texts: Emitting Transfer Event even when there is no actual transfer

texts:
I am new to smart contracts and trying to understand it so that i can detect Ether transfers done to my user via Smart Contract.

I know I can find the event emitted from topics[]. But for those contracts where i don't have there code, but i can deduce from the topic[] that a Transfer or AssetWithdrawal , etc, event was emitted, how can i be sure that when Transfer event was emitted actual transfer of asset took place(since i don't have that contract's code)

Thanks for any help.


texts: Rlp vs rlpx: the specified difference between rlp and rlpx?

texts: Rlp vs rlpx - the specified difference between rlp and rlpx?


texts: Is it allowed to used modifiers in mandatory functions of any token standards that I wish to implement?

texts: As for example, Is it okay to add modifiers in transfer function in ERC20


texts: Connect GETH to miner's node. Speed up transactions

texts:
Sometimes transactions from my node are delayed, how to configure Geth so node can connect directly to the miners' nodes? For example asia.sparkpool.com:3333
Or what other options? Thank you in advance
(Gas price & limit settings are ok)


texts: How to ensure unique value in mapping (like unique nickname for address)?

texts:
I am creating smart contract where I want each account to have unique nick/name attached to address. Here is example code:

mapping (address => string) members;
function isMember() constant returns bool() {
    return members[msg.sender] != "";
}

function register(string _name) {
    if (members[msg.sender] != "") {
        throw("Already registered");
    }

    /* now check if name is already taken...
    foreach (name : members) {
        if (name == _name) {
            throw();
        }
    }
    */
}

Is it possible to utilize mapping to ensure that each nick/name entered into members is unique? Or my best course of action would be to create another property that just holds list of nicks already in use? What is better approach from gas usage standpoint (considering iterating huge lists should incur higher costs)?


texts: How to create a fork from Ethereum (with name e.g. Methereum)

texts:
How I can create my own fork of Ethereum?
And people can come to my website(Methereum) and create their tokens.
If there is a tutorial on any website please share that link
Thanks


texts: Is there an API to Download source code of verified smart contracts from etherscan?

texts:
There is same question on stackexchange but the answer to that question does not include the new api on etherscan which, given an address as input, allows you to download source code of that verified smart contract.

But I want to download source code of a random verified contracts without knowing its address.

My ultimate goal is to make folders based on versions of contracts and download 50-100 for each version if available enough. I also want to know how many verified smart contracts are there on etherscan so that i can estimate time of download as only last 500 verified contracts are visible on etherscan.

edit: If I know addresses of verified smart contract then the api will work since i can loop over all addresses. Is there any way to get a list of addresses of all verified smart contracts?


texts:
Is that everything is ok with this result?

When will I receive my first coin? And why can't I see my balance, it shows (it started about 8 hours from first) When I type eth.getBalance(eth.coinbase) in the geth attach it prints ←[31m0←[0m

Is it ok? What does that mean?

in geth --rpc:

I0618 21:15:35.492554 core/blockchain.go:964] imported 1 block(s) (0 queued 0 ignored) including 21 txs in 414.5035ms. #1727499 [53777429 / 53777429]
I0618 21:15:47.059936 core/blockchain.go:964] imported 1 block(s) (0 queued 0 ignored) including 4 txs in 775.0133ms. #1727500 [3fcc2930 / 3fcc2930]
I0618 22:14:07.945653 miner/miner.go:119] Starting mining operation (CPU=0 TOT=1)
I0618 22:14:08.413245 miner/worker.go:555] commit new work on block 1727501 with 7 txs & 0 uncles. Took 467.592ms

and in ethminer:

miner 22:45:02|main Mining on PoWhash #e18a69e1ΓÇª : 26317606 H/s = 13369344 hashes / 0.508 s
miner 22:45:03|main Mining on PoWhash #e18a69e1ΓÇª : 26315613 H/s = 13631488 hashes / 0.518 s
miner 22:45:03|main Mining on PoWhash #e18a69e1ΓÇª : 25959891 H/s = 13369344 hashes / 0.515 s
miner 22:45:04|main Mining on PoWhash #e18a69e1ΓÇª : 26315613 H/s = 13631488 hashes / 0.518 s
miner 22:45:04|main Mining on PoWhash #e18a69e1ΓÇª : 26473948 H/s = 13369344 hashes / 0.505 s
miner 22:45:05|main Mining on PoWhash #e18a69e1ΓÇª : 25809544 H/s = 13369344 hashes / 0.518 s
miner 22:45:05|main Mining on PoWhash #e18a69e1ΓÇª : 26264909 H/s = 13631488 hashes / 0.519 s
miner 22:45:06|main Mining on PoWhash #e18a69e1ΓÇª : 26526476 H/s = 13369344 hashes / 0.504 s
miner 22:45:06|main Mining on PoWhash #e18a69e1ΓÇª : 25809544 H/s = 13369344 hashes / 0.518 s
miner 22:45:07|main Mining on PoWhash #e18a69e1ΓÇª : 25959891 H/s = 13369344 hashes / 0.515 s
miner 22:45:08|main Mining on PoWhash #e18a69e1ΓÇª : 26315613 H/s = 13631488 hashes / 0.518 s
miner 22:45:08|main Mining on PoWhash #e18a69e1ΓÇª : 26417612 H/s = 13631488 hashes / 0.516 s
miner 22:45:09|main Mining on PoWhash #e18a69e1ΓÇª : 26058051 H/s = 13107200 hashes / 0.503 s
miner 22:45:09|main Mining on PoWhash #e18a69e1ΓÇª : 25909581 H/s = 13369344 hashes / 0.516 s
miner 22:45:10|main Mining on PoWhash #e18a69e1ΓÇª : 26214400 H/s = 13631488 hashes / 0.52 s
miner 22:45:11|main Mining on PoWhash #e18a69e1ΓÇª : 26178538 H/s = 38273024 hashes / 1.462 s
miner 22:47:09|main Got work package:
miner 22:47:09|main Header-hash: 006d90f968a348a4a960ccc68db599332139ba2049a7980c2c21ec23d1317d2d
miner 22:47:09|main Seedhash: a1cf12393876a9e30788eb582aeea764ad71d6b2419f2c6b35706ec60b49c85c
miner 22:47:09|main Target: 000000000006884aa8f81f060331f21097467838b975026daf831976e216f89c
i 22:47:09|gpuminer0 workLoop 1 #a1cf1239ΓÇª #a1cf1239ΓÇª
miner 22:47:09|main Mining on PoWhash #006d90f9ΓÇª : 25165824


texts: Is it Possible To Avoid Yield Farms That Use Leverage?

texts:
Are there any Yield Farms (YFs) that do not use leverage or is leverage worked into virtually every YF strategy?
I'm concerned with the use of borrowing behind the scenes of Yield Farms (YFs) in order to achieve astronomical gains, known as leverage. Although, this may work well as a short-term investment, in the long-term, if the prices decline for a sustained period of time there seems to be a high risk of liquidation of the principal comprising the collateral for the YF.
In addition to leverage, other strategies implemented in YFs are lending and crop rotation.

Lend

Earn APY from collateralized loans

Crop rotation

Switch between different protocols
Liquidity pools and mining
Governance staking

Represent voting participation in a liquidity pool


texts: I am trying to execute a simple contract on Solidity Remix. But the page have different options compared to the tutorial videos?

texts:
I am new to the blockchain world. So I was trying to build a simple contract using ERC20 on solidity remix.
But the tutorials I have seen have different options when they run the same program, I am attaching you the images of both tutorials and my page.

Thanks


texts: Does Gas Limit have any bearing on transaction/mining time?

texts:
Gas Price has an obvious impact on how long it takes for the transaction to be mined, but does the Gas Limit have any bearing on transaction time?

Based on my understanding it shouldn't, as Gas Limit just determines how much you're willing to pay to complete the transaction, but would miners prioritize transactions with a higher limit if the Gas Price of both transactions were the same?

If that is in fact the case, would it not be generally faster to set an absurdly high Gas Limit for all of your transactions if you were wanting the fastest transaction, so long as you are actually willing to pay the entire Gas Limit if a transaction were to consume it?

This was posted here after being asked in the MyEtherWallet Support Slack (conversation below):

limitless76 [6:09 PM]
Does changing the Gas Limit have any bearing at all on the speed of the transaction? I know increasing the Gas Price will speed it up, but my understanding is the Gas Limit simply determines how much Gas you're willing to pay to process the transaction, so it should not affect speed, is that right?

tayvano [6:10 PM]
@limitless76 not really. Gas price is the primary. Miners will go after bigger fees which is limit * price

tayvano [6:10]
So technically limit does play a role

tayvano [6:11]
However excess gas limit is returned to you so sending a standard tx with a higher limit isn't going to actually net the miners more

tayvano [6:11]
That would be an excellent question for Ethereum stack exchange tho.  I really recommend you ask there as I would love to have someone pull all the details


texts: What command to run for Live.ether.camp project?

texts:
and am trying to run the example-project in live.ether.com.
What is the command for me to run the project?


texts: How to clear Ethereum chain data on windows?

texts: I'm using the ethereum wallet, which uses geth. I keep getting the time out of sync error message. I know i need to clear my bad chaindata. How do i do this?


texts:
I am trying to convert the assembly code into Solidity given at the link:
What is a function Selector
The code is trying to invoke the function func(...) of  Contract1 given below:

contract Contract1 {
    function func(uint256 x, uint8 y) public returns (uint32, uint32) {...}
}
contract Contract2{
/* .......
 */
        assembly
        {
                let success := call(
                    gas,           // pass the remaining gas to the function
                    dest,          // the address of the contract1 instance
                    0,             // pass 0 wei to the function
                    add(data, 32), // the actual data starts after the length of 'data'
                    mload(data),   // the length of 'data' appears at the first 32 bytes
                    ret,           // the address of the output
                    8              // the size of the output
                )
                if iszero(success) {
                    revert(0, 0)
                }
        }
/*....*/
}

Is the following statement correct?

(success, errCode, arg1, arg2) =dest.func.value()(  uint256(789), uint8(123));

arg1 & arg2 would hold the two values returned by func() of Contract1. Somebody please guide me.

Zulfi.


texts: How to get external transaction using python

texts:
I am trying to test their code  in order to detect the Ponzi smart contracts. When I run their code following error occurred to get the external transactions. Here is their code ;
for addr in ponzi:
    if (verbose): print("Retrieving transactions of contract ",addr,"... ",end=" ")
    sys.stdout.flush()
    print("Address: ", addr)
    api = Account(address=addr, api_key=key)
    print("api: ", api)
    text = api.get_ext_transactions()
    tint = api.get_int_transactions()

The value of addr = "0xf45717552f12ef7cb65e95476f217ea008167ae3"
The value api = "<etherscan.accounts.Account object at 0x00000075B4C67388>"
but when execution reaches at api.get_ext_transactions() it gives following error

Traceback (most recent call last):   File "ponzi-stats.py", line 133,
in
text = api.get_ext_transactions() AttributeError: 'Account' object has no attribute 'get_ext_transactions'

And I think this error will also be appeared in next to get internal transactions.
Now my question is how to get external/internal transactions using web2.py. What I have to import, install, etc...
EDIT: In their code they have used from etherscan.accounts import Account. That's why I have installed py-etherscan-api by using this command python -m pip install py-etherscan-api . I am not sure this is right or wrong ...


texts: How to get balance of an address using web3js

texts:
Here is a very simple code that i am using :-
    let web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/XXXXX"));
    var balance;
    web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(bal => balance = bal);
    document.write(balance + "
");

And it gives me the output undefined. So i decided to wait for 5 seconds before printing the output.
    function sleep(miliseconds) {
       var currentTime = new Date().getTime();

       while (currentTime + miliseconds >= new Date().getTime()) {
       }
    }
    let web3 = new Web3(new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/XXXXX"));
    var balance;
    web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(bal => balance = bal);
    sleep(5000);
    document.write(balance + "
");

This waits for 5 seconds and the output is still undefined. What is the proper way to store the result of promise in an external variable?
I don't want to print the result inside the .then(bal => document.write(bal));


texts: Which one of methods should I choose for deployment of smart contract geth or a wallet if I have to build API for smart contracts in nodejs?

texts:
I'm having trouble to understand which method would be better for deployment geth or a wallet if I'm building API in nodejs using web3.

Where exactly is the contract stored??

Is the contract independent of wallet when deployed from wallet??

In both cases will I need the private key of smart contract in web3 or the account which launched the smart contract to invoke its functionality??

If I close the geth node the smart contract should still run smoothly right??


texts: Smart contract function call from many accounts

texts: Lets say that I have a smart contract C witch has a function setf(uint256).  Also let's assume that there are many users(with different accounts) that want to call that function with argument 5 for example. As i understand each of them will make a logically same transaction to the same contract function with the same argument and each of them will pay the same gas. Is there any way to reject the  rest of the pending transactions when the first one of them is mined and avoid the gas? If every user use the same account I could use the same nonce in all the transactions and only one would be mined. In the case of different accounts is there any way?


texts:
having a problem with calling a method of my deployed contract in the main Ethereum network.

I have a 'view' function which returns user's refund balance, everything worked fine in my local blockchain (Ganache), but doesn't work in the main network :(

So here I call that method from web3:

this.myContract.methods.checkFunds().call().then((refunds) => {
      return refunds;
});

this is my contract function and here I call another contract function:

mapping(address => uint256) private funds;

function checkFunds() external view returns(uint256) {
    return contract2.checkFunds(msg.sender);
}

here is that contract2:

function checkFunds(address _owner) public view returns(uint256) {
    return funds[_owner];
}

if user doesn't have funds then it should return 0 and it's uint256, then it should be ok, but I get such an error:

Uncaught (in promise) Error: Returned values aren't valid, did it run Out of Gas?
at ABICoder.decodeParameters (app.js:37038)
at Contract._decodeMethodReturn (app.js:36366)
at Method.outputFormatter (app.js:36719)
at Method.formatOutput (app.js:9201)
at sendTxCallback (app.js:9511)
at app.js:96628
at inpage.js:1
at inpage.js:1
at o (inpage.js:1)
at inpage.js:1

and I have the latest version of web3 btw:"react-web3": "1.2.0",

Do view functions cost gas ? That's strange, because I call another method of that contract to read items and it doesn't cost anything.

thank you!


texts:
I created an account, it's
0x1ed6e4623c84d86a170b9a500a2e6ea1d29cd292
and sent some ETH to it, but when I try to check my balance using the geth docs, which mention eth.coinbase, it says:

Error: not supported
at web3.js:3104:20
at web3.js:6191:15
at get (web3.js:6091:38)
at <unknown>

What's going on? I'm getting a sinking feeling in my stomach...


texts: How can I disconnect a Metamask wallet from Uniswap?

texts: As soon as I go in Uniswap, it already loads the Metamask wallet that was used previously... but I do not want to use that Metamask wallet, I want to use a different Metamask wallet. How my I do this, please?


texts: Invoking a smart contract from a front end

texts: I am building a Dapp that will need to invoke a smart contract and then send funds to another address. Do, I need to be running my own node to accomplish sending a request to the Ethereum network? Is there anyway to broadcast my transaction directly to the broader network?


texts: How to calculate token buy and sell prices?

texts:
I have a ERC20 token

    string public name = "Token ZIZ";
    string public symbol = "ZIZ";
    uint8 public decimals = 18;
    uint256 public totalSupply = 1000000 * 10 ** uint256(decimals);

    /// the price of tokenBuy
    uint256 public TokenPerETHBuy = 10000;  /// 1 TOKEN = 0.001 ETH

    /// the price of tokenSell
    uint256 public TokenPerETHSell = 10000;

    /**
    *  function for Buy Token
    */

    function buy() payable public returns (uint amount){
          require(msg.value > 0);

          amount = ((msg.value.mul(TokenPerETHBuy))).div(1 ether);

          balanceOf[this] -= amount;                        // adds the amount to owner's
          balanceOf[msg.sender] += amount;
          emit BuyToken(msg.sender,msg.value,amount);
          return amount;
    }

    /**
    *  function for Sell Token
    */

    function sell(uint amount) public returns (uint revenue){

        require(balanceOf[msg.sender] >= amount);         // checks if the sender has enough to sell
        balanceOf[this] += amount;                        // adds the amount to owner's balance
        balanceOf[msg.sender] -= amount;                  // subtracts the amount from seller's balance

        revenue = (amount).div(TokenPerETHSell) ;

        msg.sender.transfer(revenue);                     // sends ether to the seller: it's important to do this last to prevent recursion attacks
        emit Transfer(msg.sender, this, amount);               // executes an event reflecting on the change
        return revenue;                                   // ends function and returns

    }

  How can I achive my result ? 1 TOKEN = 0.001 ETH.


texts: Is Etherum or Hyperledger be helpful for Money Lending business without Miners reward without using Cryptocurrency?

texts:
If I have to implement something like Money Lending Business on a Private - Enterprise level in India provided the facts that -

I don't want to reward the miners as it's a private network.
I want to execute smart contracts in INR. currency (Smart contract use case - A is lending some money to B on a agreed interest rate, expects that back after 6 months of span.)

Is Ethereum platform be a help for me? Or else any other options too exist? Any suggestions about how can we do that ?


texts: Unlocking accounts and making transactions in web3.js

texts:
This question is related to this one and this one. It also has a partial answer here and here.

In the third link the account is being unlocked for a period of time using web3.js:

web3.personal.unlockAccount("0x..", "<passs>", 1000);

The unlock period parameter is optional.

How is it possible to check if accounts are locked (prior to making transactions)?

Are there any functionality consequences of unlocking an already unlocked account?


texts: Deploying on contract on main net - Error: insufficient funds for gas * price + value

texts:
Running

geth v 1.7.3

truffle 4.0.5

truffle-config.js

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    live: {
      host: "localhost",
      port: 8545,
      network_id: "1",
      from: "0x2cd02c6bfb7d36be9c98be275c5c30aa8d3848b8",
      gas:5000000
    }
   }
};

1_initial_migration.js

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations, {gas:7987299});
};

2_deploy_contracts.js

var DevContest = artifacts.require("./DevContest.sol");

module.exports = function(deployer) {

  deployer.deploy(DevContest, "0xf7B098298f7C69Fc14610bf71d5e02c60792894C", 4942901, 4977461, {gas:7987299});

};

The error I'm getting is in the migrations file it seems like -

mokn$ truffle migrate --network live --reset
Using network 'live'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41483:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330353:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176198:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326008:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329052:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176427:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176717:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176872:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176832:24)
    at IncomingMessage.emit (events.js:165:20)

I checked how much the contract should cost in Remix - no more than 3.5 million. Anyone know what's going on here? Thank you

UPDATE - Seems to have deployed the migrations but it's not completing the second contract. Is it possible I don't have enough eth in the account? The migrations contract is not very large and cost 300k gas.

Now I'm getting this issue -

mokn$ truffle migrate --network live --reset
Using network 'live'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x92cc08d87aac4ea464d2b1bfe89a747fbb52e4cf8bdade1c5d992705cffcad3c
  Migrations: 0x12613c93ae25f51d956cf9fcd80edc05babdc2fc
Saving successful migration to network...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41483:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330353:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176198:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326008:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329052:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176427:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176717:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176872:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176832:24)
    at IncomingMessage.emit (events.js:165:20)


texts: JSON RPC Best Practices for Sending Ethereum

texts:
I am planning on setting up an Ethereum wallet in my website. Doing so by interacting with an Ethereum node over JSON RPC.

I want it to act almost 100% similar to how a cryptocurrency exchange (Bittrex, Binance, etc) wallet acts, with the ability to send and receive funds from my website.

If possible, I would like to spin up a node using a service like quiknode.io to do this if possible, rather than maintaining my own. And then interact with it via my website.

I am finding it very hard to find any guides on this or any literature on what best practices are in doing something like this.

Anyone have any insight?


texts:
I was trying to set-up ethereum private test-net. I was able to create a custom Genesis block and create an account. Now I modified my customGenesis.json to preallocate ethers to my account, I was hit by:

  Fatal: failed to write genesis block: wrong genesis block in database
  (have 6650a0ac6c5e8054, new 423e5a9e61bce67e)

Steps to reproduce:

setup Genesis state:

  geth --identity "Prashant" --fast --cache=1024 --rpc  --rpcport "8013"
  --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" init customGenesis.json console

Start geth without init to create account:

  geth --identity "Prashant" --fast --cache=1024 --rpc  --rpcport "8013"
  --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" -ipcpath "/home/prsingh/.ethereum/geth.ipc" console

Create an account in geth console

  personal.newAccount("my_password");

Modify customeGenesis.json to preallocate ethers

"alloc":{
     "0xe43ee2af5a41385ff951f0c3fe2f5156287757a6":
     {"balance": "20000000000000000000" }
 }

Again run geth with init

  geth --identity "Prashant" --fast --cache=1024 --rpc  --rpcport "8013"
  --rpccorsdomain "*" --datadir "myPrivateNetwork2" --port "30312" --rpcapi "db,eth,net,web3,admin,debug,miner,personal,web3" --networkid 1902 --nat "any" init customGenesis.json console

At step 5, I am getting the wrong genesis block in database error. I am quite sure this is because I have already run the geth with init param so when I am trying to run it the second time, geth gives error because these in already a genesis block.

But then the question is:
How will I pre-allocate ethers to my account?

Here is my customGenesis.json after adding funds to my account.

{
    "nonce": "0x0000000000000042",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x00",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "alloc":{
    "0xe43ee2af5a41385ff951f0c3fe2f5156287757a6":
    {"balance": "20000000000000000000" }
    }
}


texts: How to send ether to contract's address?

texts:
I have a problem with sending ether to my contract address via metamask. I found that the function has to be with 'payable' modifier, but it doesn't help. I send transaction, spend ethers from my account, but the contract's address still has 0 value. For example the contract looks like:

contract Mycontract
{
  function Mycontract() payable{}
}


texts: Truffle / Solidity - Can I call mulitple variables, simultaneously?

texts:
I am currently using Truffle framework to call Etherum block chain (testing with Ganache).

When I call public variables on a contract instance...is it possible to return multiple variables in one call?

Example:

Looking to get started and ended public variables.

My current approach:

const started = await instance.started.call({ from: account })
const ended = await instance.ended.call({ from: account })

Can I get these 2 variables in one call?

If I am mistaken on the architecture, please let me know.

Thank you!


texts: Gas cost for contract transaction called form external

texts:
If I call my contract and ask it to send x amount of ether to another account y, I know i have to pay a transaction cost.

Will the contract also have to pay any amount while sending the ether to the account y?


texts:
var test = await web3.eth.getBlockNumber();

I copied this code from the docs but when I call it I get this error:

TypeError: e is not a function

Anyone know what might be causing this?

I'm able to do

userAccountAddress = await web3.eth.accounts[0];

no problem.

Thanks


texts: Can a contract own an ENS name? That would make it possibly to lock names for a period of time, making them immutable, so that the name can be trusted to continue to point to a certain contract.


texts: Would it be possible to combine gtx 1060 and gtx 970 in a single rig?

texts:
I have a two gtx1060 6g working, i have seen that the gtx790 is cheaper and the performence is quite similare. i am thinking of adding 4 gtx970 in the same rig.

would it be possible??


texts: How to deploy a contract on Infura with Web3.py v4

texts:
I am trying to deploy a contract to a test network like Ropsten.

I am running through Infura using the HTTPProvider. I need to be able to sign the deployment of the contract locally, but can not figure out how to do this with the current API.

Any pointers?


texts: Compiling contract in web3: "Method eth_compileSolidity not supported"

texts:
I have web3 and truffle running. I am able to execute the following commands:

> node
> Web3 = require('web3')
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
> web3.eth.accounts
> code = fs.readFileSync('contracts/Voting.sol').toString()

Then I want to compile the Voting.sol contract with the following command:

> contract =  web3.eth.compile.solidity(code)

This fails with the following error:

  Error: Error: Method eth_compileSolidity not supported.
      at GethApiDouble.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85608:16)
      at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18)
      at VmSubprovider.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113829:12)
      at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18)
      at GethDefaults.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85935:12)
      at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18)
      at FilterSubprovider.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113388:7)
      at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18)
      at DelayedBlockFilter.handleRequest (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:85448:3)
      at next (C:\Users\abc\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\build\cli.node.js:113129:18)
      at Object.InvalidResponse (C:\Users\abc\truffletest\node_modules\web3\lib\web3\errors.js:38:16)
      at RequestManager.send (C:\Users\abc\truffletest\node_modules\web3\lib\web3\requestmanager.js:61:22)
      at Object.send [as solidity] (C:\Users\abc\truffletest\node_modules\web3\lib\web3\method.js:145:58)
      at repl:1:30
      at sigintHandlersWrap (vm.js:22:35)
      at sigintHandlersWrap (vm.js:73:12)
      at ContextifyScript.Script.runInThisContext (vm.js:21:12)
      at REPLServer.defaultEval (repl.js:340:29)
      at bound (domain.js:280:14)
      at REPLServer.runBound [as eval] (domain.js:293:12)

I am going off this tutorial https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-1-40d2d0d807c2


texts: Solidity: Smart Contract, always get wrong result

texts:
I'm writing a token locker contract, code as following:

pragma solidity ^0.4.24;

import "./SafeMath.sol";
import "./ERC20.sol";

contract TokenLocker {
    using SafeMath for uint256;

    address public creator;
    address public owner;

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    constructor(address _creator, address _owner) public payable {
        creator = _creator;
        owner = _owner;
    }

    function() payable public {
        emit Received(msg.sender, msg.value);
    }

    function unlock() public returns(bool) {
        uint256 balance = address(this).balance;
        require(balance > 0, "No token available !");

        owner.transfer(balance);

        emit Unlock(owner, balance);

        return true;
    }

    function getBalance() public view returns(uint256) {
        return address(this).balance;
    }

    event Received(address from, uint256 amount);
    event Unlock(address to, uint256 amount);
}

contract TokenLockerFactory {
    address public creator;
    mapping(address => address) ownerLockers; // map owner-locker relation
    address[] private lockerList;

    function createLocker(address _owner, uint256 amount) public payable
            returns(address locker) {
        locker = ownerLockers[_owner];

        if(locker == address(0)) {
            // Create new locker.
            locker = (new TokenLocker).value(amount)(msg.sender, _owner);
            ownerLockers[_owner] = locker;
            lockerList.push(locker);

            // Emit event.
            emit Created(locker, msg.sender, _owner);
        }
    }

    function getLocker(address _owner) public view returns(address) {
        return ownerLockers[_owner];
    }

    function getLockersNumber() public view returns(uint256) {
        return lockerList.length;
    }
}

When call createLocker, I can get a correct locker address return, but when I then call getLocker with the related _owner address, I always get a 00000000000000000000 return, even call getLockersNumber() to check lockerList but always get a 0 return.

What is the problem? anybody can help? thanks in advance.


texts: How to check if a bytes32 represents an empty string?

texts:
Why does the require not throw here when I am passing an empty string for the _name param?

function MyContract(bytes32 _name) public {
        require(_name.length > 0);
        name = _name;
    }


texts:
I am running this sample code but I got an error because my fake account has 0ETH, how I can charge my account ?

try {

        // Unlimited allowances to 0x proxy contract for maker and taker
        const setMakerAllowTxHash = await zeroEx.token.setUnlimitedProxyAllowanceAsync(ZRX_ADDRESS,  makerAddress);
        await zeroEx.awaitTransactionMinedAsync(setMakerAllowTxHash);
        console.log('Maker allowance mined...');

    }
    catch(err) {
        console.log(err);
    }

  Error: sender doesn't have enough funds to send tx. The upfront cost
  is: 47275 and the senders account only has: 0


texts:
I need to have a random bit generated with the user input. so returns a 0 or 1.
The user input is also always a 0 OR a 1, this is random.
Is there anyway i can create a fully random number in the smart contract using the user input?
function play(uint8 input) external payable returns(uint8){
   //generate random number
   return(randomNumber)
}


texts: Etherscan API Get Balance - Decimals Not Showing In Response

texts:
Expected
Use the Etherscan API to make a GET request for an ETH address' balance in order to receive a response providing the Ether token quantity representing all decimal places.
Observed
The response provides the Ether token quantity without representing any decimal places.
Request: Etherscan Get Ether Balance for a single Address
http://api.etherscan.io/api?module=account&action=balance&address=0x8a27D05e97A156E93D42a6d3afB5c2154ebb9cB5&tag=latest&apikey={YOUR_API_KEY_HERE}
Note: I chose a random ETH address above. This is not my ETH address.
Response
{
    "status": "1",
    "message": "OK",
    "result": "86354095000000000"
}

Balance From Etherscan UX
The balance from the Etherscan UX indicates that decimal places are included in the Ether balance. However, the API response does not provide any information regarding decimal formatting.
0.086354095 Ether


texts: Ethereum proof of stake - Is transaction finality/settlement finality finally possible / within reach?

texts: With Ethereum proof of stake, is transaction finality/settlement finality finally possible / within reach?


texts: How to call contract functions using web3?

texts:
I have deployed my contract in private blockchain, now I am calling functions using Nodejs and web3.
Here, I want to transfer tokens for which I need to unlock my account from which I am transferring the tokens and then I want to check the balance of the account to which the tokens were transfered.
Here, is the code:

var Web3 = require('web3');
var web3 = new Web3(new
Web3.providers.HttpProvider("http://localhost:8545"));
var Personal = require('web3-eth-personal')
var personal = new Personal(Personal.givenProvider)

var ABI = {contract abi}
web3.eth.personal.unlockAccount("0xcc8d743....97278fe497ee90...", "password",
60).then(
contract.methods.transfer('0x43a91c052B913299Dd4F47C91bB7d982D8A8632e',
2).send({from:'0xCc8d743eB486bF38ED1197278Fe497eE90...', gas:210000})
.on("result",
contract.methods.balanceOf('0x43a91c052B913299Dd4F47C91bB7d982D8A8632e')
.call((error, result)=>console.log(result))).on("error", function(error)
{console.log(error);}))

But I am getting the balance of the account first which should be called after transfer function and for the transfer function I am getting the error saying 'need authentication'.

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


texts: Is there a simple way to make sense of Ethereum tx given ABI?

texts:
It seems that ABI is used by web3.js to only make sense of the function calls and storage values, are there any simple means to make sense of Ethereum tx given ABI?

For example, given ABI, is there an easy way, perhaps via web3.js, to make sense of this tx?


texts: Constructor should be payable error on adding money

texts:
pragma solidity ^0.4.17;

contract supplyChain {
    address public state;
    uint public unitCost = 10;
    uint public totalAmount = 0;

    function supplyChain() payable public{
        state = msg.sender;
    }

    function add_money() public payable {
        require(msg.value == totalAmount && totalAmount>0);
    }

    struct School{
        address schoolId;
        string name;
        string district;
        uint students;
        uint amountRequired;
    }

    function getbalance() external view returns(uint){
        return address(this).balance;
    }

    School[] public Schools;

    function addSchool(address schoolId,string memory name,string memory district,uint students) public {
        require(state == msg.sender);
        Schools.push(School(schoolId,name,district,students,students*unitCost));
    }

    function getTotalAmountToPay() public returns(uint){
        uint total = 0;
        for(uint i=0;i<Schools.length;i++){
            total+=Schools[i].amountRequired;
        }
        totalAmount = total;
        return total;
    }

    function allocateMoneyToSchools() public{
        for(uint i=0;i<Schools.length;i++){
            Schools[i].schoolId.transfer(Schools[i].amountRequired);
        }
    }

}

**Error generated**

> transact to supplyChain.add_money errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value.

Even though the method is payable, still it shows the same error.


texts: Continuous Funding Chainlink VRF Oracle activity

texts: What is a good way to fund a project that implements a function that pulls chainlink VRF data for random number generation? I don't want the function to stop working because of no more funds left, however, I don't want to require users to fund the LINK directly nor do I want to have to refill it continuously.


texts: I am using already deployed tokens in my contract

texts:
My question is if I'm not implementing ERC-20 methods in my contract, but I'm using already deployed ERC-20 contract methods in my contract, so can we say this will be ERC-20 compliant contract?

contract MyContract is Owned {
  event Created (
    uint256 tradeId,
    uint256 createdAt,
    uint256 expiredAt,
    address originatorAddress,
    address benificiaryAddress,
    string expectedToken,
    uint256 receivedQty);
  event Released(uint256 tradeId);

  struct Escrow {
    uint256 tradeId;
    uint256 createdAt;
    uint256 expiredAt;
    address originatorAddress;
    address benificiaryAddress;
    string expectedToken;
    uint256 receivedQty;
  }

  mapping (uint256 => Escrow) public escrows;
  mapping(address => mapping(address => uint256)) public escrowBalance;
  uint256 feePercent;
  address feeAddress;
  // ------------------------------------------------------------------------
  // Constructor
  // ------------------------------------------------------------------------
  constructor() public {
  //  escrowBalance[msg.sender][this] = 1000000000;
  // myToken = ERC20interface(erc20Address)
  }

  function createEscrow( uint256 _tradeId,
    uint256 _expiredAt,
    address _benificiaryAddress,
    string _expectedToken,
    uint256 _receivedQty,
    address token)payable external
  {
    uint256 tokenBalance = ERC20Interface(token).balanceOf(msg.sender);
    require(tokenBalance >=_receivedQty, "Insufficient balance.");

    escrows[_tradeId] = Escrow(_tradeId, now, now + _expiredAt, msg.sender, _benificiaryAddress, _expectedToken, _receivedQty);

    ERC20Interface(token).transferFrom(msg.sender, this, _receivedQty);
    emit Created (_tradeId, now, now + _expiredAt, msg.sender, _benificiaryAddress, _expectedToken, _receivedQty);
  }

  function releaseToken(uint256 _tradeId, address token) external {
    Escrow storage escrow = escrows[_tradeId];
    ERC20Interface(token).transfer(escrow.benificiaryAddress, escrow.receivedQty);
    emit Released(_tradeId);
    delete escrows[_tradeId];
  }
}


texts: Why does sites like Etherscan display complete state of transactions?

texts:
I just started learning about Ethereum, found sites like etherscan.io very interesting, but was wondering about few things, please help me understand.
Question 1
Why etherscan.io display complete information about the transaction like fromAddress & toAddress. I feel it's a potential risk, or maybe I didn't understand the right way.

Question 2
It also displays the state of the transactions as well like before/after transaction states

I was checking the transaction on the https://rinkeby.etherscan.io/ like this, and the above leads me to think, why does it display your old vs new balance, that way I can find any wallets ether balance.
Question 3
It does allow you to decompile the smart contract's bytecode, that way anyone can decompile any Smart Contract's bytecode, although this feature is experimental, why it is still a feature eg link

I am just trying to get the understanding in place, thanks in advance.


texts: Why my TransactionReceipt and TransactionHash always the same?

texts:
I setup my private node, able to deploy smart contract and makes RPC call.

However, I noticed that my TransactionReceipt and TransactionHash are always the same.

Are they supposed to be the same?


texts: ShhFilter: ValueError: {'code': -32000, 'message': 'filter not found'}

texts:
For web3.py==v5.0.1:

web3.geth.shh.newMessageFilter used to return the filter on v4.x.x but now it only returns the filter_id, so I received the filter object using w3.eth.filter(filter_id='0x').

The approach on the following code was working on web3==v4.x.x, but now I receive following error: shh: ValueError: {'code': -32000, 'message': 'filter not found'}for Listening For Events.

Example code:

from web3.auto import w3
import time

from web3 import Web3, HTTPProvider
web3 = Web3(HTTPProvider('http://localhost:8545'))

def handle_event(event):
    print(event)

def log_loop(event_filter, poll_interval):
    while True:
        for event in event_filter.get_new_entries():
            handle_event(event)
        time.sleep(poll_interval)

def main():
    filter_id = web3.geth.shh.newMessageFilter({'topic': '0x12340000', 'privateKeyID': recipient_private})
    myFilter = web3.eth.filter(filter_id=filter_id)
    log_loop(myFilter, 2)

if __name__ == '__main__':
    main()

The error I am getting:

Traceback (most recent call last):
  File "example.py", line 22, in <module>
    main()
  File "example.py", line 19, in main
    log_loop(myFilter, 2)
  File "example.py", line 12, in log_loop
    for event in event_filter.get_new_entries():
  File "/home/netlab/venv/lib/python3.6/site-packages/web3/_utils/filters.py", line 124, in get_new_entries
    log_entries = self._filter_valid_entries(self.web3.eth.getFilterChanges(self.filter_id))
  File "/home/netlab/venv/lib/python3.6/site-packages/web3/eth.py", line 402, in getFilterChanges
    "eth_getFilterChanges", [filter_id],
  File "/home/netlab/venv/lib/python3.6/site-packages/web3/manager.py", line 97, in request_blocking
    raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'filter not found'}


texts: Calling a function of another contract is not working properly?

texts:
I have a problem like this. I am very new to solidity stuff. I have created two contracts and I have called a one contract function inside another contract. Here I am providing my contracts.

This is my main contract.

pragma solidity ^0.4.17;

contract TrafficFine{
    struct Officer {
        string firstName ;
        string lastName;
        address account;
    }

    address public manager;
    uint public numberOfOffiers;

    mapping(address=>Officer) public officers;

    modifier restricted(){
        require(msg.sender == manager);
        _;
    }

    constructor () public{
        manager = msg.sender;
    }

    function addOfficer(
        string firstName,
        string lastName,
        address officer) public  restricted{

        require(officer!=officers[officer].account);

        Officer  memory newOfficer = Officer({
            firstName:firstName,
            lastName:lastName,
            account:officer
        });

        officers[officer] = newOfficer;
        numberOfOffiers++;
    }

    function getofficer(address officer) public view returns(address){
        address officer1= officers[officer].account;
        return officer1;
    }

}

This is my second contract.

contract DriverProfile{
    address watch_adrs=0x8c1eD7e19abAa9f23c476dA86Dc1577F1Ef401f5;

     function doFine(uint offenceID,string location,address officer) public{
         TrafficFine trafficfine = TrafficFine(watch_adrs);
         require(officer==trafficfine.getOfficer(officer));
     }

}

contract TrafficFine{
    function addOfficer(string firstName,string lastName,address officer) public;
    function getOfficer(address officer) public;
}

When I compile the second DriverProfille contract it gives me an error like this.

Can someone help me to solve this problem?. I search a lot to find a solution to this problem. But I was unable to do nothing to this problem. Thank you!!


texts: Transaction sent from wrong Ledger account in Metamask

texts:
I use two ETH accounts on my Ledger - account [1] and [2]. When submitting a contract or transfering ETH on the mainnet from account [2] via Metamask it still sends from [1].

To Reproduce

Click on 'Connect Hardware Wallet', select 'Ledger' and click 'connect'
Choose 'Ledger Live' as HDPath and select Ledger account [2] and click on 'Unlock'
Deploy contract on Remix/transfer ETH  with this account
Transaction history in Metamask shows 'From' address to be account [2], but in Etherscan it is obivious, that [1] has been used.

Expected behavior

Use selected account to send ETH.

Browser details

OS: Windows 10
Ledger Nano S, Firmware version 1.6.0
Chrome Version 79.0.3945.117 (Official Build) (64-bit)
MetaMask Version 7.7.2

I already opened a bug report on the Metamask GitHub page, but maybe it's my mistake?


texts:
Im using this code to send payment from Address A to address B.. But im getting this error always.

(node:18492) UnhandledPromiseRejectionWarning: Error: Returned error: insufficient funds for gas * price + value

I read at many places it may be fixed if chainId is changed. I changed many chainId but it did not work for me. I always get error :-(

// Require the web3 node module.
var Web3 = require('web3');
var Tx = require('ethereumjs-tx');
// Show Web3 where it needs to look for a connection to Ethereum.
//web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'));
web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/N6IIa2HvDYOovtgmPbhD'));
var gasPrice = '25000000000';//or get with web3.eth.gasPrice
var gasLimit = '9000';
var addr = '0x.................................';
var toAddress = '0x.................................';
var amountToSend =  "1859274664735255";
var nonce = web3.eth.getTransactionCount(addr); //211;
var rawTransaction = {
"from": addr,
"nonce": web3.utils.toHex(nonce),
"gas": web3.utils.toHex('21000'),
"gasPrice": web3.utils.toHex(gasPrice),
"gasLimit": web3.utils.toHex(gasLimit),
"to": toAddress,
"value": web3.utils.toHex(amountToSend) ,
"chainId": web3.utils.toHex('1')
};
var privateKey = '......................................................';
var privKey = new Buffer(privateKey, 'hex');
console.log("privKey  : ", privKey);
const tx = new Tx(rawTransaction);
tx.sign(privKey);
const serializedTx = `0x${tx.serialize().toString('hex')}`;
web3.eth.sendSignedTransaction(serializedTx);


texts: How much money was spent on gas for CryptoKitties transactions?

texts:
Just the main NFT contract for CryptoKitties, not the auction sale or other helper contracts.

Bonus points if you can also include billable transactions that started from another contract and then did a CALL into CK.


texts:
I just got access to a old ether wallet with all my DAO tokens. Is it too late, no way to convert them back to Ether?
any way at all?


texts: "AssertionError: Contract code empty" when testing contract above a particular size. How do I fix it?

texts:
I'm writing a contract for arbitrary-length integer arithmetic, for use in a larger project.

The problem is that once the contract gets above a certain size, the Python ethereum.tester.state().abi_contract() test environment begins giving this stack trace:

Traceback (most recent call last):
  File "se_bigint.py", line 5, in <module>
    bigint = s.abi_contract('bigint.se')
  File "/home/ada/mypy/local/lib/python2.7/site-packages/ethereum/tester.py", line 166, in abi_contract
    assert len(self.block.get_code(address), "Contract code empty")
AssertionError: Contract code empty

Here's a pastebin of code that works: http://pastebin.com/1KppMmRx

And here's a pastebin that reproduces the error: http://pastebin.com/qq7mcLeM

Note that the only difference between them is some meaningless busywork added to one of the contract functions. Also note that both contracts successfully compile via "serpent compile bigint.se". I see this both on the PyPI release and on the current github develop branch.

I'd have asked this on the ethereum forum, but I seem to be stuck in account verification over there.

Does anyone know what might be causing this, or how to get around it?


texts: How to avoid gas fee by sending ETH automatically from HDwallet addresses to my specific ETH address

texts: I have created ETH HD wallet and want to send all coins received on those HD wallet address to an admit ETH wallet , this is easy but problem stands as I want to send the ether without any gas fees. I was said it could be achieved , but after multiple google I was clueless on how I could achieve it ,I landed here for help !


texts:
I'm running a private blockchain instance for personal development and I'm trying to understand what is the proper way to use personal.unlockAccount() to prevent a security risk.

I understand the usage of the function,

personal.unlockAccount(addr, password, duration)

I know that if I don't put a duration, the account remains unlocked for the default time (which appears to be 300 seconds).  With hacks and security risks, should I stick to personal.unlockAccount(addr, password, 0.1) or something of that nature?  Or is it unimportant that the account is unlocked (contrary to what I've been reading online regarding security risks / hacking vulnerabilities)


texts: How to transfer ERC20 tokes from Blockchain wallet to MyEtherWallet?

texts: I got some token and by mistake sent them to my Blockchain ETH address. Now, what is the process of transferring them to MEW? They talk about exporting your private key, what does that mean and to where?


texts: What is the best practice to find out deposits to some Ethereum accounts?

texts:
Suppose we have multiple Ethereum accounts and we are trying to track them for any deposit. I mean we want to be notified for any transaction in the blockchain if the transaction is to any of our accounts and save that transaction. I know that for Bitcoin, there exists a function listunspent that shows any unspent transaction that is related to our addresses. but after weeks of search, I didn't find any alternative for that in Ethereum Blockchain. I tried below methods but these are not completely what I want:

Using eth.filter:

After some tests, I found that apparently, this function just filter smart contracts with the specified accounts.

searching all blocks:

This method is very time-consuming. Because there exists a lot of transactions and we should check every single transaction for the to field.

creating smart contract:

A friend told me to use Event in a smart contract. but the problem is that I don't want others to know that this contract is for me. but after some times that can be comprehended.

Using eth.getBalance

This is a solution to find out deposits but I also want to have the exact transaction that the deposit is done. but can't find it in this way.
I wonder if there exists any better way. I appreciate if you can help me.
Thanks


texts:
I recently came across a comment from Vitalik Buterin on reddit where he said that the EVM will eventually either become a sidechain or a contract written in EWASM. The comment can be found here

  even the EVM itself will eventually become either a sidechain or a contract written in E-WASM as the rest of the chain implements EWASM

That was quite a surprise to me. Does that mean that we won't be able to write contracts with Solidity in the future and basically have to switch to Rust or C++? Then why is there even work on Py-EVM if it is going to be deprecated?


texts: What are the differences between the incentivisation systems for Swarm, IPFS and STORJ?

texts:
Reading this comparison between IPFS and Swarm, I came across this section:

Filecoin is a sister project of IPFS, it adds an incentivisation layer
to IPFS and relies on its own altchain. Proof of retrievability "mining"
on the filecoin blockchain is a scheme providing ongoing compensation to
storers for preserving content. Random audits as part of the proof of work
task are responded to with proof of retrievability and the winning miners
get compensated accordingly. Such a system has inherent limitations: IPFS
can only implement positive incentives and relies on collective
responsibilty.

But what is the problem with only implement positive incentives and relies on collective responsibility?  Is there something that Swarm's incentivisation system does that Filecoin/Storj does not?


texts: What Web3JS method do I call to know what value to use for the gas price with sendSignedTransaction?

texts:
I am using Web3JS 1.0+ to send transactions to my smart contract.

I've been using the following constant for the gas price in my code that I got a long time ago from a tutorial.  What is the "professional" strategy for determining what gas price to pass to sendSignedTransaction() on the Ganache, Rinkeby and main networks?

What Web3JS method(s) do I call to determine the correct gas price?  Note, in my dApp paying a bit extra for gas is the preferred choice over trying to save some money on gas at the risk of transactions mining more slowly.

const DEFAULT_GAS_PRICE_GWEI = '0x09184e72a000';

I found the following post on the subject, but I'm wondering if there is something more nuanced:

How to caculate/estimate Gas Limit and Gas Price based on current state of the ether network?

The top answer on that post outlines the technique of using the gas price found in recent blocks or using the gas price oracle available from Web3JS, which uses the median value for the gas price found across recent blocks.  My concern with using the median value is that if there is a temporary surge in gas price you could end up  with orphan or slow transactions on the network that were submitted before the gas price surge.


texts: Is it safe to commit truffle build files to Github (open source)?

texts:
Regarding the json build files that Truffle produces based off of my smart contract, is it safe for this information to be treated as public? I just want to be sure it doesn't contain any sensitive cryptographic signatures reserved for the contract producing address.

Thanks!


texts: Unable to deploy contract with params from another contract using Truffle

texts:
I have two Contracts - a contract with a single constructor argument (ContractB), and a launcher that deploys new instances (Launcher).

Using Truffle for testing how can I link the contracts without deploying contract B, given that contract B will return an error if deployed without prams

  Error: ContractB contract constructor expected 1 arguments, received 0

Here is the link to Git repository

deploy_contracts.js

var Launcher = artifacts.require("./Launcher.sol");
var ContractB = artifacts.require("./ContractB.sol");

module.exports = function(deployer) {
  deployer.deploy(ContractB);
  deployer.link(ContractB, Launcher);
  deployer.deploy(Launcher);
};

Test File

var Launcher = artifacts.require("./Launcher.sol");

contract('Launcher', function(accounts) {
  it("Launcher Deploy", function() {
    return Launcher.deployed().then(function(instance) {
      console.log(instance)
    })
  });
});

Launcher.sol

pragma solidity ^0.4.18;

import "./ContractB.sol";

contract launcher {

    function launch() public returns(address) {
        ContractB contractLocation = new ContractB(msg.sender);
        return(contractLocation);
    }
}

ContractB.sol

pragma solidity ^0.4.18;

contract ContractB {
    address public owner;
    constructor(address addr) public {
    owner = addr;
  }

    function get() public view returns(address) {
        return(owner);
    }
}

Here is the link to Git repository


texts: Oracles and randomness, Creating or solving problems?

texts:
The idea behind oracles as a way to outsource information to be off the blockchain (Verifiable computing), Can solve a lot of problems, mostly related to randomness, As well as interacting with other APIs to get infromation from outside the blockchain.

For the issue of getting information that is related to a "PLATFORM" such as youtube, We have no choice but to trust youtube since we are depended on it...

(We may also have to trust the oracle itself, if its not open source).

But what about getting a random number from random.org for example?
We need to put our trust in a service that will report back information to the blockchain which is a trustless system, Interfering with such an external service to create exploits does present a problem.

What about future security/compatibility, Can anyone promise that what 3rd party APIs broadcast now will be valid data for future requests? With blockchain on the other hand, Everything stays on, Forever.

There is also the option of generating your own random data, But that falls short for more than obvious reasons.

When it comes to other platforms, we have no choice, But when it comes to randomness, I think we need to have a method within ethereum itself as a protocol that will allow us to generate random numbers.

Any ideas on how to get secured random number, that won't rely on oracles nor  private key/public key combo or self generated random number?


texts: How Do I Get List of Transactions for Specific Token(s) using Web3?


texts: How can we increase block gasLimit without reinitialiting the genesis block?

texts: Is it possible to increase block gas limit without reinitializing the blockchain ?


texts: Geth "origin '' not allowed on WS-RPC interface"

texts:
I'm trying to connect a local Node.js server to my local Geth node. When I try start the script, the connection fails and I see the following error in my Geth console:

origin '' not allowed on WS-RPC interface

Is there somewhere I can disable this "origin whitelist" in Geth?


texts: Where to store data when creating a blockchain based solution?

texts:
I have a question regarding the storage of data when creating a Dapp. For example i create a real estate website on ethereum blockchain where people will buy or sell properties on the basis of tokens or any traditional currency. Now where should I store all of my data. Should I store all of my data on blockchain using mapping or should i store all of my data in the database like "MySql" and store only the proof of it on the ethereum network. I have heard that its not a good idea to store all of the data on blockchain but then where should we store it if we want to maintain decentralization. Storing data on databases like MySql and MongoDB depicts decentralization. By data in a real estate website I mean:

Property information
Information regarding which user owns how many properties.
User information.
Information of the total number of tokens owned by a user.
etc

I would be very thankful for an answer.


texts: I believe one of the main criticisms of chainlink is that it is not decentralized enough, adding more nodes would be a big step in a positive direction. When I pull data through a node, that node could be corrupt and ruin my smart contract, so what gives?


texts: returning the struct value in smart contract and experimental ABIEncoderV2

texts:
I am storing and returning the struct value by using mapping.

pragma solidity >=0.5.0 <0.7.0;
pragma experimental ABIEncoderV2;

contract Manage{

 struct Policy{
  string  PolicyID ;
 }
 mapping (address => mapping(string => Policy)) private policy;

 function storePolicy(address insuranceHolder,string memory _PolicyID) public {
   policy[insuranceHolder][_PolicyID].PolicyID = _PolicyID;
 }
 function getPolicy(address insuranceHolder,string memory _PolicyID) public view returns(Policy memory) {
  return policy[insuranceHolder][_PolicyID];
 }
}

I am getting a return value like this.
 0: tuple(string):_PolicyID
I don't want this 0: tuple(string):
I want only _PolicyID, how to do that can anyone help me.

I am getting a warning for using pragma experimental ABIEncoderV2;
warning: Experimental features are turned on. do not use experimental
features on live deployment.

The compiler gives the warning. That means I should only use it for development. That makes no sense to me.


texts: How to restrict function to only callable from one external contract?

texts:
I have a Reputation contract which has a function foo() that sets some point.
In another contract called Market I want to use the foo() function. But I don't want any one to be able to call foo() outside Market.
the problem is I need to deploy Reputation first and make instance of it in market. I have no idea how to make modifier in Reputation to restrict foo() before deploying Market.


texts: How do i redirect any transaction entering my wallet to the parent wallet

texts: My wallet private key has been conpromised and anytime I receive any eth transaction it automatically redirect to the Hacker wallet address almost immediately I'm so confused right now I need all the help I can get cause that's my business wallet address please


texts: What's the difference between these two methods of creating an account via Parity?

texts:
In Parity, as explained in this tutorial for setting up a PoA, there are three methods for creating Ethereum accounts: Via RPC calls, via the UI, and via parity account new.

The UI obviously seems to wrapping the RPC calls, so we can discard the UI for the sake of this discussion. I've observed the following:

The RPC calls will deterministically create an ICAP address. I'm specifically running parity_newAccountFromPhrase and I seed this with a random phrase from parity parity_generateSecretPhrase.
The command line option parity account new does not seem to give me an ICAP address or the possibility of getting a recovery phrase.

So what's the rationale behind this? Is there a way for me to get a non-ICAP compatible address from the RPC calls? Is there a way for me to get a recovery phrase from the command line option?

I'm specifically asking with regard to private PoA chains.

EDIT: ICAP, not ICAN.


texts: What's the difference between OpenZeppelin's IERC vs ERC contracts?

texts: I'm using the contracts OpenZeppelin provides, but I don't understand why there is 2 version of the same one. Why is there an I version vs non-I?


texts: Detecting a contract deployment, zero address?

texts:
Can anyone help ?
I am trying to listen for a new contract deployed. I thought that contracts were sent to the zero address which means its a new contract deployment, although this is not working. Maybe I am doing something wrong ?
            for _, tx := range block.Transactions() {

                zeroed := util.IsZeroAddress(tx.Hash().Hex())

                if zeroed {
                    fmt.Println("We have a zero address!!!!")
                    fmt.Println("header", header.Hash().Hex())
                    fmt.Println("tx", tx.Hash().Hex())
                }

The above doesn't seem to work so I am obviously doing something wrong.
I am listening for new headers, then getting the block and then finally the transactions.
Does anybody know how I can confirm that one of the transaction is a new contract deployment ?
Thanks in advance


texts: What is the difference between liquidity mining and farming?

texts:
I have seen both terms being used in the DeFi space a lot.
I understand that liquidity mining is:

when people receive tokens as rewards for participating in a certain
protocol in a given way.

I understand that farming is:

staking lp tokens to gain and getting a part of the transaction fees
that are taken when the given pair is traded.

My question is, in farming are people rewarded with just the fees or is liquidity mining also invloved?


texts:
I am wondering how a private chain can communicate through Metamask.

My biggest concern is the HttpProvider and accounts.

Aren't accounts accessed through the web3 instance?
Since accounts aren't shared over the network, aren't we only be able to access the accounts associated with the  providing chain?
Is there anyway to dynamically access providers so that members aren't always using the same provider?


texts: Is there possible that current block do not have uncles? As we know that Main block contain the contract information , What does uncles holds ?


texts: Gas consumption of a view public function

texts:
In my contract I have a view public function that returns an array of bytes32 elements. In remix it produces a warning saying it might run out of block gas limit if I use this function.
As I had read when a function doesn't make state changes you define it as view public. So when you call it you don't have to pay ether because your local node calls the variables from the contract and runs it localy. Is this right? Then why I have to worry about gas limit?

Re-edit after Lauri's Peltonen comment. The code I used is:

pragma solidity ^0.4.18;
contract Project{
    bytes32[] array;

    function addValue(bytes32 element)public{
        //only the administrator can add new values
        array.push(element);
    }

    function getAll()view public returns(bytes32[]){
        return array;
    }
}


texts:
Hi There i was running this code on remix javascript vm. But this gave me error on buy function that constructor should be payable if you want to use message sender. I can't understand the mistake as I am still learning. Thanks for any help.

pragma solidity ^0.4.19;

contract Lottery {

    address[] tickets;
    address owner;
    uint ticketCount = 0;
    uint maxTickets = 100;

    function buy() public payable {
        require(msg.value == .001 ether);

        tickets.push(msg.sender);
        ticketCount++;
    }

    function currentTickets() public constant returns(uint currentNumber){
        return ticketCount;
    }
}


texts: Is there any recent problem with Chrome Metamask?

texts:
I was using MetaMask for google chrome. recently I realised when I send a transaction to a blockchain (e.g. private/local) all the transactions are pending. But if I do the same with Firefox metamask, it works fine.

Can anybody explain to me if I'm missing something or there's some problem.
I tested on MAC and linux, both have the same issue.


texts: Get ERC721 token total supply using web3.js

texts:
I created a simple contract which basically does nothing but mints new ERC721 tokens. The solidity code for it is as follows:

struct Monster {
        string name;
        uint level;
        uint attackPower;
        uint defensePower;
    }

Monster[] public monsters;
function createToken(string _name, address _to) public{
        require(owner == msg.sender);
        uint id = monsters.length;
        monsters.push(Monster(_name, 1, 100, 100));
        _mint(_to, id);
    }

I invoked the createToken method serveral times and created a token named testToken and sent it to my metamask wallet account. I can see the token in metamask.
The contract is deployed on ropsten network and I have the contract address.

Now, I want to use web3.js to simply check this balance from my account (metamask wallet). I am trying to use this library https://www.npmjs.com/package/erc721 for the abi.

I have the following code:

const { MintableNonFungibleToken } = require('erc721');
var abi = MintableNonFungibleToken;
var contractAddress = '0x17b95748b3da7f1c4fbf665b8340b851cec7b856';
var token = web3.eth.contract(abi).at(contractAddress);
console.log(token.balanceOf(address).toNumber());

I get the correct token count here. However, I could not find any method token.decimals() like in ERC20 contract.

Does it mean I can just use token.balanceOf(address).toNumber() to find the token count?
How do I identify the tokenId of these tokens so I can query more information about the token?
How do I execute totalSupply()?
I tried token token.totalSupply().toNumber(). However, the value is always 0.

PS: I haven't implemented totalSupply(). I am trying to write generic APIs to query ERC721 contracts and get information, so I am looking for something from standard specs from ERC721 instead of depending on the developer to write specific functions in contracts.


texts:
My Etherli wallet has a huge problem. When I try to send Ether with it, I always get the message:

  Error: invalid rlp: total length is larger than the data

I have no idea what that means or what to do. If anybody can help me to solve this problem, I guarantee a huge surprise gift. Of course the gift has to do with Ethereum :-)


texts: Public / Internal modifier spawns error: This type is only supported in the new experimental ABI encoder

texts:
I have this code snippet:

pragma solidity >=0.5.0 <0.7.0;

import "@aztec/protocol/contracts/libs/NoteUtils.sol";

library EscrowUtils {
    using NoteUtils for bytes;

    struct Note {
        address owner;
        bytes32 noteHash;
    }

    function noteBytesToStruct(bytes memory note)
        internal
        pure
        returns (Note memory codedNote)
    {
        (address owner, bytes32 noteHash, ) = note.extractNote();
        return Note(owner, noteHash);
    }
}

which does not throw any errors. However, when I change the visibility modifier on the function to public, I get:

This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.

Why changing modifier causes this error?


texts: Advantage of Chainlink's VRF over commitment scheme chain

texts:
News

Chainlink announced a randomness oracle via VRF: https://blog.chain.link/verifiable-random-functions-vrf-random-number-generation-rng-feature/.

Question

What is the advantage of an VRF over a simple 'hash of hash of hash...'. (see e.g. 3.1 in https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=924116) Basically an infinite commitment scheme where each commitment reveal is automatically the commitment for the next value.

Detailed explanation

The commitment scheme is a way for someone to commit to a secret value without revealing it. This can be done by simply using a one-way hash function, e.g., keccak256(12). The resulting hash can be revealed in a first step, in a follow-up step the actual secrect number, in our case 12, will be revealed. Anyone can verify the correctness of 12 by computatin keccak256(12) themselves.

To make this into an oracle, one would create chains of commitments where you start with a random number and then continue computing the hash of the hash.. keccak256(...(keccak256(12))...). You do that let's say a few billion times and you start sending the last value first. Now you are basically forever committed to a series of random numbers which only you will know in advance and the only thing you could do is stop sending. Sounds identical to the VRF approach in that regard:

  The worst case scenario is that the compromised node does not return a response to a request.

Now I'm wondering if there are any advantages from the VRF? Seems like a more complicated approach than the commitment chain oracle without any benefits?


texts: POA chain: intrinsic gas too low, contract deployment

texts:
I'm trying to deploy my smart contract to a private proof of authority chain with geth, but i always get the following error message intrinsic gas too low
This is the JSON RPC request i'm sending. bytecode is the byte code of my smart contract.
data = {
    "jsonrpc": "2.0",
    "method": "eth_sendTransaction",
    "params": [{
         "from": w3.eth.defaultAccount,
         "data": Web3.toHex(bytecode),
    }],
    "id": 420
}

When I deploy the same contract on ropsten it uses 3163322 gas. Ropsten link
I'm able to deploy smaller contract like SafeMath, so my first thought was that the gaslimit of my blocks were too small. This is not the case.

eth.getBlock("latest").gasLimit
150063322

Does anyone see the mistake?


texts: Can we say a solidity function is an atomic operation?

texts:
Look at this very basic solidity function:
function myfunction() external {
  address payable address1 = 0x....;
  address payable address2 = 0x....;

  address1.transfer(1 ether);
  address2.transfer(1 ether);
}

Let's suppose the second transfer will fail.
There are many reasons for that (insuffisant funds in the contract's balance, ).
I want to be sure the first transfer will be cancelled in this case.
I suppose a solidity function is "atomic". I mean if something fails in the function, every operation made in the function is canceled.
I have test and i have see the first transfer is cancelled. I am happy to see that.
But somebody told me what i was doing is a bad practice. He told me i should write a "pull-payment" pattern. My question is why should i do that.
Is there some cases where a solidity function is not "atomic" ?
Thanks a lot
*** EDIT ***
Here is what i mean by "pull payment":
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/payment/PullPayment.sol

strategy, where the paying contract doesn't interact directly with the
receiver account, which must withdraw its payments itself.
Pull-payments are often considered the best practice when it comes to sending   Ether


texts: How can I call smart Contract function from server side using ethereum account

texts:
I want to call Smart Contract function from server side.
How can I call?
I want to use nodejs.


texts:
I have used Geth.aar library for generating ethereum address from 24 word seed.

But every time I got new address.

I need same address every time.

Please help me with this.


texts: Defining an endpoint dinamically in metamask?

texts:
I am creating a permissioned ethereum blockchain network and many dapps will be deployed in it.
Since the dapps need to check some rules before submitting transactions to the node (yes, it is a permissioned network, not so much censorship-resistant :( ), each dapp has its own endpoint.
I would love that the user could use Metamask without needing to configure different endpoints anytime he/she changes dapps.
The concept of endpoint comes in the network dropbox of Metamask. Each "network" is a different endpoint to (possible different) networks.
For example
Dapp1 - network config in metamask --- http://177.453.993.113:8885
Dapp2 - network config in metamask --- http://177.453.993.114:8885
Is it possible to define the metamask endpoint dynamically (programmatically) in each dapp (of course, asking the user permission)?
Thank you


texts:
I am working with @truffle/hdwallet-provider library.
This library works with a mnemonic. Is is basically a seedphrase.
Is there a way to work with this library outside truffle ? (I mean in a standalone javascript file).
Is there a way to calculate private keys from the mnemonic ?
Thanks


texts: require Statement returns Transaction Revert Error instead of provided custom error message

texts:
For example, i have this piece of code here require(keys[_address].purpose != _purpose, "Key Already Exists"); in a Smart Contract. Upon executing a function and failing a requirement, require statement does not return the defined error message. Instead it returns UnhandledPromiseRejectionWarning: Error: Transaction has been reverted by the EVM. I am writing an application in Node JS and i know my code works correctly because i tested it with different type of inputs and it provide the correct outputs.
I am using Truffle for development with parity. I tested it with Remix and it provides me defined error message so issue is not with the code.
My actual question is why require statement does not return the provided error message?. Am i missing something?. Do i need to provide a certain flag to parity or setup something to catch the provided error message?. Any suggestion would be helpful
Smart Contract Code:
address public administrator;

constructor() public
    {
        administrator = msg.sender;
        addKey(msg.sender, 1, 1);
        emit KeyAdded(msg.sender, 1, 1);
    }

mapping(address => Key)keys;
mapping(uint256 => address[])keysByType;
mapping(uint256 => address[])keysByPurpose;

event KeyAdded(address indexed key, uint256 indexed purpose, uint256 indexed keyType);

struct Key {
        uint256 purpose;
        uint256 keyType;
        address key;
    }

modifier onlyAdmin
    {
        require(msg.sender == administrator, "Sender is not admin");
        _;
    }

function addKey(address _address, uint256 _purpose, uint256 _type) public onlyAdmin override returns(bool success)
    {
        require(keys[_address].purpose != _purpose, "Key Already Exists");
        keys[_address].key = _address;
        keys[_address].purpose = _purpose;
        keys[_address].keyType = _type;

        keysByType[_type].push(_address);
        keysByPurpose[_purpose].push(_address);

        emit KeyAdded(_address, _purpose, _type);
        return true;
    }

Node JS Sample Execution:
myContract.methods.addKey("00a329c0648769a73afac7f9381e08fb43dbea72", 3, 1).send({from:"00a329c0648769a73afac7f9381e08fb43dbea72", gas:4613288}).then(console.log)


texts: Fatal: Error starting protocol stack: resource temporarily avalible (Virtual Machine Ubuntu)

texts:
This happened as soon as I typed in

  geth

This also happened when I typed in

  geth --rpc --fast --cache=2048

Does anybody have a fix? Keep in mind I run on virtualbox.


texts:
What benefits does the use of following bring to my Ethereum application if I wish to interact smart contracts for sending multiple transactions, upload files on blockchain, etc.?

bower
web3js
nodejs
golang apis

Can someone please explain the advantages and dis-advantages of each one of them?

Also, which is the best choice for large scale projects?


texts: Exactly what data does snap sync download?

texts: Geth 1.10 introduces snap sync, faster way of syncing the blockchain. What data does snap sync actually download? If I run a snap sync with --gcmode archive will I end up with an archive node?


texts:
I have a function that calls a contract and uses the return value in the code. I want to change that function so I can use it in the rest of my code as getter to my contract.

The function is asynchronous, so I can't do something like var res = App.getter(param);.

Looking at the other asynchronous functions like the calls, I figured I could use .then or promises: ContractInstance.myFunction.call().then(function (result){ ... });

But App.myFunction(i).then(function (result){ ... }); doesn't work, and I don't know where to look to make it the way I want.

Here's the function:

getEventInfo: function(i){
  var numeroPlace;
  App.contracts.myContract.at(addresses[i]).then(function (instance) {
    var MyContractInstance = instance;
    MyContractInstance.getEventInfo.call().then(function (result) {
        console.log(result);
        //do stuff with result
        return result;
    });
  });
},

I want to be able to do something like:

var eventInfo = App.getEventInfo(i);
//do stuff with eventInfo

or

App.getEventInfo(i).then(function (result){
  var eventInfo = result
  //do stuff with eventInfo
};


texts: Why to write return statements in solidity function

texts:
A value returned by a function in the smart contract cannot be captured as every function returns a hash.

Then, why write return statements in Solidity function?

For example,

event LogNewVoter(address sender, string name, bool isSuccess);

function addVoter(address _voter,string _name, bytes _voterImageHash) payable public returns(bool) {
    require(msg.sender == votingAdmin);
    Voter storage sender = voters[_voter];
    if(sender.isVoter){
        revert("This address is all ready registered as a voter!");
       //throw;
    }
    voters[_voter].name = _name;
    voters[_voter].hasVoted = false;
    voters[_voter].isVoter = true;
    voters[_voter].voterImageHash = _voterImageHash;
    LogNewVoter(msg.sender,_name,true);
    return true;
}

In above question, I can get whether the voter is registered successfully or not by using events. If I can not capture value returned by a function then why to write return statements in function?


texts: Ethereum transaction RangeError: private key length is invalid

texts:
I'm running a tutorial on how to sign an ethereum transaction programmatically, and I'm getting the following error:

RangeError: private key length is invalid

This is the code:

var Web3 = require('web3');
var web3 = new Web3(new
Web3.providers.HttpProvider('https://ropsten.infura.io/'));
var util = require('ethereumjs-util');
var tx = require('ethereumjs-tx');

var privateKey = '0x...';
var publicKey = util.bufferToHex(util.privateToPublic(privateKey));

The error is on the last line, that attempts to get the public key from the private key.

My private key is an alphanumeric  string with a length of 64 characters. From all I can see it's the correct length.

What am I missing?


texts:
I'm working on API'S for smart contract.  I'm using tronbox to compile and migrate. Error is this contract constructor expected 1 arguments, received 0 I tried to add arguments in migrations like this but it's not working.

const SimpleStorage = artifacts.require('SimpleStorage.sol');

module.exports = (deployer) => {
  const VALUE = 100;
  deployer.deploy(SimpleStorage)
    .then(() => (VALUE));
};

This is my contract.

contract SimpleStorage {
    uint256 public data;
    event UpdateData(uint256 oldValue, uint256 newValue, uint256 timestamp);
    constructor (uint256 _value) public {
        require(_value > 0, "in SimpleStorage:constructor(). Value must be greater than 0.");
        data = _value;
    }
    function updateData(uint256 _value) public {
        require(_value > 0, "in SimpleStorage:setData(). Value must be greater than 0.");
        emit UpdateData(data, _value, now);
        data = _value;
    }
    function getData() public view returns (uint256) {
        return data;
    }
}

This is my Controller

const updatedData = async (params) => {
  try {
    const { value, contractAddress } = params;
    const contractInstance = await getContractInstance(contractAddress);
    utils.setDefaultKeyAndAddressInTronWeb(process.env.TOF_PRIVATE_KEY);
    const result = await contractInstance.methods.updateData(value).send();
    return result;
  } catch (e) {
    return {
      status: 'failure',
      message: e.message,
      data: [],
    };
  }
};


texts: greeter.address Undefined while deploying the contracts


texts: access struct from mapping in a different contract

texts:
I want to access / modify data from a contract from another contract.
If you could help me understand the error that would be great!

I get the following error:

Untitled1:33:8: Error: Indexed expression has to be a type, mapping or array >(is function (address) constant external returns (bool,address,uint256,bool))
        if (a.Owners[msg.sender].sub = false){
            ^------^

below is the code :

pragma solidity ^0.4.7;

contract abc{
    struct Owner{
        bool exist;
        address owner;
        uint share;
        bool sub;
    } // un owner as son address et son percent d'ownership

    mapping (address => Owner) public Owners;
    uint public no_owners;
    uint public no_sub;

    function abc(){ // a l'execution, l'ownership est transferer a l'excecuteur avec 100 shares.
        //initate
    }

    function transfer(address to,uint amount){
        //transfer ownership
    }
}

contract cde{
    mapping (uint => abc) all_cde;
    uint public f;

    function ask_subdivise(abc a){
        //les different owners vont devoir lancer la fonction
        // une fois que tout les owners on lancer la fonction, le lot est diviser.
        if (a.Owners[msg.sender].sub = false){
            a.Owners[msg.sender].sub=true;
            a.no_sub+=1;

        }
    }
}


texts: Geth keeps shutting down on AWS EC2 instance

texts:
I am trying to run a Geth node on an AWS EC2 instance. I am able to start it, and it runs fine for a while, but keeps crashing periodically and not leaving much in the log.

The EC2 instance is a T2.Medium, so it has 2 vCPUs and 4GB of RAM. Output of commands about instance:

ubuntu@ip-127-0-0-1:~$ uname -a
Linux ip-127-0-0-1 4.4.0-1062-aws #71-Ubuntu SMP Fri Jun 15 10:07:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@ip-127-0-0-1:~$ cat /etc/issue
Ubuntu 16.04.4 LTS \n \l

I have allocated plenty of storage for the blockchain (500GB) and it is not close to full.

I have tried running Geth as a systemd service as mentioned here, as well as every other method listed. Some examples include:

geth --cache=1024 --rpc --rpcapi "eth,web3" 2> gethlog.txt

screen -dm bash -c 'geth --cache=1024 --rpc --rpcapi "eth,web3" 2> gethlog.txt'

nohup geth --cache=1024 --rpc --rpcapi "web3,eth" &

Again, the node starts and runs fine for a long time (I am able to exit the SSH session with the instance, reconnect, and I am able to attach to geth and even curl against the RPC) It seems like after running for a long period of time, geth shuts down. The only time I caught in the above-mentioned gethlog.txt, it was logging as if it received a shutdown command (Already shutting down, interrupt 9 more times for panic.)

I'm thinking something has to be wrong with my EC2 environment. I'm sure I'm missing something obvious, but I've been struggling with this for weeks!


texts:
Sha256 Message Digests are 32 bytes, however they are typically expressed as a 64 character string. Is it possible to map the string to an address?

Something like

mapping (stringToBytes32(bytes32) => address) public digestToAddress;

I'd rather not store the string and would like to store the byte32


texts: Importing contracts files to Ethereum Wallet

texts:
I tried running a contract with the code below inserted on the ethereum browser and it complied successfully. I tried it on the Ethereum wallet and its giving an error of source not found.

import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

I need it to work on the Ethereum wallet as I do not know how to interact with  contracts using the browser solidity or command line.
Thanks


texts:
I have a contract instance:

var contract = web3.eth.contract(JSON.parse(abi)).at(address);

and I can call functions like this:

contract.myFunction.call();

this works fine. Now I want to send some ETH with that function call. How do I do that?


texts: Wrong order when calling a function to return a string

texts:
I have an array of strings in my Contract.sol:

string[] messages;

function getMessage(uint i) constant returns (string) {
     require(messages.length > i);
     return messages[i];
}

In my app.js, when the page is loaded I want to populate the page with all the strings. The relevant part of how that's done is as follows:

for (i = numberOfMessages - 1; i >= 0; i--) {
        contractInstance.getMessage.call([i]).then(function (stringReturned) {
          p = document.createElement('p')
          p.innerHTML = stringReturned
          document.body.appendChild(p)
        })
      }

(You can see this is done backwards, ie. the last element in the array is retrieved and added first - because I want to display the latest message first)

The problem with this is the order the strings are retrieved and displayed on the page is all over the place, I guess because the calls are happening very quickly all at once. How should I be doing this?


texts: Is there an ERC for exchange deposits or merchant deposits?

texts:
The title is the question. I have searched for any discussions of similar topics, but after looking at various CEX platforms across the world, most are just generating a bunch of keys and doing value transactions. (No smart contracts)
I wonder if there has ever been a discussion about ways to do this?
Merchants would have similar needs for an ERC...
ie. a simple idea would be a payable function called function payment(bytes8 uid) public payable with fallback functions just reverting. Then we could create a new address format that encodes the 20 byte account and 8 byte uid for the invoice-id/exchange-user-id into a single string (bech32 or base58 or something else)... then anyone who can parse those addresses should just add 0x4a5b59d6XXXXXXXXXXXXXXXX000000000000000000000000000000000000000000000000 and replace X part with the big endian representation of the uid, slap it in the data section, then bam, only one contract is needed to receive ETH from millions of people in one place.
An open source simple solution that just simply forwards msg.value and sets off an event (for detecting the deposit) could be made, and suddenly all the exchanges don't need to worry about generating tons of keys anymore.
... Maybe my searching skills are not good enough.
If anyone knows of any discussion that was held at any point in time and can point me to it I would greatly appreciate it.
Thanks.


texts: There were reports of certain countries that had issued their own cryptocurrency. What are they?

texts: I've been reading that certain countries with sanctions has issued their own cryptocurrency on the Ethereum blockchain as ERC20 tokens. What are they and which countries? And are they on any exchanges?


texts: Why isn't the " i++ " evoked first in this code?

texts:
I could just leave well enough alone here, but I'm curious.  In this code, each byte in "wordbytes" is set individually from 0 to 1, ... 3.  But why does it start at wordbytes[0], if "i++" is in the brackets?  Doesn't this tell solidity we want to change the byte with the index of "i + 1", which would be 1 the first time around - aka the second byte?

bytes wordbytes = new bytes(4);
uint public i;

function setbyte(uint8 _utf8) public {
    wordbytes[i++] = byte(_utf8);

}

Doing the code in the following way - in which "i" is incremented after the byte is set - works the same:

bytes wordbytes = new bytes(4);
uint public i;

function setbyte(uint8 _utf8) public {
    wordbytes[i] = byte(_utf8);
    i++;

}

What tells solidity to increment "i" after "wordbytes[i]" is set in the first example?


texts: Truffle Migrate Error: Could not find built Migrations contract: Unexpected token in JSON at position 0

texts:
Running truffle migrate with valid contract code started causing this error for me:

Writing artifacts to ./build/contracts

Using network 'development'.

Error: Could not find built Migrations contract: Unexpected token  in JSON at position 0
    at Object.lastCompletedMigration (/Users/joran/.nvm/versions/node/v8.11.1/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:253:1)


texts: How can I convert a bytes32 to a string? Does anyone has a magic function or library which does it?


texts:
Error: Error: ProviderError: VM Exception while processing transaction: revert
    at Object.run (C:\Users\WINDOWS\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
Truffle v5.0.33 (core: 5.0.33)
Node v11.12.0
PS D:\Blockchain Dev\t2>

***** Token.sol *****

pragma solidity >=0.4.25 <0.6.0;
contract Token {
    mapping (address => uint256) public balanceOf;

    constructor(uint256 initialSupply) public {
        balanceOf[msg.sender] = initialSupply;
    }

    function transfer(address _from, address _to, uint256 _value) public returns (bool success) {
        require(balanceOf[_from] >= _value);                // Check if the sender has enough
        require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        return true;
    }
}

***** Shop.sol *****

pragma solidity >=0.4.25 <0.6.0;

import "./Token.sol";

contract Shop {
    struct Product {
        string name;
        string imgPath;
        uint256 price;
        uint256 quantity;
        address seller;
    }
    event AddedProduct(uint256 pid, address seller, uint256 timestamp);
    event BuyProduct(uint256 pid, address buyer, uint256 timestamp);
    mapping (uint256 => Product) products;
    mapping (uint256 => address[]) buying;
    Token token;

    constructor (address _tokenAddress) public {
        token = Token(_tokenAddress);
    }

    function addProduct(
        uint256 _pid,
        string memory _name,
        uint256 _price,
        uint256 _quantity,
        string memory _imgPath,
        uint256 timestamp
    ) public {
        products[_pid] = Product({
            name: _name,
            imgPath: _imgPath,
            price: _price,
            quantity: _quantity,
            seller: msg.sender
        });
        emit AddedProduct(_pid, msg.sender, timestamp);
    }

    function getProduct(uint256 _pid) public view returns (string memory, uint256, uint256, string memory, address) {
        Product memory product = products[_pid];
        return (product.name, product.price, product.quantity, product.imgPath, product.seller);
    }

    function buyProduct(uint256 _pid, uint256 _timestamp) public {
        require(products[_pid].quantity > 0, "Product is sold out");

        Product storage product = products[_pid];
        address _buyer = msg.sender;
        token.transfer(_buyer, product.seller, product.price);

        product.quantity -= 1;

        buying[_pid].push(_buyer);
        emit BuyProduct(_pid, _buyer, _timestamp);
    }
}

***** 2_deploy_contracts.js *****

const Token = artifacts.require('./Token.sol');
const Shop = artifacts.require('./Shop.sol');

module.exports = function(deployer, network , accounts) {
  deployer
    .deploy(Token, 1000000)
    .then(async () => {
      const tokenContract = await Token.deployed();
      return deployer.deploy(Shop, tokenContract.address);
    })
    .then(async () => {
      const token = await Token.deployed();
      const coinbase = accounts[0];
      const value = 50000;
      await token.transfer(coinbase, accounts[1], value);
    });
};

***** truffle-config.js *****

const HDWalletProvider = require('truffle-hdwallet-provider');
const mnemonic = ".....";

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    },

    kovan: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://kovan.infura.io/v3/.....")
      },
      network_id: 42
    },
},

}


texts: Is this the "correct" way of distributing uneven fractions of an ETH balance?

texts:
Some friends and I built a mining rig together, each contributing different amounts of fiat to the endeavor. I'm adapting the contract from this answer to receive ETH from MiningPoolHub and distribute it to our separate addresses according to how much fiat we put into the initial cost of the rig. Have I gone about this the correct way?

pragma solidity ^0.4.21;
contract SplitPayment
{
    address public A = 0xAAA;
    uint256 public A_share  = 111111111;

    address public B  = 0xBBB;
    uint256 public B_share  = 222222222;

    address public C = 0xCCC;
    uint256 public C_share = 666666667;

    function sendPayment(address person, uint256 raw_share) private
    {
        uint256 balance = address(this).balance;
        person.transfer(balance * raw_share / 1000000000);
    }
    function() payable public
    {
        sendPayment(A, A_share);
        sendPayment(B, B_share);
        sendPayment(C, C_share);
    }
}


texts: Contract deploy failed. Caused by Gas is insufficient. Can add more Gas and re-deploy again?

texts:
In fact got 3 question to ask:

when using Mist to deploy a contract (link testnet), why i always need to add more GAS, so that
my contract could deploy successfully. otherwise, usually deploy failed.
(failed contract seems cannot be review,no detail,and cannot do anything....)
see graphic bellow~(no data created on address...)

And  if the contract deploy failed, why cannot re-deploy the contract and add more gas to make it works ?
update:
failed type such as 1. metioned.... seems create address succeed ,but no data in it....looks like no any way to do re-deploy...
Can delete the failed contract on Mist?  since it is unable to be used.
update:
i find every deploy succeed contract,in contract itself detail veiw
at the contract name right side , provide a hidden trachcan icon to delete it..
but deploy failed ones ,cannot find any function to do delete...


texts: How do I generate multiple address for ethereum which have no contract on it

texts: I want to generate 10000 addresses which do not have contract on it and can send and receive ethereum from non smart contract exchanges like Koinex in India.