texts:
I'm trying to create a smart contract to buy and sell documents. The truffle has the following token example.

pragma solidity ^0.4.4;

import 'zeppelin-solidity/contracts/token/StandardToken.sol';

contract TutorialToken is StandardToken {
    string public name = 'TutorialToken';
    string public symbol = 'TT';
    uint public decimals = 2;
    uint public INITIAL_SUPPLY = 12000;

    function TutorialToken() {
        totalSupply = INITIAL_SUPPLY;
        balances[msg.sender] = INITIAL_SUPPLY;
    }
}

Is it ok to add the following code to the same contract? Or is there a better way to do it? Is there a complete example? It sounds like a typical example.

contract TutorialToken is StandardToken {
    string public name = 'TutorialToken';
    string public symbol = 'TT';
    uint public decimals = 2;
    uint public INITIAL_SUPPLY = 12000;

    function TutorialToken() {
        totalSupply = INITIAL_SUPPLY;
        balances[msg.sender] = INITIAL_SUPPLY;
    }

    // Doc struct (maybe mapping (address => Doc))
    struct Doc {
        address seller;
        int docId;
        int priceByToken;
    }
    Doc[] Docs;

    function listDoc(int docId, int priceByToken) {
        // Insert into Docs (using sender's address)
    }

    mapping (address => Doc) Transactions;

    function buy(address buyer, address seller, int docId) {
        // Send token from buyer to seller and update Transactions
        transfer(seller, ..., buyer);
    }
}


texts: Can we have collections in Solidity and Ethereum?

texts:
Technologies i used are Ethereum and Solidity.

I am trying to store multiple row of data into the Blockchain-Ethereum with an unique ID one by one. When i try to pull the inserted rows of data from Blockchain with that particular unique ID, its returning me only the latest row which was inserted. How i can get the entire rows from Blockchain? The smart contract was build in solidity language.


texts: Mist Wallet Synch Stuck - Not coder/geek

texts:
I too have the 'synch stuck' syndrome suffered by many others. I don't think I've ever been this frustrated but am trying to be patient. After 12-24 hours I get stuck around 2.4m block after multiple tries. Tried to access my Mist wallet after a long time since last successful access and now can't get it to synch. Running Win 10. Did some searching and found the youtube video by IMineBlocks "How to use Ethereum Mist wallet with Parity intead of geth." The Parity release was 1.3.3 at the time of the video. The latest release is 1.6.8. I followed the instructions and when I executed the Parity shortcut the window monitor opened, printed out a few lines very quickly and the then window shuts suddenly. I tried loading previous versions of Parity with the same or worse result. The windows shuts so quickly that I can't read what the few lines print.

I have a few questions:
1- Am I destined to never be able to access the ETH in my wallet, ie is it lost forever
2- What does the 'Skip Peer Search' mean? When I click on it, I can see my wallet but can't do anything with it, eg. can't 'SEND' ETH...
3- Any suggestions where I can go from here.

Thanks for any help.


texts: Is it possible to connect a swift iOS app to Ethereum?

texts: Is it possible (and in that case how?) to connect an iOS app, build with swift using xcode, to an Ethereum testnet? So for instance a user would be able to login and set or get a value which is saved on the Ethereum test blockchain?


texts: How many blocks I need to wait for a confirmation on a private ethereum chain? The consensus algorithm is PoA.


texts: How do we extract the content of a hash manifest generated by swarm after a download?

texts:
As far I know, whenever we upload a file or a directory using:

swarm up File

we get back a hash that is the manifest containing the uploaded file.
However, I am not sure I do understand how to extract the content of this manifest file after using the download command like following:

swarm down bzz:/given_hash

My goal is to get the original file that was uploaded. Any idea or command that can do the work?


texts: Should we be expecting china to also capitalize on ether mining until Casper is released in Serenity? Can the developers change the code to move it from the current code to another code base such as X11 to make ASIC less likely?


texts: can we implement proof of stake contracts or proof of stake based token in solidity on ethereum network?

texts: I have written a contract in solidity that operates on the basis of proof of stake. I want to know is it possible to create a pos based token or contracts and deploy them on ether network. And are there any tradeoffs(tradeoffs as I couldn't find any existing projects out there so is there a reason people are not doing that)?


texts: Is it too late to get a refund for the DAOs

texts:
I have some DAOs and some DAO_extraBalance. Is it too late to get a refund?
If not, what is an easy way to get the refund. I do not have mist or the ethereum wallet, I just have a JSON


texts: How do I get Parity client to connect to Peers?

texts:
I'd like to use the Advanced Send feature on Parity but am having issues connecting to Peers. For example, it says on the lower bottom right, 0/15/20 peers. The first number is always 0. I do not know if this is the cause of the problem but I figured it would be a start.

When I schedule a transaction at a certain block, it gets stuck on the last step. After closing the dialog since it doesn't go anywhere, I go over to TxQueue Viewer and the transaction is there on the list. However, it doesn't move beyond the status: "First propagation: Never".

Is there a way to troubleshoot this issue?


texts:
I am new in the blockchain world and I am trying to understand the following. any help will be highly appreciable. This is my understanding after several videos and courses.

I have a private Azure blockchain.
I have created a contact and deployed it.
once it is mined by Ethereum I will get an address.
Later I can use the address and add data to it.

My question is

Does the time it take to mine has any relation to the complexity of my contract?

Do I really need to mine? because I am not using the blockchain for coins for a different use case.


texts: What is the difference between Casper and Tendermint

texts: Both are consensus protocols that fall under the category proof of stake. However - they differ in some design goals. Casper favors availability over consistency in comparison to Tendermint. What does this mean?


texts: What comes first: pendingTransactions, logs, newBlockHeaders?

texts:
I am trying to understand the order in which the data propagates.
My understanding at the moment is:
Assuming someone just made sendTransaction call, then...

First we would receive pendingTransactions describing the pending transaction. This would be issued as soon as someone makes the a mutation. At this point, this transaction has not been included in any blocks, and it is possible that it will be dropped.
Next, we would receive logs associated with the transaction. At this point, the latter transaction is already included in a block, i.e. some node has processed the transaction.
Finally, we would receive newBlockHeaders. This would fire once a block including the transaction and the associated logs has been mined.

Is my understanding correct?
The main thing that I am trying to figure out is if I can trust logs.
If I subscribe to Sync, is it safe to trust the values provided in the payload or should I add some delay after which I eth_call getReserves?


texts: myContract.getPastEvents returns undefined event


texts:
I have a very strange bug in the code. When loading a page with a code, the current account in metamask should be determined. but this only happens on one local domain. in other domaines accounts are empty. It is in chrome. In other browsers (firefox) it never finds accounts at all. Metamask is open to all sites.

let w3, myAddress, myContract;
async function connect() {
 try {
    if (window.web3 !== 'undefined') {
      console.log("Using Metamask's web3 provider");
      w3 = new Web3(window.web3.currentProvider);
   }
let promise = await w3.eth.getAccounts()
       .then(accounts => {
        let Address = accounts[0]; // get address of account in Metamask
      return Address;
    });
    myAddress =  await promise;
// is empty
    let wallet =  w3.eth.accounts.wallet;
     console.log(wallet);
    if (!myAddress) {
        alert('account not found'); }
   } catch (err) { console.error(err); }// err in empty
}


texts: What type of operations have negative gas costs?

texts: I understand that some operations cost negative gas because they free up space on the blockchain, such as selfdestructs.  What are all the operations that can have negative gas?  Does this only occur because the operation ultimately frees up space on the blockchain or are there other reasons it has negative gas?


texts: How to trace erc20 testnet deposit with web3.JS

texts: I am using ropsten testnet, I wish to detect deposit of an erc-20 token. I am using infura and use method of eth_getBlockByNumber to get all the transactions and check whether the to field match an address in my database. However, when I transfer token, the to will show the token as the address. How can I get the actual to and amount transfered when detecting deposit?


texts: How to monitor and auto-restart geth with monit?

texts:
I want monit to restart geth on crashes and send me alerts by email.

Here is what I'm trying to do.

My monit config at /etc/monit/conf.d/geth.cfg

# GETH
CHECK PROCESS geth with pidfile "/home/username/monit/geth.pid"
    start program = "/bin/bash -c '/home/username/monit/geth.sh start'" as uid username as gid username
    stop program = "/bin/bash -c '/home/username/monit/geth.sh stop'" as uid username as gid username
    if not exist then alert
    if not exist then restart

And the start/stop script /home/username/monit/geth.sh

#!/bin/bash
PID='/home/username/monit/geth.pid'
LOGS='/home/username/monit/geth.log'
KEYS='\--fast --rpc --rpcport 8545 --rpccorsdomain localhost --ipcpath /home/username/.ethereum/geth.ipc --cache=16'

case $1 in
   start)
       setsid geth "$KEYS" &> "$LOGS" &
       echo $! > "$PID"
   ;;
   stop)
      cat "$PID"
      kill -SIGINT `cat "$PID"`
      rm "$PID"
   ;;
   *)
      echo "usage: geth.sh {start|stop}" ;;
esac
exit 0

I can run geth with sudo monit start geth, but monit cannot see geth's pid right. So it will not restart geth on crashes. The problems in my script:

Cannot define geth's pid right. The geth.pid receives a process number which is higher by 2-4 numbers (e.g. 4678 instead of 4674).
Cannot kill geth with -SIGINT, have to send -HUP signal instead.

I understand this is more like a Linux question, then Ethereum's, but I believe it may be very useful.

The closest howto's I found on geth monitoring are:

Restart Geth from another process
Setting up geth Ethereum node to run automatically on Ubuntu


texts: My wallet is empty and I get this strange repeating message when running Ether in the Terminal

texts:
I was looking for a way to speed up the part where it said "X Months since last block", and found the answer here (moving from WiFi to cable)

One of the tips was booting the ETH command in the Nodes/eth/max-x64 folder.

I booted that Etc command, and now I get this message:
(It keeps repeating this message too, every few seconds)

  ✘  12:58:31.244|txcheck0  Bad transaction: /Users/travis/build/bobsummerwill/cpp-ethereum/libethcore/Transaction.cpp(76): Throw in function dev::eth::TransactionBase::TransactionBase(bytesConstRef, dev::eth::CheckTransaction)
Dynamic exception type: boost::exception_detail::clone_impl<dev::eth::InvalidSignature>
std::exception::what: InvalidSignature
[dev::eth::tag_field*] = 8
[dev::eth::tag_data*] = 9f7d3d0ec40b4d50f9a5cdf5da311d7ae68a7c0f52eaf4da79ad3f359f19eb2f
[dev::eth::tag_field*] = invalid transaction format

I think it's weird that I no longer have any ether (I should have had some left on that account). So before I buy new ETH, I'd like to find out if this isn't some virus sucking my account dry.


texts: Get key for coinbase account in go-ethereum SimulatedBackend

texts:
What's the best way to 1) pre-fund 2) get a signing key for the coinbase account in the go-ethereum Simulated Back-end?

Right now the simulated back-end coinbase account seems to default to 0x0 but I'm not able to control that with GenesisAlloc.

For more info, here is the code section for SimulatedBackend. I can get the Coinbase account with Blockchain().CurrentBlock().Coinbase(), but would like to pre-allocate some funds/get the signing key at the time of calling NewSimulatedBackend.


texts:
Does anyone know of a database of large Ethereum transactions (in terms of Gas)? I am looking for large transactions on the testnet (Ropsten) or mainnet for analysis, ideally in the hundreds of thousands of Gas, or millions.

My alternative is to run a program to do this through Geth. But this will take time. In the case that someone has already done this, I would like to know!

Thanks


texts: How can I modify inputs in truffle drizzle?

texts:
I have a set method in my contract with one address as input (address of tokens). I am using drizzle for UI, but when I use ContractForm, it will automatically generates a textbox for my input(address). I don't want users to manually put the address of tokens into the input. I just want a radio button with preset token addresses, so the user can chose which they are going to use as input.
Is there anyway to modify that ContractForm inputs in drizzle?


texts: How do projects which offer tokens in ICO work afterwards?

texts:
What is the general revenue model for ICO projects apart from token sale? I read somewhere once tokens are sold, founders are left with limited number of tokens with them let's say 10 percent.
Blockchain based projects as i understand correctly are not which can be sold later , so how the development of project is maintained in long term, let's say 10 years?If the project really gets popular and require some bug fixes in future or upgradation is required , how the cost will be handled ?


texts: ERC721, Token name and symbol not shown in etherscan

texts:
I have created a simple token with ERC721, but etherscan not show my token name and symbol, why? this is my contract

I deploy with this code

Result on etherscan

No token name and symbol showed, is there something wrong?


texts: How to write data or change varibles in smart contract on Rinkeby from web3.js

texts:
I have a smart contract which have a function to allow/disallow user to send ether to my contract. By default all ETH address are allow to send ether to smart contract.

But, if I want to disallow some ETH address not to send ether, I have to write data on to the blockchain.

The same I want to do it from my WEB APP using web3.js

Can anyone provide me with example for the same.

Thanks In Advanced .......


texts: running ethereum private server on global port

texts:
I am running private ethereum node but it is only running on local server. How can i make it run globally?
Here is the command i have executed:
geth -datadir . -rpc -rpcport "8545" -port "30303" --networkid 15 -rpccorsdomain "*" --rpcaddr  "0.0.0.0" -rpcapi eth,web3,personal,net
Here is the screen shot of grep listen command:


texts: Does ethereum stores all the transaction from exchanges?

texts:
ASAIK, most of the bitcoin exchanges don't push all the transaction to the public, on-block. This is due to bitcoin speed limitations and fees.

Does Ethereum have similar limits or do Ethereum exchanges push transactions to the public?


texts:
I am getting Error: Returned error: VM Exception while processing transaction: revert when testing MyContract.deposit()

Here are simplified versions of my code to highlight where the issue is occuring (on token.transferFrom())

//MyContract.sol

contract IErc20 {
  function transferFrom(address, address, uint) public returns (bool);
}

contract MyContract {
  IErc20 public token;

  constructor(address _token) {
    token = IErc20(_token);
  }

  function deposit(uint _amount) public {
    require(token.transferFrom(msg.sender, address(this), _amount);
  }
}

Here is the unit test file, which I am running with truffle test on ganache-cli

//MyContract.test.js

const { BN } = require("openzeppelin-test-helpers");
const MyContract = artifacts.require("MyContract");
const ERC20Mock = artifacts.require("ERC20Mock");

contract("MyContract", function([_, adminRole, user]) {
  const dai = toBytes("DAI");
  let daiAddress;
  beforeEach(async function () {
    daiAddress = (await web3.eth.getAccounts())[5];
    this.daiToken = ERC20Mock.new(daiAddress, 100*(10**6));
    this.MyContract = await MyContract.new(
      this.daiToken.address
    );
    await this.daiToken.approve(user, amount, {from: daiAddress});
    await this.daiToken.transferFrom(daiAddress, user, amount);
  });

  describe("deposit()", function() {
    const amount = new BN(1);
    it("should deposit if tokens are approved by user", async function () {

       await this.daiToken.approve(this.MyContract.address, amount, {from: user});
       await this.MyContract.deposit(amount, {from: user});  //REVERTS!
    });
  });
});

Here is the migrations script:

// migrations/deploy_dai.js

const ERC20Mock = artifacts.require("ERC20Mock");

module.exports = async function(deployer, network, accounts) {
    if (network === "development") {
        console.log("Deploying MockDAI on Development");
        await deployer.deploy(ERC20Mock, accounts[5], 100*(10**6), {from: accounts[5]);
    }
}

This is the Mock ERC20 token, which I am deploying on the development blockchain:

//ERC20Mock.sol

pragma solidity ^0.5.0;

import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

// mock class using ERC20
contract ERC20Mock is ERC20 {
    constructor (address initialAccount, uint256 initialBalance) public {
        _mint(initialAccount, initialBalance);
    }

    function mint(address account, uint256 amount) public {
        _mint(account, amount);
    }

    function burn(address account, uint256 amount) public {
        _burn(account, amount);
    }

    function burnFrom(address account, uint256 amount) public {
        _burnFrom(account, amount);
    }
}


texts: Why is the ethereum archival node so big in size?

texts: My understanding is that the archival node stores the state tree for each block -- that's the reason the size is so big. Can someone validate my understanding?


texts: Is there any way to know why a contract call cannot work through web3.py?

texts:
I have a deployed smart contract and attempt to write codes to call it through web3.py. I'm getting the following error when I call estimateGas().

ValueError: {'code': -32000, 'message': 'gas required exceeds allowance or always failing transaction'}

Due to I'm just estimating gas, I guess it should be impossible to have not enough gas. So the error should be caused by always failing transaction.

The contract function indeed has some require parts that verify something before executing the logics, like the following:

require(
   !traderNonces[msg.sender][_nonce],
   "Failed to call function due to replay attack."
);

However, I cannot ensure which part causes the error. Is there any chance that I can get the error message, such as the above message Failed to call function due to replay attack., in web3.py, so I can at least know the reason of failure?


texts: avoid replay attacks on signing on smart contracts

texts:
the scenario: a user has a privatekey
and wants to sign something to send to the contract
ex: the user send his (message,signature,publickey) to the contract and the contract can verify it with the arguments user provided and recorded it.
But in this situation, when the record on the contract is (message,signature,publickey)
an attacker can write arguments previous send by the user to overwrite present data, cause is signed by the user before the contract will verify it and record it on the contract

My question is that are there any chances that without adding another data structure like a counter (record on the contract and be part of the signature, i.e make the data to (msg,sig,pub,counter)) to avoid this kind of replay attack?


texts: I am trying to develop a token that has a function which will allow me to tax each transaction a certain percentage and send the tax to a wallet. Any ideas on how I can do this?


texts: Can I selfdestruct a smart contract without the selfdestruct function being implemented?

texts:
is it possible to selfdestruct a smart contract which I have deployed even though the selfdestruct(address) function is not implemented in the code?
Thank you


texts: Pass a function as a parameter in Solidity

texts:
Can you pass a function as a parameter in Solidity?

My guess: There is the concept of address in Solidity, but they represent contracts. Contracts can have fallback functions, but I don't think you can give them parameters. Thinking about passing the function as a parameter by address like you would do in C.

Is there a legit way to pass functions as parameters, or if not, is there a hacky way?

If there is, how? And if there isn't, why not?


texts:
I have 3 nodes, all in Ubuntu 16.04 that I have to upgrade.

To install the node, I downloaded the latest stable version from https://www.parity.io/

and then did:

wget wget [LINK_FROM_PARITY]
sudo dpkg -i [FILE_DOWNLOADED_FROM_PARITY]

to install it.

What's the best way to upgrade my nodes making sure I don't lose the content of the chain, the enode, the chain config and the peer list?

Does dpkg have an upgrade function or something like that?


texts:
Web3.js has so many newer versions than one of Geth.
I want to use the 1.2.0 version (or newer) web3 with Geth.
When compiling, can I replace the old version with any newer version?


texts:
Hi I am getting an warning in the geth console and not able to communicate with geth from the dapp also.
Here is the warning

  WARN [08-22|13:22:59] Stats login failed           err=unauthorized

What is this warning?? I am using geth with rinkeby


texts: Where is the stake amount stored in Proof-of-Stake?

texts:
So in the PoS consensus algorithm, the nodes can lock their coins and the node with the highest coins has the highest probability of getting the chance for validating coins.

I have two questions:

1) How does the process of staking coins take place? Like does the node who wants to stake their coins, send those coins to some address?

2) Who keeps track of how much is staked by whom? Is that number stored in the blockchain?

Thank You.


texts: I am trying to send TRX form leadger wallet to my exchange TRX wallet my balance was reduce and deduct but the transfer is not done. I have attached the error message i got


texts: Private key opens a different address than the one that it "should"

texts:
I have a small problem (hope it doesn't prove to be huge) with importing wallets using private keys.
I am not the most knowledgeable when it comes to Ethereum, and was hoping you guys could maybe help me. I have created a wallet on Exodus some time ago, and sent funds to that wallet. I have lost access to that wallet because I did the most rookie mistake of not backing up my mnemonic phrase / seed as soon as I created the wallet and my laptop had to mess up before I took any backups of the phrase BUT I have the address and the private key (which I thought was a solid backup option as well).
The thing is that, whenever I try to fetch my funds into any other wallet (I have tried MetaMask, Trust wallet, and Exodus), the private key opens a different address than the one it is supposed to open except on Exodus where it says that the key is invalid (but I guess that isn't related to my issue because ertain Exodus versions have this bug).
I am quite sure my private address is correct, I have copy and pasted it from Exodus (and I took a screenshot of the revealed private key for that address through Exodus as well to make sure), so it isn't an issue of a wrong private key at all.
This isn't my first time using private keys, but this is definitely the first time this happens to me. I have found a few threads online regarding this, but none offered any solutions really. It says almost everywhere that a private key is supposed to lead only to two addresses; one from the hash of the compressed public key, and one from the uncompressed one, and Ethereum uses the uncompressed one so basically the public key should lead only to one address.
Am I missing something? Is there a way to unlock a certain address using its private key?


texts: I have gone through the https://github.com/jpmorganchase/quorum-examples and it works good and fine. Now I want to make my own custom node Quorum Network what is the best method, tool or any guide available to achieve this.


texts:
Is it possible to send conditional transactions in ethereum?
For, e.g., Alice wants to send five ethers to bob. Alice has initiated a transaction for this transfer, but these five ethers will be credited to bob only when bob completes some task given by Alice. Once Bob completes the task, the transfer will complete; otherwise, these five ethers will be refunded to Alice.


texts: Compiler won't let me instantiate struct

texts:
Usually this error shows up when declaring functions and goes away by adding "memory" next to the argument, but this time I can't get it to resolve. I'm trying to instantiate a struct that takes in two parameters:
struct Obj {
    string where;
    uint what;
    }

function do() public {
    obj=Obj("here",1);
    }

the line with the new Obj triggers: TypeError: Data location must be "storage", "memory" or "calldata" for variable, but none was given.
I tried putting "memory" all over the place, after the first argument, after the second, after both, after the function, etc. Nothing seems to appease the compiler.
 I'm using pragma solidity ^0.8.0;


texts:
And if yes, how?

noob here, so this is probably a stupid question!


texts: What do you mean by private and public smart contract in private blockchain ethereum? How to create it?

texts:
What I have done
1. A running private blockchain.
2. written and deploy a smart contract.
3. smart contract works fine on my private blockchain

What I want
1. Only authorized account can access my contract, not by another one.
2. i want to maintain transaction log of contract, which account access that contract and which method that account accessed.


texts: Can anyone help me to access my eth account in metamask using infura in android

texts: My question is about accessing my eth account in metamask using infura in android


texts: How to generate a transaction for ERC20 token?

texts:
I'm currently use this package to generate new transaction in ETH:
https://github.com/kornrunner/php-ethereum-offline-raw-tx
Now I want to generate a transaction for an ERC20 token like Tether.
As I know when we want to create an eth transaction we have to set all of these items :
nonce' => $this->nonce,
            'gasPrice' => $this->gasPrice,
            'gasLimit' => $this->gasLimit,
            'to' => $this->to,
            'value' => $this->value,
            'data' => $this->data,
            'v' => $this->v,
            'r' => $this->r,
            's' => $this->s,

But I don't have any idea about tokens, are they same as ETH transaction? How and where we defined this transaction is about token and which token?


texts: How is Casper better than POW against possible government censorship?

texts:
As of now my understanding is that with POW an attack by one or multiple goverments could be orchestrated just by raiding mining farms (which can be easily identified given the electricity bill) and confiscate mining equipment + taking down pool servers and terrorism trough media ....that imho is more than enough to permanently compromise bitcoin (no need for a 51% attack)

How will Casper mitigate those risks? Will the IP of the validators be public? How will the problem of DDos be handled?

Off the bat the only clear advantage I can foresee is that if a validator is censored/taken offline ethers would be automatically redistributed to other validators (hopefully) around the world in various different jurisdictions opposed to the mining equipment being confiscated , that being said Casper would still be vulnerable to a scenario where cohercitive force and terrorism trough media is being used by governments to discourage other holders/stakers to step in and become validators themselves , in such scenario even with the use of dedicated servers to run validators the real life identity of the holder would be compromised , not to mention the loss of ethers and the legal troubles for the the hosting company .... Finally this brings in the most important question : What would happen if nobody is willing to stake?


texts: ERC-721 - How to avoid that an updatable tokenURI becomes a vulnerability for token trust?

texts:
I understand that one can use the tokenURI field to add the address for an endpoint that returns meta data for the given token. Let's imagine we create a unique asset with

tokenId = "1"
tokenURI = "https://api.endpoint.com/1"

Let's say tokenId "1" refers to an asset of value $500. However, there is also a asset with tokenId "2" which is valued $2000.
Let's assume there is a crypto market place that lets owners of assets trade their crypto collectibles and uses the tokenURI to receive meta data.

I understand the tokenURI can be updated.

What would hinder a holder of tokenId "1" to update his tokenURI to

tokenId = "1"
tokenURI = "https://api.endpoint.com/2"

What hinders the market place to display the more valuable related crypto collectible?
Why does it make sense to leave owners of the token with the possiblitiy to update the tokenURI?


texts: basic ethereum zepplin crowdsale smart contract token rate question

texts:
A basic question on how zepplin solidity code calculates token rates.
The code comments say

// how many token units a buyer gets per wei

 uint256 public rate;

however we cannot get it to serve back 1000 tokens per ETH when we pass an ammount as the rate into;

function Crowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet) {
    require(_startTime >= now);
    require(_endTime >= _startTime);
    require(_rate > 0);
    require(_wallet != address(0));

    token = createTokenContract();
    startTime = _startTime;
    endTime = _endTime;
    rate = _rate;
    wallet = _wallet;
  }

the rate is used in;

   uint256 weiAmount = msg.value;

    // calculate token amount to be created
    uint256 tokens = weiAmount.mul(rate);

Again, whatever rate we send in, high or low does not come out at 1,000 tokens per eth.

can anyone explain the working of this calculation so we can get there?

Thanks


texts: Create an Identity Card with information using blockchain

texts:
I am a very beginner in blockchain, in fact I just have a few hours reading about blockchain, bitcoin, ethereum, etc, so if this question does not belong here or makes no sense please let me know.

One of our customers (a city town hall), they want all Students from the city to have an APP on their phone that would work as an identification system.  There are 600.000 students on the city, and every student would have the app installed.

The purpose is that the students can be recognized everywhere:}
1. If they go to a library, they can use the app to borrow a book.
2. If the police stops them for random checking, then they can identify themselves

For some reasons they asked this to be implemented with blockchain.

Does this makes sense?
If it does, what documentation can I read about? I see that blockchain is more about transactions between Peers, but it looks like our APP is not about transactions but more about identification of the people.

any reading suggested is welcome


texts: What happens when you 'create' an item on the OpenSea app?

texts:
Very noobie here. I'm sorry,
Does anybody know what happens on OpenSea when you actually CREATE an item?
I know it doesn't mint one but what it does? (As it signs a transaction tho).
I've been trying for weeks to understand the "gasless" proxy thing they have but I don't know how they actually transfer an NFT to your wallet, even if it's not minted.
I also managed to deploy and mint a Creature with the example contract (open sea creatures, https://github.com/ProjectOpenSea/opensea-creatures) but how can I let users mint their own item on this factory contract?


texts: Is it possible somehow to use Ethereum from Telegram? They seem to support custom HTML5 apps, that means that you could possibly inject web3.js there?


texts: How do I detect a failed transaction after the Byzantium fork as the REVERT opcode does not consume all gas?

texts:
Pre Byzantium fork, I could use gas == gasUsed to detect when a transaction has failed (further details in How can the transaction status from a thrown error be detected when gas can be exactly the same as the gasUsed for a successful transaction?)

Post Byzantium fork, the revert opcode now returns a much lower gasUsed amount. How do I detect a failed transaction after the Byzantium fork?

See also:

Difference between require and assert and the difference between revert and throw
What improvements will the upcoming Byzantium fork bring to Smart Contract development?


texts: What is better, mapping a struct with 2 variables or having 2 mappings?

texts:
I have a mapping linking a key and a byte32, and I would like to extend it to store something as long as a byte64.

I chose to cut it in half, but what is the best (and lightest) way to store the two parts ? Should I map to a struct like this:

struct b64 {
    bytes32 part1;
    bytes32 part2;
}

mapping (uint256 => b64) public b64s;

Or use two mappings, like this:

mapping (uint256 => bytes32) public b64s_1;
mapping (uint256 => bytes32) public b64s_2;

I'm looking for the lightest solution. The only function making the mapping always writes both parts at the same time so I don't think there will be consistency issues with two mappings.

The first solution is cleaner but if I can save precious gas at every writing with the second one I'll take it.


texts: Smart Contract Error : Gas required exceeds 300000000

texts:
I got the following code from this tutorial :

https://medium.com/@merunasgrincalaitis/the-ultimate-end-to-end-tutorial-to-create-and-deploy-a-fully-descentralized-dapp-in-ethereum-18f0cf6d7e0e

pragma solidity ^0.4.11;

contract Casino {

    uint minimumBet;
    uint totalBet;
    uint numberOfBets;
    uint maximumAmountsOfBets = 100;
    address[] players;

    struct Player {

        uint amountBet;
        uint numberSelected;
    }

    mapping(address => Player) playerInfo;

    address owner; // Long string from metamask

    function Casino(uint _minimumBet) public{  // Constructor : has the same name as the contract , used to set up
        //contract owner

        owner = msg.sender;
        if(_minimumBet !=0) minimumBet = _minimumBet;

        }

        //To be for a number btw 1 & 10 both inclusive

    function bet(uint number) payable public {

        require(checkPlayerExists(msg.sender) );
        require(number >= 1 && number <= 10);
        require(msg.value >= minimumBet);

        playerInfo[msg.sender].amountBet = msg.value;
        playerInfo[msg.sender].numberSelected = number;
        numberOfBets += 1;
        players.push(msg.sender);
        totalBet += msg.value;

        if(numberOfBets >= maximumAmountsOfBets) generateNumberWinner();

        }

    function checkPlayerExists(address player) public view returns(bool) {

        for( uint i = 0 ; i < players.length; i++){
            if(players[i] == player) return true;
        }
        return false;
    }

    /*
    Generate Winner : Generates a number between 1 & 10
    */

    function generateNumberWinner() public{

        uint numberGenerated = block.number % 10 + 1; // This isnt secure

        distributePrizes(numberGenerated);
    }

    /*

    Distribute Prizes : Sends the correspondng ether to each winner
    depending on the total bets
    */

    function distributePrizes(uint numberWinner) public {

        address[100] memory winners ; // We have to create a temporary in memory array with fixed size

        uint count = 0; // This is the count for the array of winners

        for(uint i = 0; i < players.length ; i++) {
            address playerAddress = players[i];
            if(playerInfo[playerAddress].numberSelected == numberWinner){
                winners[count] = playerAddress;
                count ++;
            }
            delete playerInfo[playerAddress]; // Delete all the players array

        }

        players.length = 0; //Delete all the players array

        uint winnerEtherAmount = totalBet / winners.length; // How much each player gets

        for(uint j = 0; j < count; j++) {

            if(winners[j] !=address(0)) // Check the address in the fixed array is not empty
            winners[j].transfer(winnerEtherAmount);
        }

    }

    /*
    Annonymous Fallback function: In case someone sends ether to the
    contract so it doesnt get lost
    */
    function() payable private{}

/*
Kill function: Used to destroy contract whenever we want. Only owner
has the ability to kill the contract
*/

    function kill() private{

        if(msg.sender == owner)
            selfdestruct(owner);
    }
}

It compiles fine, but when I try to bet it REMIX throws the following error:

  transact to Casino.bet errored: Gas required exceeded limits :
  3000000. An important gas estimation may also be a sign of a problem in the contract code. Please check loops and be sure you did not sent
  value to a non payable function (that's also a reason for a strong gas
  estimation).

I would appreciate it if someone could point me in the right direction.


texts: Pass ADDRESS(string) as argument to contract function using web3.py

texts:
I've been stuck on this isseu for more then 24 hrs now.
I have the following function in my solidity contract:
function getBalance(address _addr) public view returns(uint256){
    return userBalance[_addr];
}

I'm trying to check a users balance in my smart contract using an
"address" as a argument. Whenever I pass the address as an argument,
I receive an error.
I have another function which doesn't require any arguments, which
works just fine.

I am trying to call this function in PYTHON using Web3.py as followed:
contract = self.w3.eth.contract(contract_address, abi=ABI)
addr = '0x0b5b1953752B0C41A59E6B401A13C5816078840A'
print (contract.functions.getBalance(addr).call())

I receive the following error
Could not identify the intended function with name `getBalance`, positional argument(s) of type `(<class 'str'>,)` and keyword argument(s) of type `{}`.
Found 1 function(s) with the name `getBalance`: ['getBalance()']
Function invocation failed due to improper number of arguments.

There's no example in the documentation which shows me how to pass an address as argument.
As stated in the comments. I changed my original implementation and forgot to update the ABI. I'm feeling really bad.


texts: How to limit the total supply for an ICO contract

texts:
I am trying to create a test ICO contract (simply for the purpose of learning about blockchain etc). I have followed a tutorial and produced the following contract. The total tokens supplied to the sender however seem to be limitless. How do I set it so supplied tokens are deducted from the total supply?

pragma solidity ^0.4.11;

import './IERC20.sol';
import './SafeMath.sol';

contract testy2 is IERC20 {

using SafeMath for uint256;

uint public _totalSupply = 1000000000000000000000000;

string public constant symbol = "TSTY2";
string public constant name = "testy2";
uint8 public constant decimals = 18;

// 1 ether = 250000 TSTY2
uint256 public constant RATE = 250000000000000000000000;

address public owner;

mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;

function() payable {
    createTokens();
}

function testy2() {
    owner = msg.sender;
    balances[msg.sender] = 500000000000000000000000;
}

function createTokens() payable {
    require(msg.value > 0);

    uint256 tokens = msg.value.mul(RATE);
    balances[msg.sender] = balances[msg.sender].add(tokens);
   _totalSupply = _totalSupply.add(tokens);

    owner.transfer(msg.value);
}

function totalSupply() constant returns (uint256 totalSupply) {
    return _totalSupply;
}

function balanceOf(address _owner) constant returns (uint256 balance) {
    return balances[_owner];
}

function transfer(address _to, uint256 _value) returns (bool success) {
    require(
        balances[msg.sender] >= _value
        && _value > 0
    );
    balances[msg.sender] = balances[msg.sender].sub(_value);
    balances[_to] = balances[_to].add(_value);
    Transfer(msg.sender, _to, _value);
    return true;
}

function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
    require(
        allowed[_from][msg.sender] >= _value
        && balances[_from] >= _value
        && _value > 0
    );
    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
    Transfer(_from, _to, _value);
    return true;
}

function approve(address _spender, uint256 _value) returns (bool success) {
    allowed[msg.sender][_spender] = _value;
    Approval(msg.sender, _spender, _value);
    return true;
}

function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
    return allowed[_owner][_spender];
}

event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);


texts: Sending a transaction without using MetaMask

texts:
I have designed a contract deployed on the Rinkeby with web3. I have also implemented a react app to interact with the blockchain.
I want to use my application without metamask but I got this error in Chrome "No "from" address specified in neither the given options, nor the default options." when I try to send a transaction like this:

await tracker.methods
      .createAsset(name, description, manufacturer, price)
      .send({
        from: accounts[0],
        value: web3.utils.toWei(this.state.amountToStake, "ether"),
        gas: "1000000"
      });

Based on the code below can someone tell what I am doing wrong?

web3 script:

import Web3 from "web3";
let web3;
const provider = new Web3.providers.HttpProvider( // creating my own provider
"https://rinkeby.infura.io/v3/..."
);
web3 = new Web3(provider);

export default web3;

deploy script:

const HDWalletProvider = require("truffle-hdwallet-provider");
const Web3 = require("web3");

const compiledTracker = require("./build/AssetTracker.json");

const provider = new HDWalletProvider("mnemonic",
 "https://rinkeby.infura.io/v3/...");

const web3 = new Web3(provider);

const deploy = async () => {
const accounts = await web3.eth.getAccounts();

const result = await new web3.eth.Contract(
JSON.parse(compiledTracker.interface))
    .deploy({ data: compiledTracker.bytecode })
    .send({ gas: "2000000", from: accounts[0] });

Note: Everything was working fine with MetaMask but I need to send a transaction without MetaMask that's why I defined a provider with Rinkeby.


texts: Create contract that receives and sends bonus money to many addresses. What is the gas price?

texts:
I would like to create a contract that holds references to 20 Ethereum addresses. Each address has some associated Ethereum value. I want to send the message to this contract later and call function "payBonus" which accepts the ordered array of addresses.

1st address in array gets 60% of total sum of Ethereum, 2nd - 30%, third - 10%. All other 17 addresses get nothing.

Imagine 20 people made bets and I decide who are the winners.

I have few questions

It's really expensive to store data. Do I have to store 20 bytes (people who bet) * 20 addresses + byte_size_of_ethereum_type * 20?
Do I have to pay for 20*3 bytes while sending the message to my contract "payBonus" function?

Thanks!

  It's not clear why the other 17 addresses need to be stored?

The scenario is:
I create betting contract. 20 people take part in it and deposit money to the contract. The idea is to record which user has put money on the contract.

  If the contract already has the 3 address, you don't need to pay for the 20*3 bytes when calling payBonus

Contract knows who and how much deposited funds to it. The contract doesn't know who won. Contract owner (me) should send three top winner addresses. I should send a message to a contract with three addresses and it should cost a gas since message changes state of contract and transferred over

  Ethereum
  Thanks!


texts:
I'm using the Oraclize to get the random number for bets. When the function bet() is called and if the oraclize is failed it should call the pingOracle() again. Below is example

function bet() public payable {
    require(msg.value == 0.1 ether);
    pingOracle();
}

function __callback(bytes32 _queryId, string _result, bytes _proof) public onlyOraclize  {

    if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
        oracleFailed = true;
    } else {
        uint randomN = (uint(keccak256(abi.encodePacked(_result))) % (max.sub(min)).add(min));
        revealWinner(randomN);
        oracleFailed = false;
    }

    if(oracleFailed) {
        count = count.add(1);
        pingOracle();
    }
}

function pingOracle() private {
    oraclize_setProof(proofType_Ledger);
    bytes32 queryId = oraclize_newRandomDSQuery(delay, N, gasOraclize);
}

function revealWinner(uint _index) internal {
    uint amount = pot.sub(amountforTeam).sub(gasOraclize.mul(gasPriceOraclize));
    winner = users[_index];
    winner.transfer(amount);
}

In this code snippet, if there is no proof verification, then the
function pingOracle() is called again but when the oraclize is failed for example gasOraclize isn't enough for calling oraclize or by other reasons I can't handle it... So how can I handle it and call the pingOracle() again?
Thanks in advance)


texts: It would be great if anyone could help me out. I am creating an auction website for bidding NFTs. I am stuck at a point where I need to know whether the nft on auction is sold on some other platforms like opensea etc. If that's the case I would like to refund the money of bidders.


texts: I use the Jaxx wallet, I did reset the wallet as per the help function, due to my balances not updating.  My ETH balance is now reflecting but the currency tab does not update it reflects as 1 ETH = $0.00  wallet


texts: How to transfer ETH out of owner's address?

texts:
I can receive ETH and transfer to owner via:

function () payable {
    owner.transfer(msg.value); // owner = address of owner
}

How can I have a function which does the reverse thing? Take ETH from owner and transfer to msg.sender?


texts: High transaction fee when participating a token sale

texts:
I took part in a token sale yesterday and reviewing the transaction information I see this:

Value: 0.2 Ether ($55.38)
Gas Limit: 82311 Gas Price: 0.000000024 Ether
Gas Used By Txn: 82310 Actual Tx
Cost/Fee: 0.00197544 Ether ($0.55)
Cumulative Gas Used: 124310

Isn't the transaction fee way too high? Here was said that a typical transaction cost would be around 0.001 USD. In my case it was around 50 times that value. And given that I sent 0.2 ETH, the fee was of almost a 1%, a lot. Is this the norm now or my case was an isolated one?

Please, correct me if I'm getting something wrong, but cryptocurrencies are willing to replace the banking system, while SEPA transfers are free, a 1% fee per transaction will make that pretty impossible IMHO.

Thanks for your answers!


texts: How to import account to metamask using private key through code?

texts: I am trying to create an application where each user is assigned his own private key and he needs to manually import the account in Metamask extension and then he can proceed with the transaction. Is there any way I can automatically set the private key in client-side Metamask Extension?


texts: What local testnet can be used while developing contracts in ETC? In ethereum I have used Ganache. Similarly, how can I make things work with ganache for ETC contracts, or are there any other options?enter code here


texts: Is it possible to do constant-time in-memory caching of values read from a storage array?

texts:
Situation:
I have an algorithm which has an asymptotic runtime of O(log^2 n). It involves a binary search nested within another binary search. These binary searches are upon a storage array. It is likely that the nested binary search will end up re-reading storage array values which have already been read by a previous iteration of the parent binary search.
I would like to somehow cache values which have been read from the array. However, the traditional caching implementation approach (a map from an input such as the value's index to that index's value) does not seem possible in Solidity. This is because the mapping type can only be created within storage, not memory. Clearly, this would defeat the purpose of my cache.
Current Best Approach
The best approach I have so far come up with is to create a fixed-size in-memory array for which values are a pairs of (index, value). In order to interrogate the cache for a hit or miss, a linear scan on this this array would be done to check if the target index has been stored.
This is obviously not ideal, as the overhead of re-reading a value from storage is "only" 500 gas. It is likely that the gas overhead of this linear scan will, statistically speaking, result in a higher gas cost overall than eschewing a cache entirely.
Essence of the Question
Is the described approach the best approach available given the tools Solidity offers?
I would like to hopefully achieve log-time or constant-time cache interrogation. This does not seem possible without an in-memory mapping, or an in-memory array of the same length as the storage array. This is not an option as I must keep the gas cost of searching the array sub-linear in terms of array length.
Perhaps one might use a constant-size in-memory array which stores the (index, value) tuples in sorted order by the index? This would make it possible to perform a binary search on the array given the index in question but results in log-time for both setting and getting from the cache.


texts: AttributeError while trying to call a contract using web3py and Infura

texts:
I am trying to call a function from an already-deployed contract on the Ropsten network:

from web3 import Web3

infura_url = "https://ropsten.infura.io/v3/XXXXXXXXXXXXXX"
w3 = Web3(Web3.HTTPProvider(infura_url))

ABI = '[{"constant":true,"inputs":[],"name":"say","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]'

contract_address = '0xF12f96cbc638E01546d9Ba3a1847BE762ea6dd4b'
contract = w3.eth.contract(contract_address, abi=ABI)

print('Return message from function: {}'.format(contract.say()))

My Infura key works, just tried to get the last block and balance of some random account. But I cannot interact with the contract despite giving the correct ABI and contract address? I also tried with:

contract.functions().say()
contract.functions.say()

But I am always getting an AttributeError?


texts: if the hardware wallet company ledger goes out of business, what will happen to my crypto asset / private keys in ledger? I heard that the hardware wallet ledger is not open-source, so will the company get access to my private key? Will I be able to transfer my crypto elsewhere?


texts: How is transaction finality correlated with transacted amount?

texts:
It was argued by Vitalik Buterin that transaction security can be a function of the amount the transaction carries. This is because of the economics of attacks.

How many block confirmations would you say are just a block confirmation too few for the given amounts:

1, 2, 5, 10, 20, 50, 100, 200, 500, 1000 USD?


texts: How to set token price inside the contract for ICO?

texts:
I am confused with decimal places and how it effects the rate of token we set for ICO etc.
Lets say, ERC20 Token A have 2 decimal places and per ether 10 tokens shall be sell, then how shall I set the price per wei in contract?

How many A tokens = 1 wei ?

When:
10 tokens = 1 ether.


texts: layer2/sidechain interactions with Ethereum

texts:
At this time, there is a big problem on Ethereum: gas fees.
Ethereum 2.0 will solve this problem but it will take some time.
I have read it is possible to work with Layer 2 protocols and sidechains.
There is something i want to understand:

Can we exchange "real" Ether when we work on a layer 2 protocol/sidechain ?
Is it possible to send or receive "real" Ether with someone which do not work with a layer 2 protocol/sidechain ?
Is it possible to intract with a "pure-Ethereum" smartcontract from a layer 2/sidechain ?

Thanks


texts: How to access multiple return values from solidity function in web3.js

texts:
I have written a solidity contract deployed on Ropsten network. I am using lite-server, NodeJS to develop a front-end. I have figured out how to use events and I can access a getter with one return value:

 myBorrower.getBorrowerName(function(err, res) {
    $("#loader").show();
    if (!err) {
        $("#borrower").html('Borrower Name: ' + web3.toAscii(res));
        $("#loader").hide();
    }
});

but I cannot figure out how to access a getter with 2 values in the callback function in web3. The Javascript code is:

   myPortfolio.getPortfolioInfo(function(err, res) {
        $("#loader").show();
        if (!err) {
            $("#portfolio").html('Portfolio Name: ' + web3.toAscii(value.args[0]) + ' Ether Balance: ' + web3.toAscii(value.args[1]));
            $("#loader").hide();
        }
    });

I know that args[0] is not correct, but I cannot figure out what it should be.

The relevant solidity function is:

    function getPortfolioInfo() public view returns (bytes16, uint){

    return (portfolioName, portfolioBalance);
}

Can anyone help me with this please? Thanks.


texts: Can't use object "compiled" in var compiled = web3.eth.compile.solidity(source);


texts: Can a transaction end sucessfully (i.e. not revert state) but some of it's 'traces' run out of gas?

texts:
This transaction: https://etherscan.io/tx/0xfcf6acee992a6562aeb641fe830b93a6e6c3be9080eb3842909137824d6a7881, has an odd message that I first noticed today:

Although one or more errors occurred [Out of gas] contract execution completed

If I retrieve the transaction using EtherScan's API, EtherScan does not report it as an error transaction (and, I don't think it was an error transaction). If I look at the traces of the transaction by pulling them from a local node, many of the traces report "out of gas".

I was under the impression that if any part of the transaction ran out of gas, the entire transaction would revert.

Question: How is this possible? What happened here? Is this common?

Note: I will be more likely to accept the answer if you provide simple, Solidity example of how this can happen.


texts: I'm new to Coinbase and was wondering how to buy and sell on it, and what the buying and selling means for me? Please and thank you

texts: I'm new to Coinbase and my balance is zero, what does buying and selling mean for me, and how should I do it?


texts: How can I create the wallet that has a mnemonic with an extra word that I choose? I tried doing that with MyEtherWallet however when I create it with MEW I don't get the private key. I'd like to get the private key so that I can add it to MetaMask.


texts: Can you pass events as parameters to functions?

texts:
I got the error:

ParserError: Expected type name

when I used following the following convention to pass an event as a function parameter:

  event MyEvent(string s1, string s2);

  function _emitEvent(event eventName) internal {
    emit eventName('hello', 'world');
  {

  function otherFunc() public {
    _emitEvent(MyEvent);
  }


texts: Accessing web3 object in Chrome terminal using React

texts:
I am receiving a "not defined" error when trying to access the web3 object in Chrome terminal. My current setup:

running testrpc
web3 object successfully instantiated in App.js
built app using React
using Chrome incognito window

I would like to be able to access my contract through the Chrome terminal but when I try to set the web3 variable in terminal here:

var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

I receive the error Uncaught ReferenceError: Web3 is not defined in Chrome console.

In my App.js file, I have the following: import Web3 from 'web3';. When I set the variable in App.js, console.log(web3) outputs the object correctly. When I try to add import Web3 from 'web3'; in Chrome terminal, I get the error Uncaught SyntaxError: Unexpected token import.

After doing a little research it looks like I might need to use require and Browserify to use the web3 library correctly in Chrome terminal. Are there other ways to use the web3js in React in Chrome terminal using my current setup?


texts: What does it mean to have a failed TxReceipt Status?

texts:
I realize this is probably a noob question so please forgive me, but what does it mean to have a failed TxReceipt?

So for instance: https://etherscan.io/tx/0x54f66e0c91b380b4779e92a8f0475663aa764f1c196bf98ec35fa5f11e4c0eea

I mean, it's obviously part of the chain, but it implys that because something failed, the value gets reverted? What exactly failed here? Because it certainly deducted the value from the origin address, that sure didn't fail.


texts:
I'm getting the error:

  Contract "StarNotary" should be marked as abstract.

pragma solidity >=0.4.24;

import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract StarNotary is ERC721 {
    struct Star {
        string name;
    }

    mapping(uint256 => Star) public tokenIdToStarInfo;
    mapping(uint256 => uint256) public starsForSale;

    // Create Star using the Struct
    function createStar(string memory _name, uint256 _tokenId) public {
        Star memory newStar = Star(_name);
        tokenIdToStarInfo[_tokenId] = newStar;
        _mint(msg.sender, _tokenId);
    }

    // Putting an Star for sale (Adding the star tokenid into the mapping starsForSale, first verify that the sender is the owner)
    function putStarUpForSale(uint256 _tokenId, uint256 _price) public {
        require(
            ownerOf(_tokenId) == msg.sender,
            "You can't sale the Star you don't owned"
        );
        starsForSale[_tokenId] = _price;
    }

    function _make_payable(address x) internal pure returns (address payable) {
        return address(uint160(x));
    }

    function buyStar(uint256 _tokenId) public payable {
        require(starsForSale[_tokenId] > 0, "The Star should be up for sale");
        uint256 starCost = starsForSale[_tokenId];
        address ownerAddress = ownerOf(_tokenId);
        require(msg.value > starCost, "You need to have enough Ether");
        transferFrom(ownerAddress, msg.sender, _tokenId);
        address payable ownerAddressPayable = _make_payable(ownerAddress);
        ownerAddressPayable.transfer(starCost);
        if (msg.value > starCost) {
            msg.sender.transfer(msg.value - starCost);
        }
    }
}

What I know of abstract contracts is that they have to do with interfaces. I have a suspicion that it has to do with the inheritance from ERC721 of the Open Zeppelin library.

ERC721 has three interfaces it's inheriting from: IERC721, IERC721Metadata, IERC721Enumerable.  Do I have to go through the entire list of functions from those three interfaces and fill in what's missing in either the StarNotary contract or ERC721?


texts:
In a dapp application who listens to events? the geth node or my node.js component (backend component?

How can I implement the listen function in web3.js?


texts: What is the time zone of the Ethereum block chain?

texts:
In Solidty, you can use now keyword or block.timestamp to get the timestamp of the current block. This value, which is set by the block miner, can be used to work with time in your smart contract (which will treat 'now' as the time at which the miner says the code was executed).

The number returned is given in standard UNIX 'epoch' time, which is the UINT32 number of seconds since January 1, 1970 at 00:00:00 (midnight, start of day).


texts:
I was trying this tutorial that implements a simple DEX.
I am specially interested in the non payable function sell, that exchange custom tokens for ETH.
function sell(uint256 amount) public {
    require(amount > 0, "You need to sell at least some tokens");
    uint256 allowance = token.allowance(msg.sender, address(this));
    require(allowance >= amount, "Check the token allowance");
    token.transferFrom(msg.sender, address(this), amount);
    msg.sender.transfer(amount);
    emit Sold(amount);
}

It is always mandatory for the user to call the approve function of the ERC20 Smart Contract to be sold? Is there any way to do both steps (approve/sell) in a single transaction?


texts:
I started downloading the blockchain from mist wallet, and got frustrated by slow speed after 30%.  I then switched to geth --fast --cache=1024, but did not see until later that I should have used geth removedb beforehand.

geth --fast --cache=1024 is downloading slowly.  Is that the only issue I will have by not using geth --fast --cache=1024 first, or will my db be corrupted for some reason, or any other unknown issues?


texts: Getting an address from ethereumjs-utils ecrecover

texts:
I am trying to sign a string using web3.eth.sign() and then get the public key I signed with from the signature. To do this I am using ecrecover() from ethereumjs-utils, which returns a buffer. When I use bufferToHex() on the buffer it gives a hex string that is much too long to be an address - 130 characters including '0x'

web3.personal.unlockAccount(myAccount,pass)
msg = web3.sha3(aString)
sig = web3.eth.sign(myAccount,msg)
r = sig.slice(0, 66)
s = '0x' + sig.slice(66, 130)
v = '0x' + sig.slice(130, 132)
v = web3.toDecimal(v)
msg = ethJsUtil.toBuffer(msg)
addr = ethJsUtil.ecrecover(msg,v,r,s)
addr = ethJsUtil.bufferToHex(addr)

I took most of the code from the answer to workflow on signing a string with private key, followed by signature verification with public key but had to convert 'msg' to a buffer as ecrecover threw a type error otherwise.

What do I need to do to convert the buffer from ecrecover to an address?


texts: Can a contract with no payable function have ether?

texts:
The question in the title says it all.

To the best of my understanding, the only way to deposit ether into a contract is by calling a payable function, and set msg.value larger than 0 (and of course, the function should complete successfully without reverting).

But if there are no payable functions to begin with, is it ever possible that the ether balance of the contract will be larger than 0?

Thank you!


texts: Remix IDE: How can I open a file from GitHub repository ID

texts:
I want to compile and use a smart contract located in a GitHub repository on a specific branch or compile ID. I did it the same thing in the past but I've always used a URL which prompted the Git ID as a pop-up.

I can't recall the URL and I don't see the open from git id option within Remix.

Can anyone point me on the right direction?

Thanks on advanced.


texts: Solidity Inheritance - when is parent function invoked?

texts:
I have 2 contracts:
pragma solidity ^0.5.16;

contract Bar {
    uint public b;
    address  owner;

    constructor() public {
        b = 100;

    }

}

contract Thing is Bar {
    uint public foo;
    constructor() public {
        foo = 1;
    }

    function setFoo(uint x) public {
        foo = x;
    }

}

On remix, I notice that when I deploy Thing, its b field is set to 100. This means that the parent class is invoked at some point - this seems counter-intuitive.
In most programming languages, you have to explicitly invoke super to invoke the parent class; it allows for better flexibility as you have control over when you want to invoked the parent functions - something that seems impossible in solidity.
I would love some pointers to understand the inheritance model in solidity.


texts: Contract to store balance of all ETH sent to this contract address

texts:
i'm new to solidity and am trying to learn writing some contract on my own. I've came across an ethereum forwarding contract where eth sent to this contract address gets automatically forwarded(sent) to the destination address.

pragma solidity ^0.4.21;

contract Forwarder {

  address public destinationAddress;
  event LogForwarded(address indexed sender, uint amount);
  event LogFlushed(address indexed sender, uint amount);

  function Forwarder() public {
    destinationAddress = msg.sender;
  }

  function() payable public {
    emit LogForwarded(msg.sender, msg.value);
    destinationAddress.transfer(msg.value);
  }

  function flush() public {
    emit LogFlushed(msg.sender, address(this).balance);
    destinationAddress.transfer(address(this).balance);
  }

}

My questions are:

How can i write a function to automatically increment the balance of the ethereum deposited into this contract address for tracking purposes?
How can i call this function from web3?

All help is appreciated.


texts: What are some Blockchain-based email services? I'm looking for some email services which are based on crypto/blockchain tech. Preferably anyone can set up an account and use it for free.


texts: When Bitcoin and Ethereum initially launched they had emblematic figures such as a B and a prysm to represent the token on exchanges and wallets e.g. MetaMask. Does one have to use JavaScript to plugin the image to each exchange?? I would like to know


texts: Can ganache-cli connects to another ganache-cli?

texts:
Is it possible to create a private network using ganache-cli?
Can a ganache-cli running on port 8545 connect to ganache-cli running on port 9545?

Can we use ganache-cli as a node? Or it is a complete network?

Thanks!


texts:
I have setup an Infura account to send transactions on the kovan network.
This is the code I want to use to send ether to another account (current one has 1 ether from a faucet):

var Web3 = require('web3');
var web3 = new Web3('wss://kovan.infura.io/ws/v3/<PI>');
var Tx = require('ethereumjs-tx');

target='<target address>'
priv='<priv key>'
address= '<from address>'
a=web3.eth.accounts.privateKeyToAccount(priv);

web3.eth.defaultAccount =address

const EthereumTx = require('ethereumjs-tx').Transaction
const privateKey = Buffer.from(
    priv,

  'hex',
)

price=20_000_000_000
limit=21000

const txParams = {
  nonce: '0x199',
  gasPrice: "0x"+price.toString(16),
  gasLimit: "0x"+limit.toString(16),
  to: target,
  value: "0x100",
}
// The second parameter is not necessary if these values are used
const tx = new EthereumTx(txParams)
tx.sign(privateKey)

var serializedTx = tx.serialize();

web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);

console.log("success")

But the transaction never gets mined, no matter how high I set the gas limit. I eventually get this message

(node:28855) UnhandledPromiseRejectionWarning: Error: Transaction was not mined within 50 blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!

What am I doing wrong?


texts: How to detect if the user cancels a transaction in Metamask?

texts:
I want to detect if the user has clicked a button that will make metamask popup asking them to submit, but then rejects the transaction. I have something like the following:

Contract.deployed().then(function (contractInstance) {
        contractInstance.function({ from: web3.eth.accounts[0]}).then(function (error, result) {

            if (!error) {
                console.log('ok')
            } else {
                if (error.message.includes("User denied")) {
                    alert("You rejected the transaction on Metamask!")
                } else {
                    alert(error)
                }
            }

        })
    })

This doesn't work as intended. How should this be done? The error printed if the user rejects the transaction is:

  Uncaught (in promise) Error: Error: MetaMask Tx Signature: User denied
  transaction signature.

So presumably this should be simple by checking if that's the error message.


texts: Storing Ether based digital assets in a paper wallet

texts:
This morning I was looking for a paper wallet generator to move Augur out of an exchange, and I found a reddit post saying that as Augur is an ETH based token you can use an ETH address to store it.

How would that work though - what happens if i move both Augur and ETH to that address? Would they both be accessible afterwards? I know i probably shouldn't do that, but I am just curious how it would work at all.


texts: I need a long-running private Ethereum net (at least for 2 weeks) with fast block times. I have a single machine which is mining. When setting the difficulty very low, the block-time is very fast in the beginning. "Unfortunately" the difficulty gets adjusted so that after some hours the block-time gets towards the usual 14s. Is there a way to change that? I assume I can re-build geth and set the target block-time somewhere? Or is there any easier method?


texts: How to tell ethminer the specific account/address where Ether should be put in?

texts:
On the farming machine i have two accounts:

> geth account list

  0x.......1

  0x.......2

i've started ethminer with ethminer -G and the Ether lands in the first account. But i want it being farmed into the second account, as the second one is an imported wallet.

'ethminer --help' does not offer any option for that.


texts: Ether taking long time to send between my accounts?

texts:
I sent ether from my 'Account 1' to 'Main account (Etherbase)' and it has got 0 out of 12 confirmations. It has been about 20 minutes since the transaction was created. I am using the Mist wallet version 0.8.9.

Here are the details of the gas used:

Fee paid: 0.00042002 ETHER

Gas used:   21,001

Gas price:  0.02 ETHER PER MILLION GAS

Transaction Details:

Transaction ID: 0x58fb752c8807ed1c5fa46a4a1c17cf37e97f024697e7f1309597f3679376e5a5

Block height: 3367602 (97 block confirmations)

I am wondering what the reason for the delay is for the transaction, or can you not send to the 'Etherbase' account?

Is there somewhere to view the status of the blockchain?


texts: Simple function triggering infinite gas warning?

texts:
When I compile this in Remix (0.4.21+commit.dfe3193c.Emscripten.clang):

  uint256 public rewardAmount = 40;

  function adjustReward (uint256 reward) onlyOwner public {
    rewardAmount = reward;
  }

I'm getting this error:

  Gas requirement of function Quarters.adjustReward(uint256) high:
  infinite. If the gas requirement of a function is higher than the
  block gas limit, it cannot be executed. Please avoid loops in your
  functions or actions that modify large areas of storage (this includes
  clearing or copying arrays in storage)

Any ideas why this simple function is triggering this warning and how to fix it/avoid the warning?


texts: I currently have a contract which requires around 16M gas to deploy and execute. Trying to deploy using Parity on Kovan net fails due to gas limit being reached. On my private network I just configured the gas limit of the test server to match my needs, however I assume this won't help when it comes to deploying to an actual network since other miners have lower gas limit settings and since we need a consensus contracts like these simply can't be deployed?


texts:
Let’s say I want to build an app that is not completely decentralized, in fact it serves Restful APIs to the frontend and uses a private ethereum blockchain in the backend to process sensitive data and manage user permissions.
I create for each user when signing up to my backend an ethereum account using his password.
The backend is running NodeJS express, and connected to the web3 instance.
Whenever the user wants to make an action he is required to enter his password, then I use this password to unlock his account and send a transaction (or it could be a contract call).

Does it makes sense to act as a middleware between the user and the private blockchain? I mean from an ethereum design point of view is this a common practice? How should the user be aware of this practice if he is not seeing anything related to blockchain because all the work is done behind the scenes? How could the user trust my system that his password is not going to be leaked?
Is it recommended in such case to use multiple nodes for this private blockchain? What benefit does it bring with it? Is it only the high availability and removing the central point of failure?


texts: Return a value while hiding output from logs

texts: I would like to return a value to one ethereum address without the other parties of the contract seeing the returned value. The returned values always show up in the logs as decoded output. How do I pass a value to only one entity without the others in the contract knowing it? Is there a way to hide the decoded output from the logs? if there any other way?


texts:
I'd like to understand how can I send my MCO to MyEtherWallet, I've just tried to send 1 from Bittrex using as withdrawal address the one of the wallet but after 2 hours it looks like it the transaction has been done on Bittrex but not sign of life from MyEtherWallet.

Could the waiting time be longer? Do I have to spend some Gas from Bittrex (isn't it automatic)?


texts: How are view/pure functions handled in upgradeable contracts?

texts:
I have read through some standards regarding upgradeable contracts like EIP-1538, EIP-1822 and EIP-2535, and it seems most of them rely on the proxy pattern where a proxy/storage contract with a fallback method uses delegatecall on a "logic contract" to run its code. However I'm not sure how the proxy may call the view/pure functions in the "logic contract" this way? It seems in order to perform a delegatecall, you can't use it in a view function, and you must send a transaction for it.
After read through a lot of docs, I still cannot find anything regarding the handling of view/pure functions in a supposedly upgradeable contract. I wonder if I have missed something? Anyone can explain how these proxy contract based on delegatecall handled view/pure functions? Thanks.


texts: Receiving unexpected JSONRPC requests on my website

texts:
I have a production website (nothing about blockchain or related) and I a received hundreds of POST request to "/" with these params.
Obviously my server raise an error because it doesn't know how to handle it, but i am curious. What are these request? Is it something bad?

POST "/"

 {
      "id" => 0,
      "jsonrpc" => "2.0",
      "method" => "eth_blockNumber"
    }

POST "/"

{
  "jsonrpc" => "2.0",
  "id" => 1,
  "method" => "eth_getBlockByNumber",
  "params" => [
    "0x0",
    false
  ]
}


texts: Are there any companies working on blockchain with clojure?

texts: Which commercial fintech companies or startups are working on clojure and blockchain


texts: Using a loop to ~ reset a storage array?

texts:
How am I supposed to reset an array with previous values to just an empty array? Can't figure it out for the life of me. Using solidity version 4.26, tried...

tokenContract[tokenAddress].someArray = new uint256[];
tokenContract[tokenAddress].someArray = [];
tokenContract[tokenAddress].someArray = uint256[];

It's a mapping with an address attached and then linked to an array but I doubt that has any influence on it.

resolved
My issue wasn't the ability to delete the array but that I was using a loop to do so, and since my loop integer was (and must be) a uint (unsigned integer that cannot become negative), on the last iteration it would break. Hence, if you're running through an array and get to the last element, please insert the following...

if (x == 0) {
return;
}

Hopefully, it will save you the whole day. Thank you for the answers.


texts: Recover address from signature using web3j

texts:
I have signed a data string using the following code snippet in web3js

var data = "hello world";

web3.personal.sign(web3.fromUtf8(data), web3.eth.accounts[0], function(error, result) {
    if (!error) {
        console.log(data);
    } else {
        console.log(error);
    }
});

Now I am trying to verify the address used to sign said string  from web3j

public static boolean verifyAddressFromSignature(String address, String signature)
{
    byte[] signatureBytes = Hash.sha3(signature).getBytes();
    byte v = signatureBytes[64];
    if(v < 27)
    {
        v += 27;
    }

    SignatureData sd = new SignatureData(v, (byte[]) Arrays.copyOfRange(signatureBytes, 0, 32), (byte[]) Arrays.copyOfRange(signatureBytes, 32, 64));

    String addressRecovered = null;
    boolean match = false;

    // Iterate for each possible key to recover
    for (int i = 0; i < 4; i++)
    {
        BigInteger publicKey = Sign.recoverFromSignature((byte) i, new ECDSASignature(new BigInteger(1, sd.getR()), new BigInteger(1, sd.getS())), signature.getBytes());

        if (publicKey != null)
        {
            addressRecovered = "0x" + Keys.getAddress(publicKey);
            System.out.println(addressRecovered);
            if (addressRecovered.equals(address))
            {
                match = true;
                break;
            }
        }
    }

    return match;
}

However, none of the generated addresses match the one used to create the signature.

Can anyone shed any light on what I am doing wrong?


texts: How can I solve the unlock address issue?

texts:
I created the address and unlocked the address when it is created.

var address = response.substring(2).toLowerCase();
web3.eth.personal.unlockAccount(address, pwd, 300);

Once created, I sent ether to other address.
It worked at that time.

After that, I restart the wallet and I can't resend ether.

Error is following.

error Error: Returned error: authentication needed: password or unlock

In this case, how can I do?

If I did't restart the wallet, will it work in the future?


texts: How can I maximize the probability that my ETH nodes stay synchronized with mainnet for as long as possible?

texts:
I run three full ETH nodes, one on my local, home network, and two in the cloud. All three make use of geth.

My "local" node, is always in sync with mainnet, i.e. always showing the same last block number (or within 1 or 2 blocks of the same number) as the LAST BLOCK number shown on Etherscan.io.

My "cloud" nodes, on the otherhand, spend the majority (yes, the majority!) of their time lagging by hundreds (or even thousands) of blocks behind mainnet. This situation has persisted for several months. To be clear, that is to say that there are times when the nodes are fully synced, but this situation will last for no more than a few hours, and then the nodes will spend 24 - 48 - 72 hrs lagging, and lagging badly...

In case it is relevant, one of the "cloud" nodes is mining with multiple remote miners (approx 20, using ethminer, with total hashing power approx 3.2 GH/s). The other "cloud" node is a fail-over node in case the first has problems, but it is generally not supporting remote miners at any given point in time. Both of these "cloud" nodes are suffering from the same syncing problem.

So, does anyone have any suggestions or tips for keeping ETH nodes synced? Why does my "local" node manage this effortlessly, while my "cloud" nodes are making a "hash" (and an "ethash") of it?


texts: What argument does contract.GetFunctionSignature expects?

texts:
I'm trying to get function by signature from contract using Nethereum.Contracts.Contract.GetFunctionBySignature.
This function seems to expect the signature of function, however how can I generate the function signature appropriate for the above method?
For example, there's a function like this... function F(bool by) public {}
and I tried for the signature of this function by ...

F(bool)
GenerateSha3Signature ("F", [| boolParam |])
and none of them succeeded to find the function. What the hell this method expects for the argument?
Thanks, waiting for the precious answers.


texts: Deleting chain data to start new year fresh

texts: I guess I should start saying that I am not a developer. As a noob, how can I delete the chain data so that I can re-download the chain again using the latest Ethereum Wallet version? I have been trying to re-sync for quite a while now but it is just going extremely slow. Any help is greatly appreciated!


texts:
I deployed my smart contract on Kovan Etherium testnet. After that, I am trying to interact with smart contract methods using web3 1.0.0. Below is my node js code:

var Web3 = require('web3');
var api = myapikey;
const testnet = 'https://kovan.infura.io/'+ api;
const web3 = new Web3(new Web3.providers.HttpProvider(testnet))

function a (){
        const abi =[{ abi json}];
        var MyContract = new web3.eth.Contract(abi,'0xf...');
        console.log(MyContract.address);
        console.log(MyContract.jsonInterface);
        MyContract.methods.buyCoordinator(1,'https://cdn.pixabay.com/photo/2016/02/17/19/08/lotus-1205631_960_720.jpg','abc').call({from:'0x7...'},(error, result) => {
                console.log(result);
                console.log(error);
        });
}

a();

It returns null and giving me the following error:

  Error: Node error: {"code":-32015,"data":"Reverted 0x","message":"VM
  execution error."}
      at Function.validate (/home/administrator/node_modules/web3-providers/dist/web3-providers.cjs.js:114:18)
      at HttpProvider._callee$ (/home/administrator/node_modules/web3-providers/dist/web3-providers.cjs.js:708:61)
      at tryCatch (/home/administrator/node_modules/regenerator-runtime/runtime.js:62:40)
      at Generator.invoke [as _invoke] (/home/administrator/node_modules/regenerator-runtime/runtime.js:288:22)
      at Generator.prototype.(anonymous function) [as next] (/home/administrator/node_modules/regenerator-runtime/runtime.js:114:21)
      at asyncGeneratorStep (/home/administrator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
      at _next (/home/administrator/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
      at
      at process._tickCallback (internal/process/next_tick.js:188:7)

Can anybody tell me the meaning of this error? Where I am getting wrong? And how to confirm whether the smart contract has interacted or not?


texts:
I just crated a NFT and deployed it on Rinkeby to test it. I'm able to add my NFTs to wallets but I don't see the image I provided when minted it.
What could be the reason? The image was a small .png and it's provided with a URI to the contract. All I see is a generic image. The Same NFT image is not showing on opensea as well.


texts: How to manually submit a block to the ethereum blockchain

texts:
I'm looking for an API call to submit a block manually to the network. For example a similar call in monero can be found below.

https://getmonero.org/resources/developer-guides/daemon-rpc.html#submitblock


texts:
I bought LGD token on BittRex and it won't show up in my wallet. It's not a business I particularly support, but thought I could make some quick profit on it.

I bought EMV and EOS tokens on EitherDelta, and everything worked smoothly there.  From what I can tell BittRex sent the correct data to the LGD smart contract.

Transfer from Bittrex to my Wallet:
https://etherscan.io/tx/0xd6522e36c8ea741149f86a173aefe9437e38b69ddc7a1d2f669a898d4b897640

My Wallet:
https://etherscan.io/address/0x006752624D45DbfeD473A273e96a0dAB97e5AD77


texts: How to add member NOT peer node to private ethereum network

texts:
I followed this parity-poa tutorial to build a private POA ethereum network in local. I want to add member node to this network . so i run parity client with below configuration

toml file:

[parity]
base_path = "3"

[network]
id = 8995
port = 30303
# Override the bootnodes from selected chain file.
bootnodes = ["enode://XXX@localhost:30300", "enode://XXXX@localhost:30301"
]
# Enable or disable new peers discovery.
discovery = false

[rpc]
port = 8543
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]
[websockets]
port = 8453
[ipc]
disable = true

I haven't passed chain = "genesis.json" in above file because i want it to work just like public ethereum network i.e when we start parity/geth the blocks get automatically download in local system.

From few links i learn that adding bootnodes will help to achieve this task .. but it does not work . the parity client is asking for genesis file.

So How can i add member node to this network in my local system without genesis file.


texts: Can I pass arguments to a .js script on Geth?

texts:
I'm starting to get a handle of Geth, especially the scripts, following this and this.

I have scripts that create contracts and call functions, but I don't know how to pass arguments to a script. Argv[] is not recognized, and most javascript doc I found is for html.

For now I call scripts with geth --testnet js script.js 2>>geth.log

Is there a way to pass arguments ?


texts: How to bootstrap AlethZero on Morden testnet?

texts:
I am trying to use the testnet using AlethZero. I use this command alethzero --morden as suggested in the wiki. It does not seem to connect to any peer and hence does not sync the blocks. I also tried to connect to the testnet using eth --morden command with no success.

If I use AlethZero in the main chain, it syncs perfectly.

AlethZero version is 1.1.1. Any suggestion why this might occur?


texts: What are some proposed ways of storing data in Ethereum?

texts: I keep reading that swarm or ipfs would be used for storage, but how would that work exactly? Would an ethereum contract store its data in these data blockchains? I thought ethereum smart contracts can't write to an external source but only read from it? Also what other storage blockchains can be used in this way?


texts: browser-solidity debug alternative for more automate process (rather than manually type in the function input everytime)

texts:
As specified in the title
I use truffle to test now, but often times it just returns the error msg "invalid opcode" instead of clearly stating what happened.
Any other testing/debugging tips will also be much appreciated ><
Thanks a lot:)


texts: Why are there pending TXs with high gas prices?

texts: Rinkeby has pending transactions, some of which have gas prices of 100+ gwei and have been pending for over half an hour. Why is that? Are sending too little gas?


texts: Mist Testnet error "it seems this transaction will fail"

texts:
I am very new to Ethereum, and just working through some early tutorials using the testnet. My version is up to date; the blockchain is also up to date; and I have only one account in the keystore, the main account.
As I try to deploy a simple contract (or any contract for that matter - including the examples on ethereum.org), the code compiles correctly:

When I go ahead and hit deploy contract, the confirmation popup gives me this error:  "it seems this transaction will fail. If you submit it, it may consume all the gas you send"

It gives me this error irrespective of whether I send 1 eth or 20eth, and regardless of the fee amount I choose.
If I press on regardless, the contract appears to be created on the mist wallet UI, but sits with another error message under the transaction saying basically that no data reached the blockchain: " No data is deployed on the contract address!".
My apologies if this is basic. I have scanned previous questions and they either didn't quite cover this scenario, or had a fix that didn't work for me (like reselecting the FROM account just before deploying)
Many thanks in advance.


texts: How Best to Iterate Through a Web3.js Array?

texts:
I have made a simple contract function where a user can write a message and then submit it to the array in the contract Messages:

  string[] public Messages;

  function WriteMessage (string MessageInput) public {

    Messages.push(MessageInput);

}

On the frontend, I want to print in order all of the messages contained in the array. With one message it is very simple, you just write the call via Web3.js like this:

   Contract.WriteMessage(0, function(error, result) {
    if (!error) {
        $("#messagediv1").html("" + result);
    } else
        console.error(error);
});

It's a bit confusing the syntax, but the 0 represents the first entry into the Messages array. In the div with the ID messagediv1, you will see the very first message printed. If you omit the entry number it will error. You cannot just download the whole array and then write something like this:

   Contract.WriteMessage(function(error, result) {
    if (!error) {
        $("#messagediv1").html("" + result[0]);
        $("#messagediv2").html("" + result[1]);
        $("#messagediv3").html("" + result[2]);
        $("#messagediv4").html("" + result[3]);
    } else
        console.error(error);
});

Is there a way to do a for loop on the this dynamic array until a result returns as invalid/null/0?

Note: Writing a getter function for the array does work, but you must transact each time to retrieve everything in the array.


texts: What is ethereum bytecode link references is?

texts:
I compiled contract from there and found some strange things in bytecode:

<some_bytecode>...__CrowdsaleTokenExt:SafeMathLibExt______6366098d4f9091836000604051...<some-bytecode>

As I understand right, it is link references, that created for linking code with some deployed libraries.

Can you describe to me, for what reason we have it in compiled bytecode and why we don't have it on deployed bytecode?


texts: Transaction not performed, morden.ether.camp has different transactions than me (Morden)


texts: What does it mean by smart contract state.Where they get stored?

texts: I am new to ethereum. We understand that whenever some new transaction made Contract state changes. What does it mean exactly by state change. Where they get stored.Are they called distributed ledger. Except transaction are there any events which cause state changes.


texts: Quorum Account existence on node requirement of Private Transaction

texts:
I am trying out private transaction using Quorum.
Two quorum nodes N1 and N2 configured to participate in the private transaction.

I deployed a contract which is private for N1 and N2.

I issue transaction (invoke contract method) using A1 account (address) and use public key of N2 node.  Note that account A1 is not present on either of the nodes N1/N2.

I connect to Node N1 to issue the transaction.

I receive following error when the transaction is sent to the N1 node.

Error processing transaction request: account is locked

I do not get such an error in following scenario:

Deploy public contract
Issue transaction (invoke contract method) using A1 account (address) by connecting to node N1

Im using web3j-quorum API to connect to the quorum nodes.

Please help to have the issue resolved.

Thanks in advance.

Regards,
S


texts: how to connect "Kovan" or "Rinkeby" from geth

texts:
As far as I know, the default test network is "Ropsten" and you can connect to ropsten with following command.Since it is default, when you connect to testnet its "Ropsten".

geth --testnet

I would like to connect "Kovan" / "Rinkeby" test networks. What are the required parameters connecting to these test networks?


texts: How to access external knowledge / data in a smart contract

texts: let’s say a contract wants to execute on knowledge contained outside the blockchain  (e.g. whats the price of gold, what was the avg windspeed in NYC, how many people moved to portland in the last week) — what are common ways a contract might acquire this sort of information?


texts: How will dApps built on ETH deal with the requirements of GDPR?

texts:
GDPR expects it's citizens to have the 'right to be forgotten'. A company failing to fulfill this obligation is expected to pay a hefty fine. How will decentralized autonomous communities who store immutable data on the blockchain about its users deal with such a legal obligation?

Let's take the case of an alternative that ETH developers build for Facebook. They ought to store the users' names and other identifiable information on the blockchain, correct? What measures do they have to take to be compliant with the law? Should the founders remain anonymous so that nobody is held liable? Please talk about how social DACs can grow in such conditions.


texts: How to interact with my ropsten smart contract

texts:
I've looked for hours online for how to interact with contracts but I've yet to find an efficient way to do so. My contract is deployed at 0x09B81faA7fB51E5Af79b0241243e58297aC84158 on the ropsten network. I just want to know how to call my method

    function getChallengeNumber() public view returns (bytes32) {
        return challengeNumber;
    }

and

function mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) {

Obviously I can interact with ropsten but I want to set up a script that can find solutions for the PoW method "mint" and then push solution when it find them.

I've found a bunch of fragmented explanations but nothing that comes close to comprehensive. I can interact with it via remix. I figured out how to call methods that do not alter the state of the network with python but I haven't yet to find any way to interact with my contract in a sustainable way.

Any guidance would be appreciated.

Building off @goodvibrations answer. Because I only have a JSON file I'm working with, I've changed the update method somewhat.

async function deploy(web3, account, gasPrice, contractName, contractArgs) {
    const json_file  = fs.readFileSync(ARTIFACTS_DIR + contractName + ".json", {encoding: "utf8"});
    const json_obj = JSON.parse(json_file);
    const abi = json_obj['abi'];
    const bin = json_obj['bytecode'];
    const contract = new web3.eth.Contract(JSON.parse(abi));
    const options = {data: "0x" + bin}  //arguments: contractArgs}; <-- I got rid of this because my constructor doesn't accept any arguments
    const transaction = contract.deploy(options);
    const receipt = await send(web3, account, gasPrice, transaction);
    return new web3.eth.Contract(JSON.parse(abi), receipt.contractAddress);
}

But now I get a new error.

(node:5672) UnhandledPromiseRejectionWarning: Error: Provider not set or invalid
    at Object.InvalidProvider (~/node_modules/web3/node_modules/web3-core-helpers/src/errors.js:38:16)
    at RequestManager.send (~/node_modules/web3/node_modules/web3-core-requestmanager/src/index.js:128:32)
    at sendRequest (~/node_modules/web3/node_modules/web3-core-method/src/index.js:705:42)
    at Eth.send [as getGasPrice] (/home/lnielsen/node_modules/web3/node_modules/web3-core-method/src/index.js:726:13)

Am I misunderstanding the implementation?


texts: Can't connect to Infura testnet or mainnet

texts:
From the Web3 JS API I've written:

var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/MYTOKEN"));
console.log(web3.currentProvider);

which produces:

HttpProvider {
  host: 'https://ropsten.infura.io/MYTOKEN',
  timeout: 0,
  connected: false }

So far I've tried removing the token and just using https://ropsten.infura.io, and I've also tried the Infura mainnet and Kovan, neither of which worked.

I suspect this is unrelated to Web3/Infura and maybe related to firewall settings or something? Any help is appreciated.


texts:
I am using this command to start geth. Geth starts but I cannot connect to it via Web3. I get a couldn't connect to localhost. Has anyone any idea why this would happen?

  nohup geth --datadir node6/ --syncmode 'full' --port 30316 --rpc
  --rpcaddr 'localhost' --rpcport 8506  --rpccorsdomain "*" --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes
  'enode://739f2c03c2378b1335bbdff6f8fff481339224b9bb6dccf2799a8075c450871fa40057c42c10de0703e2637514537b1a7d129177f452e9d719e7832cde55fbd7@10.154.0.2:30310'
  --networkid 1520 --gasprice '1' -unlock 'f39995b718ae7a0075557f9781425b92fd8b28a6' --password
  node6/password.txt --nat "any" --mine &