texts:
I have a simple contract that contains a struct. First, I initialize it using certain values and at some point I want to change them, in this case with setCompleted. However, the changes do not get stored permanently and completed property is still stored as false even after setting it to true in setCompleted function. What could be the issue?

pragma solidity ^0.4.15;

contract MyStructExample {
    struct MyStruct {
        address addr;
        string description;
        bool completed;
    }

    address owner;
    mapping (address => mapping(string => MyStruct)) myStructs;

    // MyStructExample.deployed().then(function(instance) {app=instance;})
    function MyStructExample() {
        owner = msg.sender;
    }

    // app.setMyStruct("0xe38d0b841dd19802b429b85c41d597e4c29d88e1", "Blah blah")
    function setMyStruct(address _addr, string _description) {
        MyStruct storage myStruct;

        myStruct.addr = _addr;
        myStruct.description = _description;
        myStruct.completed = false;

        myStructs[myStruct.addr][myStruct.description] = myStruct;
    }

    // app.getMyStruct.call("0xe38d0b841dd19802b429b85c41d597e4c29d88e1", "Blah blah")
    function getMyStruct(address _addr, string _description) constant returns (address, string, bool) {
        MyStruct memory myStruct = myStructs[_addr][_description];
        return (myStruct.addr, myStruct.description, myStruct.completed);
    }

    // app.setCompleted.call("0xe38d0b841dd19802b429b85c41d597e4c29d88e1", "Blah blah")
    function setCompleted(address _addr, string _description) onlyOwner returns (bool) {
        myStructs[_addr][_description].completed = true;

        return myStructs[_addr][_description].completed;
    }

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

    function kill() onlyOwner {
        selfdestruct(owner);
    }
}


texts: Challenge: What is Ethereum's 1 Billionth transaction?

texts: I am trying to find ethereum's 1 billionth tx for a project but I don't know how I would go about finding this? Also if you already know what the tx is would be great if you could share! Thanks


texts:
I'm just wondering if is possible to create a private network (Not development) with this characteristics:

Max supply
One account has all the supply already
Nodes/peers can't mine
Gas cost is always 0


texts:
I started a project with truffle init, and  I am trying to write a test and I have an import like so:
import "truffle/Assert.sol";

I get an error:

Error: Could not find truffle/Assert.sol from any sources;

How do I fix this? Is Assert a built-in truffle library or do I have to install it separately?


texts:
The more gas used, the more profit a miner earns. So miners can simply say that the transaction ran out of gas without even executing the transaction and updating the state.

JITVM optimizes the byte-code so less gas is required for executing transactions. But how does this benefit miners? Less operation will result in less profit.

How does another node verify verify the gas used is correct?


texts: Anyone some have "ERC20 Deposit Contract" sample code?

texts:
I'm looking for an example contract that works like this:

  There is a person A, a person B, an ERC20 token named abc, and a
  smart contract C,

  Person A sends 20abc to contract C, and 30 minutes
  later, the contract C sends 20abc to person B.

It doesn't need to be reusable, i.e., it doesn't need to support multiple deposits.


texts: Transaction fees on smart contract token as loyalty points

texts:
As at ethereum mentioned, token ERC20 can be used as Loyalty points. So consider a Forex website which wants to send 1 of its token to each clients who have traded 1 lot or so. In other words its smart contract event has coded to sending token per each trade or even for each sign up in its website.
my question is if the transaction fees apply to all sending token as loyalty points to the website's clients, it will be horrible and gainless.
I am starting to learn solidity , so maybe I'm in a wrong way. please help me know there is the transaction fees? and if it is what is the minimum amount?


texts: Different address make same signature for one message

texts:
Is it possible two different wallets (address) make the same signature for one message?

I have one message: '010025819ecc6e01000000000000000000000000000000000000b735b643314b4e512020204c271c0eff02003b0f000000' and two different addresses: '0x222682ef86452de181cfdbb173261e31ea9c7f3e' and '0x93a12ef77d452f49b789077b142ec87407ac15f8'.
Both addresses produce the same signature '0xf48423551081e974fb0fb6cd13342dd54bf5ad552076da4b3738d6ce9bcb6d951400af5ada5f487897aac29393f1a3e4fc51bb8239dec2b397e3c7075f1116931b'.
I verified this in https://etherscan.io/verifySig and both pass the verification.
Why this is possible?


texts: Create hash in c# and validate in solidity

texts:
I'm trying to build an app that will call a contract from javascript. I want the contract to validate that the parameters weren't tampered with. In order to do that, my plan was to figure out the parameters server-side, hash the combination of parameters, and sign the hash. I'd pass the hash and signature along to the contract for the contract to validate. The hash would prove the parameters haven't changed and the signature would prove that I generated the hash.

I'm currently trying to figure out the hashing part.

void Main()
{
    var bytes = ASCIIEncoding.ASCII.GetBytes("abc");

    SHA256 hasher = SHA256Cng.Create();
    var hashed = hasher.ComputeHash(bytes);
    Console.WriteLine(BitConverter.ToString(hashed).Replace("-", string.Empty));
}

gives me an output of BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD

On the other side of the fence I have

pragma solidity 0.4.18;

contract HashCheck {
    function hash(bytes32 toHash) public returns(bytes32) {
        bytes32 hashed = sha256(toHash);
        return hashed;
    }
}

which returns

truffle(development)> f.hash.call("abc")
'0x26426d7cb06a12643ccfe84107603083d835c37f000a12f734137a0c8df77f26'

I'm happy to try out keccak (sha3) hashing but I haven't figured out how to do that in C# yet.


texts: Uniswap Fee or how 180 AMPL tokens suddenly "disappeared" from blockchain

texts:
If you look  at https://etherscan.io/token/0xd46ba6d942050d489dbd938a2c909a5d5039a161?a=0xfe6c9c5a0d36eba3a767aaf6df2f335e666a74e7, you can notice that there were 3 transactions associated with the address 0xfe6c9c5a0d36eba3a767aaf6df2f335e666a74e7.
And if you sum up the quantity in (141,178604069 + 1659,518828706 = 1800,697432775) and
subtract quantity out (1800,697432775 - 1620,109104886) there should stay 180,588327889 AMPL on the address.
But actually there is 0 AMPL. Just curious about it, how could that be done without emiting Transfer or Burn event on behalf of 0xfe6c9c5a0d36eba3a767aaf6df2f335e666a74e7 address? How can I track where 180,588327889 AMPL "disappeared"
The same thing happened in the second in transaction : after sending 1659.518828706 to the address, the balance had to be equal to 1800,697432775 (balance was 141,178604069 before this transaction), but actual balance showing in that block is equal to 1747.184124201
curl -XPOST https://mynode \
--header 'Content-Type: application/json' \
--data-raw '{"jsonrpc": "2.0",
    "id":1,
    "method":"eth_call",
    "params":[{"to":"0xd46ba6d942050d489dbd938a2c909a5d5039a161", "data":"0x70a08231000000000000000000000000fe6c9c5a0d36eba3a767aaf6df2f335e666a74e7"},"0xa3496c"]
    }'

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000000000000000000000000000196cc4a0129"
}

196cc4a0129 is equal to 1747184124201 and AMPL's decimal is 9, so the result is 1747.184124201.
Please someone explain me where this amount of tokens "disappeared".


texts:
I am running into permission issues when I try to install truffle

avi@avi-Inspiron-3542:~$ sudo npm install -g truffle
/usr/bin/truffle -> /usr/lib/node_modules/truffle/build/cli.bundled.js

  keccak@1.4.0 install /usr/lib/node_modules/truffle/node_modules/keccak
  npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."

  keccak@1.4.0 rebuild /usr/lib/node_modules/truffle/node_modules/keccak
  node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/avi/.node-gyp/11.6.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/truffle/node_modules/keccak/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/truffle/node_modules/keccak/.node-gyp'
gyp ERR! System Linux 4.15.0-29-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/truffle/node_modules/keccak
gyp ERR! node -v v11.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/avi/.npm/_logs/2019-01-05T10_04_02_789Z-debug.log
Keccak bindings compilation fail. Pure JS implementation will be used.
+ truffle@5.0.1
added 90 packages from 305 contributors in 7.547s


texts: array.push replacing last value instead of adding to the array

texts:
I am attempting to keep a log of when a user does certain things but when a new log event is reached the second log is overwritten instead of adding a new one to the array I am unsure as to why when push should not replace anything.
struct logger {
 bytes32[] who;
 uint64[]when;
}

mapping(address => logger) log;

function LogEvent( bytes32 _username, address _userAddress, uint64 _timestamp) public{
      log[_userAddress].who.push(_username);
      log[_userAddress].when.push(_timestamp);
}

function getlogs(address _userAddress) view public returns(bytes32[] memory, uint64[] memory){
    return(log[_userAddress].who, log[_userAddress].when);
}


texts: Why does this Oraclize query only works once?

texts:
Why this code works one time? First time I get proper random number, but after that I get wallet response "Data can't be executed, so it will use all provided gas"

I'm in Testnet.

contract Random_number is usingOraclize {
  string public randomNumber;

  function Create_random_number() {
    oraclize_setNetwork(networkID_testnet);
    oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
    oraclize_query("WolframAlpha", "random number between 0 and 100");
  }

  function __callback(bytes32 myid, string result, bytes proof) {
    if (msg.sender != oraclize_cbAddress()) throw;
    randomNumber = result;
  }
}


texts: How does Ethereum cope with division of prime numbers?

texts:
I have seen this question here about representing decimals in solidity, and although of course the answer is that 'msg.value' is always in Wei, this got me thinking about how Ethereum handles division of odd or prime numbers.

For example if I have 481129598370820487 Wei and I need to distribute that amongst several parties, I am going to have a problem.

In addition the Ethereum Converter seems to give up trying to convert 0.481129598370820487 ether into anything, but I'm guessing this is the limitation of front end javascript.

So how does Ethereum solve this?


texts: Decoding signature for verification not working

texts:
I'm trying to verify a signature, but when I decode it, the function reverts. This is the function I'm using
function source(bytes memory signature) public returns (bytes32 r, bytes32 s, uint8 v) {
        (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
    }

The encoded signature looks like this (Im encoding it using web3.eth.abi.encodeParameters) and then making an eth_call
  0000000000000000000000000000000000000000000000000000000000000020
  0000000000000000000000000000000000000000000000000000000000000041
  8318875f720f88683b75c949a1e83fcefbd586ae8a8276944f126cdba176f384
  4b05c92d1b4393dcf1dad2d59b88f196c9aba988141265bdacbfdbc90049fa21
  1c00000000000000000000000000000000000000000000000000000000000000

But if I hardcode the signature into the contract like this It seems to work
function source() public returns (bytes32 r, bytes32 s, uint8 v) {
    bytes memory signature = "0x8318875F720F88683B75C949A1E83FCEFBD586AE8A8276944F126CDBA176F3844B05C92D1B4393DCF1DAD2D59B88F196C9ABA988141265BDACBFDBC90049FA211c";
    (bytes32 r, bytes32 s, uint8 v) = abi.decode(signature, (bytes32, bytes32, uint8));
}

Can someone explain to me what is going on and why it happens this way? Thanks!


texts:
Newbie question. Suppose I have contract X which have a foo function which accepts contract of type Y and calls function bar on it like this.
contract Y
{
 function bar() public;
}

contract X
{
 function foo(Y y) public { y.bar(); }
}

If my understanding is correct then anyone can write contract Z with the same ABI as Y and pass it as a parameter to the contract X's foo function (impersonate Y). If that is correct, is it possible to ensure that only "trusted" contracts are passed as a parameter to the X::foo.


texts: BSC Wallet and all its token amounts/cash balance

texts:
Just started playing with the Blockchain overall. It's pretty hard to get into and understand but trying my best.
I would like to know how I can get all the tokens that the BSC wallet had Contracted with. As from the research I did an address doesn't store all its tokens but rather has 'Contracts' with those tokens where the balance can be retrieved right?
So given I have an address that has 20 Contracts with tokens (20 tokens) How I determine exactly which addresses do I need to look for from this Main Address to get the balances of those tokens.
All I know is the Main Address for which I need to find all Contracts and get balances automatically. I don't want to manually provide each contract address I interacted with in order to get the balance. I want it automatically once the Main Address is posted.
Also, one thing that bothers me. How do I map the retrieved balance of the token to the actual number of coins of that token.
Say :
const tokenABI = [{
  "constant": true,
  "inputs": [
    {
      "name": "_owner",
      "type": "address"
    }
  ],
  "name": "balanceOf",
  "outputs": [
    {
      "name": "balance",
      "type": "uint256"
    }
  ],
  "payable": false,
  "type": "function"
}];

const tokenAdress = '...';

const tokenInst = new web3.eth.Contract(tokenABI, tokenAdress);
const balance2 = tokenInst.methods.balanceOf(walletAddress).call();

balance2.then((result) => {
  console.log(result)
})

This returns me: 725214358783073420
How can I make it: 725 214 358 .783073420
P.S.
I'm keen to use some API provider if there is any good and cheap one that would provide me this data.
All tokens and their amounts/cash value of the Main BSC address.
Current Value of the token


texts:
I am adding to an bytes32[] array via push().

When I traverse the array with for (uint i = 0; i < array.length; i++), This is First in First Out (FIFO) sequence right?

How can one perform a Last in First Out (LIFO)?


texts: Solidity: How to specify a (hard-coded) address as a literal

texts:
I am defining a contract and I want to ensure a particular member variable can only be modified by me. So, specifically I want to ensure that if someone else deploys one of my contracts, then they will not be able to modify this variable.

To do this I tried to hard-code my address, and test against msg.sender in the setter

contract Sample {
  address constant public myAddress = 0xe0f5206bbd039e7b0592d8918820024e2a7437b9;
  uint public vari;
  function setVari(uint a) {
    if(msg.sender == myAddress) {
      vari = a;
    }
  }
}

When I compile this, I get the following error

Warning: This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'.
      address constant public myAddress = 0xe0f5206bbd039e7b0592d8918820024e2a7437b9;
                                          ^----------------------------------------^

And when I try to modify this variable within geth using

myInstance.setVari.sendTransaction(22, {from: eth.accounts[0]})

the value of "vari" is not updated. (Where eth.accounts[0] is the hardcoded address in the source.)

However, if I remove the protection within setVari(), everything works as expected.

This implies to me that everything I'm doing is correct, except the hard-coding of my address.

Can anyone help? How do I hard code my account into a contract?

Thanks!

Note: the address included is one I'm using on a private test network, so you won't be able to find it in the public network. However, I got the same compiler warning when I tried hard-coding one of my real accounts addresses.


texts:
In Mist browser is there an equivalent to ctrl + F5 in other browsers (clear cache and reload all sources)?

I understand it is a fork of Chromium but F5 does not even perform a refresh.


texts:
Other than Oracles writing data into the chain that then can be accessed by all nodes to verify a certain state at a certain time, what other reasons are there for creating transactions without a recipient (no to address)?

https://etherscan.io/address/0x0000000000000000000000000000000000000000


texts: Difference between high gasLimit & low gasPrice, and low gasLimit & high gasPrice

texts:
Just wondering which transaction would take to get mined, for example if two people sent a trade for the same token (not real values);

Person 1: gasLimit set to 100 and gasPrice set to 0.01, max tx cost = 1

Person 2: gasLimit set to 10 and gasPrice set to 0.10, max tx cost = 1

Would there be any difference in which transaction was mined? How do the miners choose which one to take, does it matter which one was submitted first?


texts: Is there a (theoretical) limit for amount of data that a contract can store?

texts:
Is there a theoretical limit to the amount of data that one contract can store while running in a private net in which gas is not a concern?

Context: In a financial Dapp which is to replace global payment systems, tx/s throughput is certainly one limiting factor that is widely discussed. But that is not what I am getting at here. Can a contract store 1GB, 1TB, ... data in a contract? The data would not be written in one go, but rather accumulate over time.

Example: Let's assume a best case scenario in which we manage to squeeze a single transaction of tokens living on top of a smart contract into 100 bytes. At 1000 tps throughput this would yield 100*1000*3600*24*31*12 = 3.2TB/year. Feel free to guess if / when this will be possible.


texts: How can I delete element then return him in function?

texts:
I have function, that goes to return and delete last element from array, but if I delete this element, function could return null value

function poll(Queue storage _queue) public returns(Job job) {
    require(data.length==0);
    require(_queue.length - 1 < cursorPosition);
    _queue.cursorPosition++;
    // there should be element deleting
    return (_queue.jobArray[cursorPosition - 1]);
}


texts: How eth_getStorageAt works when block option is not "latest"?

texts:
For the block parameter of eth_getStorageAt call, we are given 4 options:

  HEX String - an integer block number String "earliest" for the
  earliest/genesis block String "latest" - for the latest mined block
  String "pending" - for the pending state/transactions
  (https://github.com/ethereum/wiki/wiki/JSON-RPC#the-default-block-parameter)

How does Ethereum handle the case when the param is not 'latest'? In other words, how does it manage to retrieve the history storage?


texts: Transferring an ERC-20 using web3js 1.0.0

texts:
I have been trying to follow the web3js documentation, but it mentions things that are not native to Javascript like "Buffer" so I found a library called ethereumjs-tx to let me use that.

My HTML page to test it on has scripts to import web3js-1.0.0 and         browser-ethereumjs-tx.js
I am using Infura as my web3 provider

Here is my function, with addresses and private keys stripped for safety:

async function transferTokens(){
    // example: https://ethereum.stackexchange.com/questions/24828/how-to-send-erc20-token-using-web3-api

    // the ABI of the erc20
    var abi;

    // the token address for the specific token
    var tokenAddr;

    // instantiate the token contract using the ABI and the Contract Address.
    var tokenContract = new web3.eth.Contract(abi, tokenAddr);

    // who has the tokens to be sent?
    var sender;

    // where are the tokens being sent?
    var tokenRecipient = document.getElementById('tokenRecipient').value;

    // how many tokens are being sent?
    var tokenAmount;

    // nonce
    var count = web3.eth.getTransactionCount(sender);

    //set a gas price for the transfer in GWei (I picked 30 arbitrarily).
    var gasPriceGwei = 30;

    var gasLimit = 400000; // arbitrary, I know it's higher than needed

    //Creating a raw Tx...
    var rawTransaction = {
        "from": sender,
        "nonce": "0x" + count.toString(16),
        "gasPrice": gasPriceGwei,
        "gasLimit": gasLimit,
        "to": tokenRecipient,
        "value": "0x0",
        "data": tokenContract.methods.transfer(tokenRecipient, tokenAmount).encodeABI(), // not sure wtf
        "chainId": 0x04 //rinkeby network
    };

    // EthJS allows us a buffer function.
    var privKey = new EthJS.Buffer.Buffer('[my_privKey]', 'hex');

    var tx = new EthJS.Tx(rawTransaction);
    tx.sign(privKey);
    var serializedTx = tx.serialize();

    // Comment out these three lines if you don't really want to send the TX right now
    console.log(`Attempting to send signed tx:  ${serializedTx.toString('hex')}`);
    var receipt =  web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'));
    console.log(`Receipt info:  ${JSON.stringify(receipt, null, '\t')}`);

}

Nothing happens. The console logs:

    TEST.html:134 Attempting to send signed tx:  [a Tx that is 334 characters long]
    TEST.html:136 Receipt info:  {}

When I try to include another function (that I know works) inside transferTokens with console logs, they never get logged. So presumably the function is never executed for some reason. My working function is:

tokenContract.methods.balanceOf(sender).call(function(err, bal){
    console.log("LOG X");
    if(!err){
        bal = web3.utils.fromWei(bal, 'ether');
        console.log("sender bal: "+bal);
        document.getElementById('balBeforeSending').innerHTML
        = "The balance of "+ document.getElementById('tokenTransfer').options[document.getElementById('tokenTransfer').selectedIndex].innerHTML
            + " before sending " + sender + " was: "
            + bal;
    }
    else{
        console.log("line 106");
        console.error(err);
    }
});

I have placed it just before the "creating Raw Transaction" line in the original function.

I had await on both the count and the receipt previously but they never got logged so I thought I would remove them. The program was stuck waiting for them but never got anything back so I believe nothing after the await was executed.


texts: How to load external JavaScript files into app.js - Truffle?

texts:
I am new to truffle and webpack. Currently, I am writing all my code into this one app.js file. Suppose I would like to have an external js file which is used to do some initializations.

Currently, my app.js is something like:

// Import libraries we need.
import { default as Web3} from 'web3';
import { default as contract } from 'truffle-contract'

// Import our contract artifacts and turn them into usable abstractions.
import user_artifacts from '../../build/contracts/User.json';
var User = contract(user_artifacts);
var accounts;
var g, c;

window.App = {
  start: function() {
    var self = this;
    User.setProvider(web3.currentProvider);

    web3.eth.getAccounts(function(err, accs){
      if (err) {
        alert("Error loading accounts");
        return;
      }
      if (accs.length == 0) {
        alert("Couldn't get any accounts! Make sure your Ethereum client is configured correctly.");
        return;
      }
      accounts = accs;
    });

    // Load/Initiatize these variables from an external js files
    g = document.getElementById("government-register");
    c = document.getElementById("customer-register");
  },
};
window.addEventListener('load', function() {
    window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

App.start();
});

I want to load the variables g & c from an external js file and use them anywhere in app.js. Similarly how to use functions from an external js file in app.js.


texts: Display tokem amount in dollar in dApp frontEnd

texts:
How do I return token amount in USD using web3js ..or is there some kindof API to be used ?
For instance , say user has 3ETH and also want the user balance to show in USD just as metamask does


texts: Can a solidity event be logged successfully before a throw?

texts:
If I have the following code in a solidity contract function:

event_logEvent();
throw;

Does the event get logged correctly into the blockchain or does the throw also revert all the events?


texts: I don't seem to have a parity folder in appdata/roaming called parity. Does anyone know where parity places keys on Windows?


texts: Solidity: Can't access mapping when using array as ValueType

texts:
This contract allows users to checkin and stores last time it occurred:

pragma solidity ^0.4.18;

contract DSquare {

    mapping (address => uint) public checkins;

    function checkin() public {
        require(now - checkins[msg.sender] > 1 minutes);

        checkins[msg.sender] = now;
    }
}

In a second version intending to store all user's checkins, I've changed the ValueType from uint to uint[] resulting in this contract:

pragma solidity ^0.4.18;

contract DSquare {

    mapping (address => uint[]) public checkins;

    function checkin() public {
        uint[] storage userCheckins = checkins[msg.sender];
        if (userCheckins.length > 0) {
          require(now - userCheckins[userCheckins.length - 1] > 1 minutes);
        }

        userCheckins.push(now);
    }
}

After that I can't call the get function anymore. Using web3, it shows: "Uncaught Error: Invalid number of parameters for "checkins". Got 1 expected 2"

In the JSON file generated by Truffle I can see that it really has a second parameter:

"abi": [
    {
      "constant": true,
      "inputs": [
        {
          "name": "",
          "type": "address"
        },
        {
          "name": "",
          "type": "uint256"
        }
      ],
      "name": "checkins",
      "outputs": [
        {
          "name": "",
          "type": "uint256"
        }
      ]

(The full JSON is here: https://gist.github.com/saulobrito/ebdd40dd610da23ece1c97c4c912b492)

Same thing on Remix. That's how it shows the first contract:

And here the second version:

Is this a bug? Shouldn't the get function depend only of the key? Any thoughts how working around it?

Thanks!


texts: MEW keeps putting in QSP contract address for receiver instead of address I've entered

texts: I'm trying to send Quantstamp (QSP) to Binance offline, using MyEtherWallet. In mew's offline helper... when I paste in the signed transaction (into the online MEW, as received by offline version of mew) it keeps saying receiver is the QSP contract address - not the binance address (as supplied to me by Binance). The sender is correct (my mew wallet) - but not the receiver. Is that supposed to happen?


texts: Unable to get value from synchrous function but able to get value from synchronous function using truffle

texts:
Following asynchronous function call returns value of total votes in variable v correctly

return GlobalcontractInstance.totalVotesFor.call(candidateName).then(function(v) {
$("#" + div_id).html(v.toString());
$("#msg").html("");
});

But following synchrounous function does not return value in no_of_votes.

no_of_votes = GlobalcontractInstance.totalVotesFor.call(candidateName);
$("#" + div_id).html(JSON.stringify(no_of_votes));

I am not able to figure out why it is happening so ?
What is preferable way to call a smart contract functions?


texts: Is it safe and effective to use 128 bit integers to track wei in a contract in order to save gas?

texts:
The default type for Wei in Solidity is the 256 bit unsigned integer.  (e.g. msg.value)

However, to track 1.7e38 wei (1.7e20 ether) you only need a 127 bit integer.  That's a gigantic number not likely to be exceeded in any real world application.

As long as you are not multiplying two Wei values together, is it considered reasonably safe to track Wei in signed 128 bit integers so that two values can be packed into one 256 bit word in order save storage costs on gas?

Are there additional computational costs on half word arithmetic that might significantly eat up the gas savings?


texts:
someone know what the opcode CALLVALUE is for?
I would like to understand it well.
Have you an example on which I can easily understand it?


texts: Mapping with array as Key Or Value data type

texts:
Is it possible to do a mapping with an Array as key/value ? Where an array would exist for each value ?

I'm actually looking to store structs in a mapping but can't seem to have it work.

Struct Foo{
uint x
}

mapping(uint => Foo[])foo; and even simply
mapping([] => uint)foo / (uint => [])foo; don't seems to work.

something so i can do :

foo.1.push(FooInstance)

foo.1[0] = FooInstance

Solidity Doc reads

  Mapping types are declared as mapping _KeyType => _ValueType, where _KeyType can be almost any type except for a mapping and _ValueType can actually be any type, including mappings.

So aren't array considered a data type in solidity?


texts:
Here ether scan links to failed transactions :

last failed attempt : etherscan link
others : etherscan link
traced view of contract calls etherscan link (you may just change the tx hash on the URL to view other failed tx's in detail)

The contract call falls into gas error. It is basically chains of contracts making calls to one and another. As we have dig into the problem, we've seen that it fails on the method below.
Launchpad.sol go to contract
    /**
    * @dev Function to setup liquidity and transfer all amounts according to defined percents, if softcap not reached set Refunded flag.
    */
    function setupLiquidity() public onlyOwner {
        require(_isSoldOut == true || block.timestamp > _end , "LaunchpadToken: not sold out or time not elapsed yet" );
        require(_isRefunded == false, "Launchpad: refunded is activated");
        require(_isLiquiditySetup == false, "Setup has already been completed");
        _isLiquiditySetup = true;
        if(_raisedETH < _softCap){
            _isRefunded = true;
            return;
        }
        uint256 ethBalance = address(this).balance;
        require(ethBalance > 0, "LaunchpadToken: eth balance needs to be above zero" );
        uint256 liquidityAmount = ethBalance.mul(_liquidityPercent).div(_totalPercent);
        uint256 tokensAmount = _token.balanceOf(address(this));
        require(tokensAmount >= liquidityAmount.mul(_BASE_PRICE).div(_priceUniInv), "Launchpad: Not sufficient tokens amount");
        uint256 teamAmount = ethBalance.mul(_teamPercent).div(_totalPercent);
        uint256 layerFeeAmount = ethBalance.mul(_fee3).div(_totalPercent);
        uint256 supportFeeAmount = ethBalance.mul(_fee1).div(_totalPercent);
        uint256 stakeFeeAmount = ethBalance.mul(_fee1).div(_totalPercent);
        payable(_layerFeeAddress).transfer(layerFeeAmount);
        payable(_supportFeeAddress).transfer(supportFeeAmount);
        payable(_stakeFeeAddress).transfer(stakeFeeAmount);
        payable(_teamWallet).transfer(teamAmount);
        payable(_liquidityCreator).transfer(liquidityAmount);
        _token.safeTransfer(address(_liquidityCreator), liquidityAmount.mul(_BASE_PRICE).div(_priceUniInv));
    }

Somehow, it works on testnet; but fails on mainnet.

Testnet contract : link
Testnet success transaction with setupLiquidity() call. link

Theories are;

Chained contract calls have a higher gas limit requirement, the highest attempt so far is with 666,666 gas limit but it still fails. Maybe a number of investors caused this, as on testnet very few of them exist. If this is the case, how can we estimate the required gas limit?

Contract triggered transactions use 2300 gas, no matter how much gas limit initiator transaction has. That looks weird too.

Contracts :

Launchpad 1
LayerX
BETFI
ProxyChiCaller


texts:
In my truffle project I have around 10 contracts. I have created a deployment script, but I also need to initialize the contracts further. EG. Transfer some funds into certain contracts and setup my registry contract with the addresses of the other contracts.

What is the best practice for this? Should I include this setup code in my deployment script in the migration folder? I'm assuming there's a better option I'm just not aware of.


texts:
I am trying to send ether on private network. from chain1 to chain2.
But it does not proceed. (But no error occures.)

> eth.getBalance(eth.accounts[1])
4999580000000000000

> eth.getBalance(eth.accounts[2])

0

I unlocked my account too...

> personal.unlockAccount(eth.accounts[1])
Unlock account 0xddc25843a212978640dedb119b9720f38da50d09
Passphrase:
true

Transaction from the chain1 to the chain2

eth.sendTransaction({from: eth.accounts[1], to: eth.accounts[2], value: web3.toWei(2, "ether")})
"0x876cdad3f665434816a531f2bd303414d8c72b16339d6ff84f22ecafd354e666"

It looks like the transaction has been processed but..

> eth.getBalance(eth.accounts[2])
0

It did not..


texts: Is there a way to obtain the same Hash using Keccak256 from Web3 and ZoKrates hash function such as sha256packed?

texts:
I am trying to use the hash obtained from keccak256 (applied to a number or input) and using it into sha256packet from ZoKrates (or other function) for comparing it with the Hash obtained in Zokrates for the same input. Is there a way at least for obtaining the same return value of this function from keccak256?

Thanks in advance.


texts: How to find whether a call in debug trace has out of gas error?

texts: In the debug trace of a transaction collected using debug_traceTransaction, how can we know that an internal call was terminated because of out of gas error? Specifically, when a send() is used to transfer ether to another contract while the contract contains complex code in the fallback functions. Since 2300 gas is allocated for the send() call, the call would fail due to out of gas. But I was unable to see any error in the trace, the call simply terminated and went back to the previous call stack.


texts: Rookie Question on ETH Transferred 2+ Years Ago

texts: I was active a few years ago but haven't touched my crypto for 2 years+. I had ETH on Coinbase and then transferred it to my Ledger Nano S. I accessed by Ledger (I have my private key and everything) but it's now showing a zero balance on Ledger Live. I have the address that Coinbase sent my crypto to over 2 years ago and Etherscan and Ethplorer are showing that the ETH balance is still in the recipient address. Etherscan shows that it was a successful transaction. So it seems like my ETH is parked somewhere other than my Ledger wallet but I can't access it. I'm fairly novice here so any guidance on what I might be screwing up would be appreciated!


texts: Debit a user's wallet on a blockchain without its validation?

texts:
Can we debit the wallet of a user on a blockchain without its validation each time.

For example, I can take a subscription on a site with my credit card and they debit an amount at the end of the month without that I have to validate these transactions. Is there a way to debit a user's wallet on a blockchain by using the smart contract.

Thanks already for your answers.


texts: Can't transfer value from mapping inside mapping

texts:
The title of this issue might seem strange because I can't figure out exactly what the problem is.  But here is what is happening:

pragma solidity ^0.4.13;

contract Escrow {
  address public owner;
  uint public fee;

  //Balances temporarily made public for testing; to be removed
  mapping (address =>  mapping (address => uint)) public balances;

  function Escrow() public {
    owner = msg.sender;
  }

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

  //Fee should be set in PPM
  function setFee(uint price) onlyOwner external {
    fee = price;
  }

  function start(address payee) payable external {
    balances[msg.sender][payee] = balances[msg.sender][payee] + msg.value;
  }

  function end(address payer, address payee) onlyOwner external {
    uint value = balances[payer][payee];
    //uint paidFee = value / (1000000 / fee);
    //uint payment = value - paidFee;
    //payee.transfer(payment);
    //owner.transfer(paidFee);
    //balances[payer][payee] = 0
    payee.transfer(value)
  }
}

I've commented out a bunch of lines that I would like to get working in the end function, because I can't get even the other parts working.

Steps:

Creat contract from first address in testRPC
I call start, from the second address in my testRPC, sending 2 ETH,
to the last address: start("0xb631fc401038e191fa38c4ff20dcce8d13eb6ebc" , { from "0x1c34d277b51ec49536fe7843e289933e0f8020ed", value: 2000000000000000000000 })
I check: balances("0x1c34d277b51ec49536fe7843e289933e0f8020ed", "0xb631fc401038e191fa38c4ff20dcce8d13eb6ebc"), I see 0: uint256: 2000000000000000000 --So far so good.
This is where I get into trouble.  If I call end("0x1c34d277b51ec49536fe7843e289933e0f8020ed", "0xb631fc401038e191fa38c4ff20dcce8d13eb6ebc"), I get: transact to Escrow.end errored: VM Exception while processing transaction: out of gas

If I change end to just return balances[payer][payee], I get 0.

If I change end to just transfer 1 ETH to payee, I get a gas error.

So I can't figure out what the source of this issue is.  Can you give any advice?


texts: Initiate a transaction from within a constant function

texts:
Good day,

I know that using a constant function means that no change will be done on the blockchain, but I'd like to have a smart contract that verifies the user input WITHOUT exposing what the input is unless it matches specific criteria. You can see in the following example that no number below 5 should be accepted.

contract Try{

    uint public num;

    function changeNum(uint _num){
        num = _num;
    }

    function cool(uint _num) constant {
        if (_num > 5){
            changeNum(_num + 2);
        }
    }
}

I don't want to use a modifier since it's still possible to produce a signed transaction that will contain an invalid input, it will simply be rejected by the other nodes.
I want to have it so that the user will be allowed to insert whichever number they like to the cool function, and only if the number is above 5, a transaction (containing the final input of _num + 2) will be signed and transmitted.

I'll appreciate any input you might have on how to achieve this behavior using only the EVM.


texts: Does a storage array have a unique address on the block-chain?

texts:
The question in the title is a little vague, so I will try to explain here.

Suppose I have a contract with a storage array:

pragma solidity 0.4.24;

contract MyContract {
    uint256[10] public myArray;

    constructor() public {
        myArray[0] = ...;
        myArray[1] = ...;
        myArray[2] = ...;
        myArray[3] = ...;
        myArray[4] = ...;
        myArray[5] = ...;
        myArray[6] = ...;
        myArray[7] = ...;
        myArray[8] = ...;
        myArray[9] = ...;
    }
}

When I deploy this contract, can we say that myArray is allocated at a specific address, and that myArray occupies a consecutive memory block (in the example above, a block of 320 bytes) starting at that address?

If yes, is it guaranteed that no other state variable will reside at the same address range, and overlap that memory block (fully or partially)?

If the answer to all of the questions above is yes, how can I obtain the address-space (or at least the base-address) of myArray in Solidity?

The equivalence in native languages like C or C++, when applied in Solidity, would be something like address(myArray), I haven't tried it, but I'm pretty sure it won't work.

Thank you!


texts: How to do a migration of an old token to a new token?

texts:
I’m actually working to a smart contract where I migrate an old token to a new token :
First I need to mint with conversion 1:1 and then burn the old token.
I start with this contract but I’m not sure about it :
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import Token from "../Token.sol";

contract MigrationToken {

  // Old Token
  address public tokenV1;

  // New Token
  address public tokenv2;

  // Burn Address
  address public burnAddress = 0x000000000000000000000000000000000000dEaD;

  uint256 public endBlock;

  constructor(
    address _tokenV1,
    address _tokenV2,
    uint256 _endBlock

  ) public {
    tokenV1 = _tokenV1;
    tokenv2 = _tokenV2;
    endBlock = _endBlock;
  }

  event MigrateToV2(address indexed user,uint256 amount);

  function migratationNewToken(uint256 _inputAmt) public {

    require(block.number < endBlock, "too late :(");
    IERC20(tokenV1).safeTransferFrom(
      address(msg.sender),
      burnAddress,
      _inputAmt
    );

    Token(tokenv2).mint(msg.sender, _inputAmt);
    emit MigrateToV2(msg.sender,_inputAmt);
  }

}


texts: How to initiate ethereum transaction in HD wallets using python?

texts:
I've managed to generate HD wallet for ethereum where I have Master Key, xpriv, xpub (156 in lengh) keys but for signing a transaction I need private key of address(64 Characters).

How could we generate a private key from the xpriv?

Or how to initiate a transaction with xpriv?


texts: Is an accurate clock really required to participate in the Ethereum network?

texts:
The Ethereum documentation states:

https://github.com/ethereum/homestead-guide/blob/master/source/network/connecting-to-the-network.rst#static-nodes-trusted-nodes-and-boot-nodes

  "An accurate clock is required to participate in the Ethereum network.
  Check your OS for how to resync your clock (example sudo ntpdate -s
  time.nist.gov) because even 12 seconds too fast can lead to 0 peers."

Is this accurate clock requirement actually enforced? I have tested connecting with geth using a clock one day behind the NTP provided time and geth appears to be able to connect to other peers. I was expecting the other nodes to automatically disconnect if the accurate clock requirement was enforced.

Here is the geth version I am using:

$ geth version
Geth
Version: 1.6.0-unstable
Git Commit: cc303017c3f145441e583b5bb10ee3070b44cc50
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8
OS: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.8/libexec


texts: I have a ParserError here "function Stratus(string _greeting) {"

texts:
pragma solidity ^0.4.19;

contract Stratus {

    string public greeting;
    address public owner;

    event GreetingChanged (string oldGreeting, string newGreeting)

    function Stratus(string _greeting) {
        greeting = _greeting;
        owner = msg.sender;
    }

    function setGreeting (string _greeting){
        require(owner == msg.sender)
        GreetingChanged(greeting,_greeting)
        greeting = _greeting
        }
    }


texts: How to deploy Smart Contracts With Web3 Using Async/Await?

texts:
This is my Javascript code. I keep getting an error that states

  Error: No privateKey given to the TransactionSigner.
      at TransactionSigner._callee$ (/Users/payton/WebstormProjects/Esgro_DAPP/node_modules/web3-eth/dist/web3-eth.cjs.js:53:23)
      at tryCatch (/Users/payton/WebstormProjects/Esgro_DAPP/node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (/Users/payton/WebstormProjects/Esgro_DAPP/node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype. [as next] (/Users/payton/WebstormProjects/Esgro_DAPP/node_modules/regenerator-runtime/runtime.js:97:21)

I am using node 12.1.0 & web3^1.0.0-beta.55

 const contract = new web3.eth.Contract(_ABI);

   web3.eth.accounts.wallet.add({
        address:_publicKey,
        privateKey: _privateKey.toString()
    });
    const contract_Instance = await contract.deploy({
        data: _bytecode,
        arguments: _constructor_args})
        .send({
        from: _adminAddress,
        gas: 1500000,
        gasPrice: '20000000000'
    });

What am I doing wrong here?


texts:
What is a "51% spawn camp attack", and is it any different from a normal 51% attack. Saw this mentioned in this tweet from Vitalik.

Is there a distinction that I am missing?


texts: Contract and the transaction that creates the contract

texts: Are those different? Blockchain is a list of transactions bundled into blocks. Thus, it is clear that all transactions are recorded in the blockchain. But then where are the contracts stored?


texts: I have been following tutorials for making ERC20 tokens. All of the tutorials create a pre-mined token with a set supply, and the creator gets of those coins their wallet immediately upon creation (to be sent out to others in an airdrop I suppose). There is never any mention of how to make the coins mineable. Is this possible and how do I go about it?


texts:
I am using open-ethereum-pool for creating the ethereum mining pool over an private ethereum network . but it always give me no. of miners in pool are 0 . How do i add miners in the pool , I do not want to add any hardwares to work as miners . This task is only for testing and learning purpose . I want to use only geth nodes to work as miners or in other words CPU miners .
Please do correct me if i am wrong in my approach


texts: How do I startup geth to allow incoming work from an ASIC miner?

texts:
Github only shows options for GPU and CPU mining.  I would like to point an ASIC at my geth node.
Does anyone know how that's done?  Other pools will accept connections such as:
stratum+tcp://eth.pool.com:6666   and you give a username (such as your ETH address), and a meaningless password.
Running the latest version of geth on ubuntu, fully synced.


texts: How do I get product/parcelID from particular Assigned address using struct and mapping?

texts:
struct Sellers{
    address sellerAddress;
    uint parcelId;
    uint parcelPrice;
}

In this struct I've entered multiple parcel Ids to sellerAddress and I've retreived them using _sellerAddress.

But Now I want to retreive SellerAddress from ParcelId?

What is the exact logic for it?


texts: Is KYC required for all token sale by law?

texts:
I was told that KYC is required by law in most countries. We were Australia based, where ICO should be legal.

Do we need KYC for token sale on our website? Or it's depeneds on the country buyer currently in? What's the worst case if I don't have an KYC, e.g. website will be blocked in China?

While I cannot find a KYC in Loom's website token sale, is that because they are Bangkok based and able to bypass that? Seems china government havn't done anything to them yet?


texts: Not able to Get the response from the function call from Node Js Service Using Web3@1.0.0-beta.36

texts:
I am deploying two contracts A and B using Web3(1.0) and solc.
My Solidity file looks something like this:

pragma solidity ^0.4.21;

contract A {
   uint public value;
   constructor(uint newValue) public {
        value = newValue;
   }
}

contract B {
   A aObj;

   function setAddress(address _a) public {
       aObj = A(_a);
   }

   //Get Value Function to Return Value
   function getValue() public view returns(uint) {
       return aObj.value();
   }
}

I am trying to call the method getValue() from Node JS Service as shown below:

    //GET Call to Get Value from Contract
app.get("/showMeValue",(req, res) => {
   var contractInstance = new web3.eth.Contract(contractDataB.fileAbiDataContractB,contractAddressB);
   var calculatedGasPrice;
   utils.getGasPrice().then(function(response)
   {
       if(response)
       {
           calculatedGasPrice = response;
           console.log("Calculated Gas Price: "+calculatedGasPrice);
           contractInstance.methods.setAddress(contractAddressA).estimateGas({from: accountAddress}).then(function(gasAmount){
               if(gasAmount <= 2000000)
               {
                   console.log("Gas Amount for Function: "+gasAmount);
                   contractInstance.methods.setAddress(contractAddressA).send({from: accountAddress,gas: gasAmount,gasPrice: web3.utils.toWei(calculatedGasPrice,"Gwei")}).then(function(receipt) {
                       if(receipt) {
                         contractInstance.methods.getValue().call({from: accountAddress}).then(function(response){
                               res.json({"Value":response});
                           }).catch(function(err){
                               console.log(err);
                               res.json({"Error Getting Value":err});
                           });
                       } else {
                           res.json({"Error":"Transaction Not Executed"});
                       }
                   }).catch(function(err){
                       console.log(err);
                       res.json({"Error Setting Address":err});
                   });
               }
           }).catch(function(err){
               res.json({"Error Getting Gas Estimation for Function":err});
           });
       }
   }).catch(function(error){
       res.json({"Error Getting Gas Price":error});
   });
});

utils is the module created with functions and their promise resolution as I don't want my server file to be too messy.

The Problem what I am facing here is when it calls the function getValue() it gives me an error stating:

Response Values Are Not Correct. Did it run out of Gas ?

I have been looking for solution and accordingly mentioned the byzantiumBlock:0 in my genesis.

Still I am facing the issue.

I have tried making two separate contracts and deploying them and then providing the definition of one in the other contract but still the error remains the same.
PS: Everything works smooth in Remix IDE (may be ability to vary gas accordingly).

Does it have anything to do with the gasLimit I have mentioned while setting my local block-chain.

Would like the inputs on this.


texts: The Ether denominations are called Finney, Szabo, and Wei. What/who are these named after?

texts:
This was recently asked on Reddit.

To expand, who are Finney, Szabo, and Wei, and what did they do/contribute to the project that warranted being awarded denominations?


texts: How can I configure node when I run truffle test?

texts:
How can I get truffle test to execute node with the --abort-on-uncaught-exception option?

I'm guessing that I should probably add something in the Truffle's configuration file (truffle.js), but the docs don't say anything about this.

Thank you!!!


texts: Hello. I have a problem with a smart contract transaction between users. Error: gas is missing

texts:
I have a problem with a smart contract transaction between users. Error: gas is missing.
Here is my function:

async function transactionContract() {

  let signerAddress = gettingOwnerByKey(
    "privateKey"
  ).address;

  let addressRecipient = "0x82A8AD5c429903c082686a307083330F99c40E53";

  const escrow = new web3.eth.Contract(
    ABI2,
    "0xF36198Ce8Dfe6A5694541bb1604195A7b9E2A61D",
    {
      from: "0x061A96C2b5A18b132783bF65a45BC720e6C95b2A",
    }
  );
  const NET_ID = "35855456";

  let tx = await escrow.methods.shifting(addressRecipient).encodeABI({
    chainId: NET_ID,
    gas: "320000",
    gasPrice: web3.utils.toWei("42", "gwei"),
    nonce:  web3.eth.getTransactionCount(signerAddress, "pending"),
  });

  const signedContract = await web3.eth.accounts.signTransaction(
    tx,
    "privateKey"
  );

  const transactionSignature = await web3.eth.sendSignedTransaction(
    signedContract.rawTransaction
  );
  console.log(transactionSignature)
}

I cannot understand why it will result in an error - "gas is missing"!


texts: How to print web3.eth. output on html page?

texts:
I am trying to print web3.eth.<function> output on a html page, but I cannot print it.

I have followed this answer. My geth-node is running on --rpcport 8545.

Let's see simple example to print blockNumber.

example.html

Get Block Number:
 <button onclick="getblocknumber()">Get Block Number </button>

myserver.js

var express = require('express');
var app = express();
var bodyParser = require('body-parser');

// Create application/x-www-form-urlencoded parser
var urlencodedParser = bodyParser.urlencoded({ extended: false })

app.use(express.static('.'));

var server = app.listen(8081, function () {

  var host = server.address().address
  var port = server.address().port

  console.log("Example app listening at http://%s:%s", host, port)

})

To run:

$ node myserver.js
Example app listening at http://:::8081

To open; from browser: http://localhost:8081/example.html


texts:
I am trying to test and deploy my contract using the latest ganache-cli v6.0.3 (ganache-core: 2.0.2) with Remix (http! version) on http://remix.ethereum.org.
So, after starting ganache-cli without any extra parameters on standard port 8545, I connect on Remix via web3 Provider http://127.0.0.1:8545 and my accounts show up, as displayed by Ganache.

This is the contract I want to deploy:

pragma solidity ^0.4.20;

contract Test {

    uint[4] public arr; // [0,0,0,0]
    event TestLog(string logmessage);

    function Test() public {
        arr[0] = 1; // [1,0,0,0]
    }

    function checkArray() public {
        if(arr[0] == 1) { // arr == [1,?,?,?]
            arr[1] = 1;
            arr[0] = 0; // switch values [0,1,0,0]
        }
        TestLog("some log");
    }

}

It works fine with the in-built Javascript VM in Remix: [vm] from:0xca3...a733c, to:Test.checkArray() 0x692...77b3a, value:0 wei, data:0x7b3...f7296, 1 logs, hash:0xa6f...87209

If i try to run the checkArray function in Remix connected to ganache via web3 Provider, I get an transact to Test.checkArray errored: VM Exception while processing transaction: out of gas error.

What am I doing wrong here? Bumping up gasLimit with ganache-cli -l 5000000did not help, as well as even higher values and a follow up test with a very small gasPrice and high gas limit. Is it a Remix problem setting wrong gas limits on the Remix website when building the transaction? I also tried it on a private geth node with the same result: out of gas...

Any help gladly appreciated!


texts: Why does gas rise when the require will fail?

texts:
Here is the contract, function being called is voteForCharacter:

pragma solidity ^0.4.19;

contract CharacterEveryDay {

event CharacterSelected(uint8 _character, uint64[256] characterVotes, uint64 day);

uint64[256] public characterVotes;

uint8 public winningCharacter;
uint64 public day;
uint256 public winningCharacterVotes;
uint256 public timeOfLastVote;

mapping (uint256 => bool) addressVotedToday;

constructor (uint8 _character) public {
    day = 0;
    winningCharacterVotes = 0;
    timeOfLastVote = now;
    voteForCharacter(_character);
}

modifier onlyCharacter(uint256 _character) {
    require(_character < 256);
    _;
}

function voteForCharacter(uint256 _character) public onlyCharacter(_character) {
    if ((now - timeOfLastVote) > 1 days) {
        selectCharacter(winningCharacter);
    }

    uint256 todaysAddressHash = uint(keccak256(abi.encodePacked(day, msg.sender)));
    require(addressVotedToday[todaysAddressHash] == false);

    characterVotes[_character]++;
    if (characterVotes[_character] > winningCharacterVotes) {
        winningCharacter = uint8(_character);
        winningCharacterVotes = characterVotes[_character];
    }
    addressVotedToday[todaysAddressHash] = true;
    timeOfLastVote = now;
}

function getCharacterVotes() external view returns (uint64[256]) {
    return characterVotes;
}

function selectCharacter (uint8 _winningCharacter) private {
    day += uint64((now - timeOfLastVote) / 1 days);
    emit CharacterSelected(_winningCharacter, characterVotes, day);
    delete characterVotes;
    delete winningCharacter;
    delete winningCharacterVotes;
}
}

FROM WEB3:

When I run it for the first time in a day, when the require passes:

require(addressVotedToday[todaysAddressHash] == false);

the gas estimate on MetaMask is reasonable and the functions succeeds:
0.000294 eth ($.05)

If I run it again in the same day with the same address, which means the require will fail, the gas cost becomes unreasonable:
2850000 eth ($500 millionish)

If I use a different address on the same day, the gas estimate becomes reasonable.

FROM REMIX:

The gas estimate stays reasonable, but after the first vote the function will fail not because the require fails, but because it runs out of gas.


texts: How do uncle blocks affect Ethereum world state?

texts:
Let's say you have two miners: A and B.

Let's also say you have two transactions: one which increases a number at a smart contract by one (transaction X), and another which decreases the same number by one (transaction Y).

Miner A mines a block containing transaction X.

Miner B mines a block containing transaction Y.

So Miner A's view is that the smart contract number has incremented, and miner B's view is that the number has decremented. They have both updated the state of the address in their respective EVMs.

These blocks are broadcasted and nodes update their smart contract state accordingly. Eventually, let's say consensus is reached and Miner A comes out the "winner".

Are the state updates from Miner B then "rolled back" and the state update from Miner B applied?


texts: How to call Base contract function externally when only Derived contract deployed

texts:
Base

pragma solidity ^0.4.18;

contract ZombieFactory {

    event NewZombie(uint zombieId, string name, uint dna);

    uint dnaDigits = 16;
    uint dnaModulus = 10 ** dnaDigits;

    struct Zombie {
        string name;
        uint dna;
    }

    Zombie[] public zombies;

    mapping (uint => address) public zombieToOwner;
    mapping (address => uint) ownerZombieCount;

    function _createZombie(string _name, uint _dna) internal {
        uint id = zombies.push(Zombie(_name, _dna)) - 1;
        zombieToOwner[id] = msg.sender;
        ownerZombieCount[msg.sender]++;
        NewZombie(id, _name, _dna);
    }

    function _generateRandomDna(string _str) private view returns (uint) {
        uint rand = uint(keccak256(_str));
        return rand % dnaModulus;
    }

    function createRandomZombie(string _name) public {
        require(ownerZombieCount[msg.sender] == 0);
        uint randDna = _generateRandomDna(_name);
        randDna = randDna - randDna % 100;
        _createZombie(_name, randDna);
    }

    function getZombieDnaById(uint _id) public view returns (uint) {
        return zombies[_id].dna;
    }

    function getZombieCount() public pure returns (uint) {
        //return ownerZombieCount[msg.sender];
        return 6789;
    }

}

Derived

pragma solidity ^0.4.18;

import "./ZombieFactory.sol";

contract KittyInterface {
  function getKitty(uint256 _id) external view returns (
    bool isGestating,
    bool isReady,
    uint256 cooldownIndex,
    uint256 nextActionAt,
    uint256 siringWithId,
    uint256 birthTime,
    uint256 matronId,
    uint256 sireId,
    uint256 generation,
    uint256 genes
  );
}

contract ZombieFeeding is ZombieFactory {

  address ckAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;
  KittyInterface kittyContract = KittyInterface(ckAddress);

  // Modify function definition here:
  function feedAndMultiply(uint _zombieId, uint _targetDna) public {
    require(msg.sender == zombieToOwner[_zombieId]);
    Zombie storage myZombie = zombies[_zombieId];
    _targetDna = _targetDna % dnaModulus;
    uint newDna = (myZombie.dna + _targetDna) / 2;
    // Add an if statement here
    _createZombie("NoName", newDna);
  }

  function feedOnKitty(uint _zombieId, uint _kittyId) public {
    uint kittyDna;
    (,,,,,,,,,kittyDna) = kittyContract.getKitty(_kittyId);
    // And modify function call here:
    feedAndMultiply(_zombieId, kittyDna);
  }
}

2_deploy_contracts.js

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

module.exports = function(deployer) {
  deployer.deploy(ZombieFeeding);
};

app.js

CryptoZombiesFeeding.deployed().then(function(contractInstance){

  console.log(contractInstance);

  // call getZombieCount() of Base contract ZombieFactory.sol
  contractInstance.getZombieCount.call().then(function(zombieCount){
    console.log("address " + account + " has " + zombieCount + " zombies");
  });

});

Commands

truffle migrate --reset

Everything builds ok, the contract ZombieFeeding is migrated successfully, and the contents of the contract instance in the client application contains both the parent and derived function references.

The problem is that when I call the getZombieCount function it returns 0, and it should be 6789. If I deploy the ZombieFactory contract alongside the ZombieFeeding contract it works. This shows me that when I use inheritance, the parent contracts functions can't be called.


texts: Does solcjs replace solc? Is there a wrapper for the differences?

texts:
It at least appears to me that "solc" (the executable) doesn't exist anymore. Installing "solc" with nmp results in a command-line tool called solcjs ... fine, but they seem to have slightly different interfaces. And there are tools that wrap solc/solcjs that are broken by this.
Geth's abigen appears to be one of them. I get the following when I try to use it:
$ abigen --sol=Foo.sol --pkg=main --out=foo.go
Fatal: Failed to build Solidity contract: solc: exit status 1
Invalid option selected, must specify either --bin or --abi

Which is true! But it looks like I'm faced with either creating/finding a solc wrapper or updating abigen (which is also fine, but I'm looking for direction so I don't waste too much time.)
Or am I not looking hard enough for solc?


texts:
I have problems updating truffle. I run the command "truffle --version" and i got truffle version 4.0.1 and solc version 0.4.18. So i wanted to upgrade to 4.1.6 which is the latest version. I run "sudo npm uninstall -g truffle" and then i run the command "sudo npm install -g truffle". After that i run "truffle version" and i got again 4.0.1 and solc 0.4.18. Does anyone know why i can not update to latest version? Basically i am intrested in updating solc version to latest 0.4.22 but after some search i found out i have to update truffle in order to update solc compiler.

Fixed: After i restarted the pc, truffle was updated. Also as Med Mansour commended below maybe a restart wasn't neseccary and it was just needed to close the cmd or terminal and open a new one.


texts: Can an ethereum contract hold ether for a group

texts:
I'm struggling to understand what can be accomplished with smart contracts.  Can they actually hold (or force a transfer at completion of) ether?  Could they work almost like an escrow account?  Or would that require a "trusted" wallet to hold the funds until the contract completed?

Would it be more feasible to try to create your own tokens and allow them to be redeemed? My understanding is this would work, but would still require a "master account" to be manually held on the "honor system".


texts: how to get(catch) returned value from function that changes state, in front-end

texts:
contract test{
function test1(string memory _name) public returns(address)
uint tempData = uint (keccak256(abi.encodePacked(_name,block.timestamp)));
address batchNo = address(tempData);
return batchNo;
}
when call this function using .call() it returns value but not getting written blockchain and when i call this function using .send() it get written on blockchain but not returning that value;
//how to catch this value in front end???


texts: Can ETH be shifted within the Ethereum Wallet into an established ERC-20 token without fees?

texts: I have watch token accounts for various ERC-20 tokens within my Ethereum Wallet. Is it possible to send Eth to any of these token accounts within the wallet that would increase my token holdings within that watched token?


texts: Buyer sends ether to seller address in exchange for NFT (ERC-721) minted by seller

texts:
The scenario is that the contract has been deployed to the blockchain and the NFT is minted. Two questions:

how do you implement in solidity the ability to give ownership of the NFT to the buyer in exchange for a specific amount of ether going from seller to buyer?
do I need to write a separate contract for this to happen or can I include all functionality in the original smart contract?

Thank you for taking the time to reply! Links to guides that answer my questions are also appreciated. :slight_smile:


texts: Can someone please explain the uses of these things and how these things are different or similar to each other, and how and when they can be used interchangeably?


texts: I started learning Eris chain and in the deploying section, they use .yaml file and for making the chain definition file they use .toml file. I searched the internet and what I found was they both are configuration files. So why not use only 1 file type.


texts: Get all transfers of a token contract from etherscan API with python

texts:
I am trying to pull out from etherscan api all token transfer from a particular token contract.
Currently, I can pull data by manually going to etherscan token contract page - for ex cvc coin:
https://etherscan.io/token/0x41e5560054824ea6b0732e656e3ad64e20e94e45
and then on the bottom of the page ' [ Download CSV Export ' allows me to import the CSV in python to get token transfer list and all transfers info:
(Txhash    ,Blockno,   UnixTimestamp   DateTime,   From,   To, Quantity)
However, I would prefer using an api call to get the exact same data but I can't found out which one. It would be something like this one:
url = 'https://api.etherscan.io/api?module=logs&action=getLogs
&fromBlock=0
&toBlock=latest
&address=0x419d0d8bdd9af5e606ae2232ed285aff190e711b
&apikey='+apikey_etherscan
request = requests.get(url)
But this requests yields a dictionnary of transfers like this:(no exploitable info on quantity)
: address': '0x419d0d8bdd9af5e606ae2232ed285aff190e711b',
'topics': ['0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925',
'0x00000000000000000000000020363f72700b58ff49690c5f875b30ad7057001a',
'0x0000000000000000000000008d12a197cb00d4747a1fe03395095ce2a5cc6819'],
'data': '0x000000000000000000000000000000000000000000000000000000e8d4a51000',
'blockNumber': '0x3cdddf',
'timeStamp': '0x595fbcdd',
'gasPrice': '0x12a05f200',
'gasUsed': '0x196992',
'logIndex': '0x25',
'transactionHash': '0x9cdaebf12c1032c648601ffbe9607e876deaac81ed65931a4952113fa353493d',
'transactionIndex': '0x32'}
I am sure there is a better way to do it directly with python without etherscan?
Could someone help?! Thanks!!


texts: How to Compile and Deploy a Smart Contract without running a full node?

texts:
I'm new to solidity and smart contract programming. I have already made and deploy smart contracts successfully, but always using Mist.

Now I'm not able to do so, because I can't complete a node update with the full blockchain, and now I feel that I will never end. So I'm looking for alternatives.

So, my question is, probably very basic, but is there a way to deploy a contract without running a full node?


texts:
Hello everybody i'v deployed a erc20 contract on the main network all work fine but when i send ether to the contract adress i have this error :  Warning! Error encountered during contract execution [Reverted]
i didn't understand why.
TxHash: 0x835d9b4106c279e116f97cc6038c6e12004aaac5408ac862436b0d8fc07ea94f
contract adress : 0xACdDb1b4a5527af01ED85C74F43F90ecD1276b8E

Thanks,


texts: I can I restore Mist to reset master password?

texts: I lost my Ethereum Wallet master password. I have all my account passwords. I've backed up my wallet, and application data. How do I restore Mist to create a new master password? How do I back up the blockchain so I do have to redownload it again?


texts: Convert transaction log hash to readable format

texts:
I am trying to convert transaction logs in text (human readable format)
tried 2 methods

1. using web3.toAscii(receipt.logs[0].topics[0])

2.Using coder.js according to this answer

While using 2nd method I get error :

  Cannot find module 'file:///C:/Users/user1/node_modules/web3/lib/solidity/coder.js'

Path where my coder.js file resides C:/Users/user1/node_modules/web3/lib/solidity/coder.js

Is there any other way to parse the transaction log and get the data in human readable format.

code used to access coder.js

var SolidityCoder = require('file:///C:/Users/user1/node_modules/web3/lib/solidity/coder.js');

also tried

var SolidityCoder = require('C:\\Users\\user1\\node_modules\\web3\\lib\\solidity\\coder.js');


texts: Estimate Gas Cost before SendTransaction

texts:
How meta estimating gas cost before broadcasting.

How can I calculate gas cost for myfunc() in web3js?

function myfunc(){
   require(msg.sender == owner)
   ...
}

await contractInstance.myfunc.sendTransaction(); //it sends the transaction and wastes the gas if `myfunc` will fail.

Is there any best way to know gas cost before call solidity myfunc(), its saves gas for me ? (Similar like metamask)


texts: Blockchain sync ongoing, apparently reached top block, what is happening?

texts:
I've installed Ethereum Wallet on a Windows 10 machine and I am now syncing the blockchain with geth --fast --cache 1024. It seems to have downloaded practically all blocks, as eth.syncing returns

{
  currentBlock: 3439728,
  highestBlock: 3439874,
  knownStates: 7808,
  pulledStates: 3352,
  startingBlock: 3439692
}

But I'm still getting countless lines like

I0329 15:02:25.506146 eth/downloader/downloader.go:966] imported   4 state entries in 213.959ms: processed 9882, pending at least 12191

and balance still does not show even if the transaction happened in an already processed block. So:

I assume the balance does not show because the blockchain "states" are still unsynced. Is this correct?
What are these "state entries" and how do they relate to a block?
How long will the sync take (already going on for one day)? At least, am I at 1%, 50% or 99%?

Thank you in advance.


texts: Can a contract auto execute a transaction given certain conditions?

texts:
I've tried searching for this question but can't seem to find an answer.

There are others asking to auto execute based on an hour interval or other real world check.

What I would like to do is have a contract sitting with an existing balance of ETH watching the balance of another contract. If that balance of contract2 drops below a certain threshold on the next block I'd like contract1 to auto execute a send to bring the balance of contract2 back up.

Basically what I'm asking is if the behaviour of a contract auto evaluates the state of other contracts that it's built to monitor and based on its own logic make a decision to execute a transaction given certain conditions of that contract's state? Does it do that evaluation every block or do I have to build a script to ping infura every few seconds even if there isn't a new block?


texts: VM error: revert.The called function should be payable if you send value and the value you send should be less than your current balance

texts:
There is already a similar question, but it doesn't help me. So I ask this question again and expect something useful information.

Two contracts named AccessControl.sol and Judge.sol. I've removed all the extraneous code, leaving only the wrong functions and get same error when call it.

First I deploy Judge contract and get its contract address. And then I deploy AccessControl contract, passed Judge contract address.

Finally I call emitError function in AccessControl.sol and see the revert error

  transact to AccessControl.emitError errored: VM error: revert.
  revert  The transaction has been reverted to the initial state.
  Note: The called function should be payable if you send value and the value you send should be less than your current balance.  Debug the transaction to get more information.

I have no idea about why it happened. Here is the simplified code。

AccessControl.sol

pragma solidity >=0.4.22 <0.6.0;

contract AccessControl{
    address   public owner;
    Judge     public jc;

    constructor(address _jc) public {
        owner = msg.sender;
        jc = Judge(_jc);
    }

    function emitError(address subject) public returns (uint penalty) {
        penalty = jc.misbehaviorJudge(subject, owner, "data", "read", "Too frequent access!", now);
    }

}

contract Judge {
    function misbehaviorJudge(address _subject, address _object, string memory _resource, string memory _action, string memory _misbehavior, uint _time) public returns (uint);
}

Judge.sol

 pragma solidity >=0.4.22 <0.6.0;

contract Judge {

    struct Misbehavior{
        address subject;   //subject who performed the misbehavior
        address device;
        string resource;
        string action;   //action (e.g., "read","write","execute") of the misbehavior
        string misbehavior;
        uint time;   //block timestamp of the Misbehavior ocured
        uint penalty;   //penalty (number of minitues blocked)
    }

    mapping (address => Misbehavior[]) public MisbehaviorList;

    function misbeaviorJudge(
        address _subject,
        address  _device,
        string memory _resource,
        string memory _action,
        string memory _misbehavior,
        uint  _time)
        public returns (uint  penalty)
    {
        penalty = MisbehaviorList[_subject].length;
        MisbehaviorList[_subject].push(Misbehavior(_subject, _device, _resource, _action, _misbehavior, _time, penalty));
    }

    function getLatestMisbehavior(address _requester) public view
        returns (address _subject, address _device, string memory _resource, string memory _action, string memory _misbehavior, uint _time)
    {
        uint latest = MisbehaviorList[_requester].length  - 1;
        _subject = MisbehaviorList[_requester][latest].subject;
        _device = MisbehaviorList[_requester][latest].device;
        _resource = MisbehaviorList[_requester][latest].resource;
        _action = MisbehaviorList[_requester][latest].action;
        _misbehavior = MisbehaviorList[_requester][latest].misbehavior;
        _time = MisbehaviorList[_requester][latest].time;
    }
}


texts:
What is the difference between

web3.eth.accounts.create()

and

web3.eth.personal.newAccount()

With first invocation I'm able to create a new account. The second call throw me:

  Invalid JSON RPC response: ""


texts: How do I start to write a function to debug Transaction?

texts:
I want to write a program that will do:

for the given txhash  debug TraceTransaction and return that

What can i do in Go ?

Do you have any materials, a tutorial or can you give me tips on how to start?

I just want to have output like here: https://rinkeby.etherscan.io/vmtrace?txhash=0xbb7323b02276aeed76b22fa50e2eefb76d5647560b8c15f23541ec5990d0e855
but i want to do this in go and run this from "code" (for example "go run x.go txhash" ).


texts: List of peers not shared in private network

texts:
I have a simplified version of a private network I need to build. This is done with parity v1.6.8

There is one mining node that is used as a bootstrap node, let's call it B.
Then first not-mining node N1 joins the network by connecting to B via bootnodes parameter. I see that blocks are imported and that each one of them have 1 peer now. That is as expected.

Now add another not-mining node N2, it also connects to B. B now has 2 peers, however N1 and N2 still only have 1 peer each. If I stop B, N1 and N2 will lose connection and have 0 peers. This seems to be incorrect. I can use json-rpc and manually call addReservedPeer to add N2 to N1 and it works - each node has 2 peers now.

If later a third node N3 joins the network it again gets only 1 peer, B has 2+1=3 peers, N1 and N2 still have 2 peers each. Now if I add N2 to N3 via rpc call, they will connect to each other, however N1 still won't be connected to N3, although N2 and N1 were explicitly connected on the previous step.

Each node is run from docker container on Azure VM. Ports are forwarded by docker run -p. I specify the actual public IP address of a node in network.nat.

Here is config.toml from B:

[parity]
chain = "spec.json"
base_path = "parity"
[network]
nat="extip:<B-public-IP>"
port = 30300
discovery=true
[rpc]
cors = "all"
interface = "0.0.0.0"
hosts = ["all"]
port = 8540
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]
[account]
password = ["node.pwd"]
[mining]
force_sealing = true
engine_signer = "0xabcdef..."
reseal_on_txs = "none"

N1, N2, N3 share the same config.toml except for public IP in network.nat

[parity]
chain = "spec.json"
base_path = "parity"
[network]
nat="extip:<N-public-ip>"
bootnodes=["enode://012345...@<B-public-ip>:30300"]
port = 30300
discovery=true
[rpc]
cors = "all"
interface = "all"
hosts = ["all"]
port = 8540
apis = ["web3", "eth", "net", "personal", "parity", "parity_set", "traces", "rpc", "parity_accounts"]

seems like I've enabled everything...

Since I can remotely call rpc, say from N1 and add peer to N2 it seems like all necessary ports are open and accessible, although if I call netPeers to get a list of peers of a node, they are returned with both public and private ips:

{
    "jsonrpc": "2.0",
    "result": {
        "active": 0,
        "connected": 1,
        "max": 25,
        "peers": [{
            "caps": ["eth/62", "eth/63", "par/1", "par/2"],
            "id": "<enode id here>",
            "name": "Parity/v1.6.8-beta-c396229-20170608/x86_64-linux-gnu/rustc1.18.0",
            "network": {
                "localAddress": "172.17.0.2:40286",
                "remoteAddress": "<public IP>:30300"
            },
            "protocols": {
                "eth": {
                    "difficulty": null,
                    "head": "81054935d40ed7ffd94a7f4915f52c96fe0ebfe42ee715df0fa0decb76d70c45",
                    "version": 2
                },
                "les": null
            }
        }]
    },
    "id": 1
}

Please advise, am I missing something in config files or how can I double check network configuration?


texts: Quorum 7node example when i try to import account1 of node1 using its key1 ciphertext i get wrong account address imported

texts:
I am trying to import account 1 of node1 of 7nodes quorum example using its key1 file which you can find here "https://github.com/jpmorganchase/quorum-examples/tree/master/examples/7nodes/keys".

my account 1 for node1 is address":"ed9d02e382b34818e88b88a309c7fe71e65f419d"

i used "ciphertext":"4e77046ba3f699e744acb4a89c36a3ea1158a1bd90a076d36675f4c883864377" to import account one in metamask so that i can use it while making transactions from DApp.

but i get some wrong account("0x86e961c7b74f760fe5DF0623f1bBD048c643F653") added in my metamask.

Please tell me how to add  7nodes example node 1 account address to metamask?


texts: Not able to call the solidity function through App.js? Anyone know how to call a solidity function?

texts:
I'm trying to call a Solidity function from App.js, but I'm unsuccessful even after a number of tries.

Its a very simple function betOnTeam().  Inside this function I just want to check condition and give a call to another function update(),
but I'm not even able to view logs in the console (can't even call betOnTeam()).

So here is the function in .sol file that I'm trying to call:

function betOnTeam(uint team) public {
  emit LogInfo("Inside betOnTeam-----------");
  if(team == 1) {
    update();
  }
}

This function accepts an int so I'm providing it through App.js:

function ready(){
  document.getElementById("bet").addEventListener("click", function(e){
    var contract = web3.eth.contract(OraclizeContract.abi).at(OraclizeContract.address);

    var team = document.querySelector("#bet #team").value;

    if(team == "Home")
    {
      team = 1;
    }
    else
    {
      team = 2;
    }
    console.log(team) ------------>> THIS SHOWS 1 IF HOME SELECTED

    // Now i am calling the .sol function

    contract.betOnTeam(team, function(err, transactionHash) {
      if (!err)
        console.log(transactionHash);
    })
  })
}

Any help is highly appreciated.

I can'not call the function by passing the argument I have even tried

contract.betOnTeam.call(team, function(err, transactionHash) {
  if (!err)
  console.log(transactionHash);
})

.call gives me a blank array on the console nothing else
otherwise without using .call I can'not see any error on the console

update() function:

function update()
  payable
  public {
  // Check if we have enough remaining funds
  if (oraclize_getPrice("URL") > address(this).balance) {
    emit LogInfo("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
  } else {
    emit LogInfo("Oraclize query was sent, standing by for the answer..");

    // Using XPath to to fetch the right element in the JSON response
    oraclize_query("URL", "json(https://api.crowdscores.com/v1/matches/123945?api_key=93c4c515196741beaf5e4528b64ea511).outcome.winner");
  }
}


texts: How do you compute the right amount of gas and tax to transfer certain amount of money?

texts:
Two situations.

You want to transfer all the money in an account and want to compute the right amount of gas and tax suc that you transfer all that is possible and leave the account with 0.
You want to transfer a specific amount of money and want to compute the right amount of gas and tax such that you transfer exactly the desired amount.

How do you compute both values?


texts: Which ERC standard is suitable for an ICO token to have types?

texts:
There will be ICO with multiple cycles... Here, investors can purchase tokens and after a fixed window of 270 days, they can redeem it back. But within this window period, they can transfer tokens to each other and the world.

For example, if user purchases 1000 tokens in 1st cycle, those tokens can only be redeemed after 7th cycle.

If someone purchased 1000 tokens in 3rd cycle and transferred 500 to other user, both should only be able to redeem after 9th cycle...

Can we bind "token purchase timestamp" with each token which never changes irrespective of transfers?

What will be the best solution according to you?


texts:
I sent ether to the DCORP crowdsale using Coinbase, can I retrieve it?

I invested 1 Ether into the DCORP crowdsale only later to find out that they do not support coinbase ether wallets.

0xD42433A8a0A1CEB73c8ff4e432463e2ee109039d

the ERC20 token (DRP) is now linked to the address Coinbase used to send ETH with, on my behalf.
I WILL OFFER A BOUNTY OF HALF THE RECOVERED ETHER IF ANYONE CAN FIND THIS
Although I am guessing the answer is that only Coinbase can resolve this, they will only send the bot to minister to my query and I do not anticipate Coinbase will seek to resolve anything.


texts: What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?

texts:
It was my understanding that Truffle migrations will move updated contracts to new addresses. As a developer, you can use this feature to update already deployed contracts with new code.

ZeppelinOS has a complicated solution using proxies. Is it doing more for you than a regular migration?


texts:
I have smart contract deployed that accepts funds (via fallback function function() payable { ... }). Also I have frontend using web3 to send funds.

When I tested it with local node (and JSON wallets presented locally) evrything works fine - web3.personal.unlockAccount(account, password) unlocked account with data provided by user then funds sent to contract.

Now I deployed geth node on standalone VPS and connecting to it using code:

var Web3 = require('web3');
this.web3 = new Web3();
this.web3.setProvider(new Web3.providers.HttpProvider('http://my-node-addr.net:18545/'));

if(this.web3.isConnected()) {
  console.log('web3 connected');
} else {
  console.log('web3 NOT connected');
}

It shows that client connected successfully. But when I am trying to send funds code failed on line

web3.personal.unlockAccount(account, password);

with error Error: no key for given address or file. Of course, my node cannot contain all client's wallet file (nobody want to upload it).

Here is how I am sending transaction:

this.contract.sendTransaction({ from: account, value: amount, gas: 400000 })
.then(() => {
    // OK, everything fine!
})
.catch(error => {
    // I am here
    console.log('Oops...', 'Error happened during your payment: ' + error, 'error');
});

UPD: What I want: provide html page with fields "account", "password" and "amount" that allows users to send ethers to predefined address. Of course my node will not have UTC-..... files (wallets).


texts:
I have mistakenly transferred ETH to ETC wallet from Binance to Kucoin as I have gone through the reviews & noticed that I can only recover my ETH through Kucoin & there is no other way i can retrieve them.

However I have spoken to the representative & firstly they said that it cannot be done & there is no way out, then i sent them few links on which different people has posted that it can recovered if we can get the private key but Kucoin is not providing me with that says that it has private information of the user & after insisting a lot they took the details from me such as TXID & screen shots of my wallets & said that we cannot guarantee & will take 2 months so i have a question

Does the procedure takes that much of time or i will be considered in the Queue?
Every private key of the assets differs from every users or it is the same for everyone??
All over internet it says that assets of same fork can be recovered if transfer into the same fork like ETC & ETH is of the same fork!

Hopefully anyone will revert because if i can retrieved it with your help would really appreciate it.


texts: Can a contract safely rely on block.timestamp?

texts: How safe is it to use block.timestamp as contract expiration time? If a miner provides an incorrect timestamp in a block header, how much can it be off before it is rejected by other nodes? Is there a strategy to make a contract more robust to this?


texts: the balance in genesis file is it in ether or wei?

texts:
In genesis.json file I have this balance :

 "bd7a14e103ffa97ec5fd96d9975adb1b52756ef3": {
      "balance": "0x200000000000000000000000000000000000000000000000000000000000000"
    }

the hex number is the balance but does the value of ether or wei ?


texts: What advantages and disadvantages does Open Blockchain / Hyperledger / Fabric have over Ethereum?

texts:
Similar to this question about Ethereum and Bitcoin:

What advantages and disadvantages does Open Blockchain (OBC) have over Ethereum? What can you do with OBC that you simply cannot with Ethereum? What price do you pay for these additional functionalities ?


texts:
I have a geth node for a private blockchain and the miner just does not start. I checked coinbase and defaultAccount and they look OK. Has anyone any ideas what could be the cause of this error?

> eth.mining
false
> miner.start(8)
null
> eth.mining
false
>
> eth.coinbase
"0x5842d6acb3dca819471bde56255f27670aa9b9c6"
> eth.defaultAccount
"0x5842d6acb3dca819471bde56255f27670aa9b9c6"
> eth.getHashrate
function(callback)
> eth.getHashrate()
undefined
>

Here is the genesis.json file -

{
    "config": {
        "chainId": 88888,
        "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x1",
"extraData" : "0x00",
"gasLimit" : "0x47e7c5",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc" : {
    "c2d7cf95645d33006175b78989035c7c9061d3f9": {"balance": "888888888888888888888888"}
}
}

Here is the connection string -

geth --datadir /geth/mybc --unlock "0x5842d6acb3dca819471bde56255f27670aa9b9c6"  --rpc --rpcaddr "localhost" --rpcport 8545 --networkid 1234 --rpcapi "admin,db,eth,debug,miner,shh,txpool,net,web3,personal"  console 2> console.log


texts: Which is the best mobile platform to develop a blockchain based mobile application

texts: I am new to the blockchain technology. For my semester porject i have to debelop a blockchain based healthdata management system. That includes a blockchain developed using ethereum to store the data and a mobile application to access the blockchain and update and view data. I want to know what i the best platform to develop mobile application (react native or androdi(java/kotlin)). I am good in android.


texts: OpenZeppelin - how to check the owner's address of an Ownable token

texts:
Please excuse this basic question, as I am quite new to this. I created a sample token using OpenZeppelin framework. The token class inherits MintableToken which in turn inherits Ownable. This class has a variable:

address public owner;

which is by default set to msg.sender, but how do i check the address of this owner using web3js/truffle. I've tried this:

coinInstance = testCoin.at("address")
coinInstance.owner

but i only get the following

{ [Function]
  call: [Function],
  sendTransaction: [Function],
  request: [Function: bound ],
  estimateGas: [Function] }


texts: Does ethereum clients return false data if someone manipulate local blockchain data?

texts:
If someone manipulates the local blockchain data, does ethereum clients like geth return false data?

For example, after cracker manipulates local blockchain files or leveldb, does geth return manipulated data?


texts: Ethereum-Wallet-linux64-0-7-2 on Ubuntu 16.04 LTS - sync completed, but the main UI don't shows up

texts:
I'm trying to run Ethereum-Wallet-linux64-0-7-2 on a fresh Ubuntu 16.04 LTS installation - block sync completed successfully, but the main UI don't shows up.
I assume that's because 16.04 is released very recently and Ethereum Wallet isn't yet compatible.
But maybe there a known workaround to get the wallet running on 16.04?


texts:
I've got a quite complex contract with two arrays:

struct TransactionsLink {
    uint transactionId;
    uint creationTime;
    uint amount;
}

mapping( address => TransactionsLink[]) public transactionsFinder;

struct BillLink {
    uint billId;
    uint creationTime;
    string name;
}
mapping( address => ResearchBillLink[]) public billsFinder;

function getBillsIndexBetweenTimes(uint _startTimestamp, uint _endTimestamp) constant returns(uint startIdx, uint endIdx){ if (billsFinder[0].creationTime) .... }
function getTransactionIndexBetweenTimes(uint _startTimestamp, uint _endTimestamp) constant returns(uint startIdx, uint endIdx){ if (transactionsFinder[0].creationTime) .... }

And I've developed a binary search algorithm inside the contract in order to get bills/transactions for someone from those arrays. However my code is quite big (range search) and I would like to reuse it for both arrays (in fact I've got 4).

Is there a way in which I can reuse my function without pasting all the code twice?

function getArrIndexesBetweenTimes(GenericStruct[] arr, uint _startTimestamp, uint _endTimestamp) constant returns(uint startIdx, uint endIdx){ if (transactionsFinder[0].creationTime) .... }
function getBillsIndexBetweenTimes(uint _startTimestamp, uint _endTimestamp) constant returns(uint startIdx, uint endIdx){return getArrIndexesBetweenTimes(billsFinder)}
function getTransactionIndexBetweenTimes(uint _startTimestamp, uint _endTimestamp) constant returns(uint startIdx, uint endIdx){ return getArrIndexesBetweenTimes(transactionsFinder) }

I would like to be able to do the second, but structs do not seems to support inheritance, I could try playing with how structs are mapped in memory and placing creationTime as first parameter, but I'm not sure that would be totally safe...

Thanks,


texts: VM Exception while processing transaction: revert when I send ETH to my contract address

texts:
recently I met a very strange problem, when I deployed a ERC20 ICO contract to Repsten network through truffle and MetaMask.Then I send some ETHs to my ERC20 contract address, I expected is that when contract deadline is up or received ETHs amount is more than funding goal, I can withdraw ETHs in the contract.

Actually it worked well as I expected when contract received ETHs amount is Integer number.

But when contract received ETHs amount includes float number, such as 0.1,0.2,1.1, then it will happen 'VM Exception while processing transaction: revert' as the title described. Anyone met this problem before? The detail information is as follows, PLS help me to resolve this problem.

Thanks in advance.

first I deployed a ERC20 contract to Ropsten network. The fallback function like following.

I send 0.5 ETH to my contract address and contract received 0.5 ETH. as deadline is up, I send 0 ETH to my contract address to trigger contract's fallback function transfer ETH balance to beneficiary. But it's failed.
And in ropsten.etherscan.io it prompts 'transaction revert' .
contract link:
https://ropsten.etherscan.io/address/0x611d807ea4c3fa9bfb5c7765642fc8be534c9f3e

I deployed another contract with same code, I send 1 ETH to contract address, as deadline is up, I send 0 ETH to my contract address to trigger contract's fallback. Beneficiary can receive ETH successfully.

contract link:https://ropsten.etherscan.io/address/0x9990282fc9734ef8e6b0073a3537938a189f7afd


texts: Ethereum balance not confirmed by online blockchain explorers

texts: When doing eth.getBalance(eth.coinbase) on my geth machine I get some non-empty balance. When checking the same account in one of many online blockchain explorers, this account is either non-existent or zero. Who's right and what did go wrong?


texts: How to push new wallet into Ethereum blockchain?

texts:
Imagine that I generated normally encrypted(by Ethereum standards) wallet keys(private, public). How to push this generated wallet into Ethereum node?
Is it possible to push new wallet into node, using web3js library? Or is it enough to send some ethereums to a new wallet address, so new address will automatically placed into blockchain?


texts:
Vitalik said the "ice age will be delayed anyways" (with metropolis).

  It's not that important or applicable either way, though on the other hand that given network going to be mucking around with mining rewards anyway because we will be delaying the ice age. I don't see any extreme case in either direction, I guess.

Maybe I'm blind: But I can't seem to find any details about the new mechanics of the difficulty bomb, any adjustments or even a total removal? Where is this specified? Could anyone guide me? Will metropolis delay the difficulty bomb?


texts: Is it possible to modify this command to use with the console in Geth?

texts:
I use this command because it allows me to sync the Geth blockchain to an external SD card rather than to the internal hard drive:

geth --datadir /media/user/sdcard/chaindata --ipcdisable

However, if there was a way to use it with the console it would be even better.

I have tried this but it doesn't work:

geth console --datadir /media/user/sdcard/chaindata --ipcdisable

Is it possible to use the command with the console and if so, how?


texts: Simple way to balance web3j connections between nodes

texts:
Context:
 I have a client that can connect to 3 local-network nodes to distribute query-loads and be more resilient to network/software issues. I have managed to create a -simple- watch-dog with a background-thread monitoring nodes health-status and updating the list of nodes to send the next query to.
Other modules can query the watch-dog and request a suitable web3j object for next requests. This is working properly, and when I switch-off a node, requests automatically skip the non-responding local node.

Problem:
The "problem" comes when trying to use web3j-generated wrapper contract objects. Each self-generated contract, due to the API design is tied for its life-time to the life-time of a web3j instance when passing a web3j reference at deploy/load instantiation time. To be able to continue using the watch-dog functionality I'm forced to create N proxy-contracts instances for each of the N local-network nodes. It works, but code looks "patchy".

Question: Is there any cleaner method to solve the problem. For example, is there a way for a single web3j instance to change underlying JSON-RPC connections transparently at runtime or for a single contract proxy to switch the underlying web3j instance/connection?


texts: Whats the cheapest way to fork an ERC20 token when you have all addresses and values?

texts:
If you have a copy of the mapping of the owners/allowance of the tokens you'd like to fork.

I couldn't find any contracts that seemed to be able to this.


texts: Automatic "Confirm Transaction" Metamask

texts:
I have a webapp and when I send a transaction I need to approve this tx by clicking "Accept" in Metamask. I would like to implement an automatic non-clickable confirmation. Is it possible? How?
(Security is not important in this case)