texts:
I want to implement my contract in much better way and want to use the inheritence. I wrote the code and i face one problem that i want to access the mapping variable of Contract A in the Contract B. My Code is as below

pragma solidity ^0.5;
import "./ConvertLib.sol";

contract A {
    mapping(address => address[]) public inves;

    function totalInves() public view returns(uint) {
        return(inves[msg.sender].length);
    }

}

The another contract is

pragma solidity ^0.5;
import "./ConvertLib.sol";
import "./A.sol";

contract B is A {
    function total() public view returns(uint) {
        return(inves[msg.sender].length);
    }
}

Contract A has more functions too and it stores the data in the mapping function. I am using Truffle framework so what i tried to do is to call the both function. When i call the function totalInves in the Contract A using truffle it gives me this ( Truffle console) where as i am running testrpc

 truffle(development)> var acont = await A.deployed()
 truffle(development)> var data = acont.totalInves.call({from:acc[0]})
 undefined
 truffle(development)> data
 <BN: 1>

Where as when i execute the contract B function it gives me this

 truffle(development)> var bcont = await B.deployed()
 truffle(development)> var data = bcont.total.call({from:acc[0]})
 undefined
 truffle(development)> data
 <BN: 0>

I am confuse why the same variable is having different result where as it should give the same resultset if i call the total function in contract B.


texts: Private chain Ethereum handshake failed Genesis block mismatch

texts:
I'm setting up a private chain between two VMs.

The first node started mining successfully, and the connetion between the two VMs has no problem.

But when I try to connect the second node to the first, I got this error:

  DEBUG[05-08|09:21:11] Ethereum handshake failed
  id=e8d86dae37655a1b conn=dyndial err="Genesis block mismatch -
  dfc3e94e54007bba (!= 573969da5d11c81a)"

I copied the genesis.json file from the first node to the second, how can they mismatch?

The command I used to start the first node is:

geth --identity nodeBcDev1 --nodiscover --networkid 9191 --port 60830 --maxpeers 5 --lightkdf --cache 512 --rpc --rpccorsdomain "*" --datadir "C:\BlockChain\Data" --minerthreads 2 --mine

The command to connect from the second node:

geth --networkid 9191 --port 60830 --rpc --rpcport 8545 --rpccorsdomain "*" --datadir "C:\BlockChain\Data" --minerthreads 2 --bootnodes "enode://41cc17dydeefide8018c39054653d638430c3abfe3f77g009dc9294h0e8a9d62a5b819fb5810391fddab560d4c1bf9d1c9b110c6fbe603731388a993751bd95e@10.0.0.1:60830" --verbosity 4

Finally, the genesis.json file:

{
    "nonce"         : "0x0000000000000055",
    "mixHash"       : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "parentHash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty"    : "0x1",
    "gasLimit"  : "0x800000",
    "timestamp" : "0x0",
    "extraData" : "",
    "coinbase"  : "0x0000000000000000000000000000000000000000",
    "alloc"         : {},
    "config"    : {
        "chainId": 9191,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    }
}

My client id matches the network id, and I know the connection was successful because the lines above the handshake failure was:

DEBUG[05-08|09:21:11] Ethereum peer connected                  id=df887467936a7c9b conn=dyndial name=Geth/v1.8.0-unstable/linux-amd64/go1.9.4

Really confused.....


texts: Save Tokens from Metamask with Stolen Seed Phrase

texts:
I got phished into sending my Seed Words to a hacker. I already lost some ETH I had there.
I will be getting some tokens on the 29th of May, and I fear the hacker might also steal them. I was thinking that maybe they have some kind of script that will automatically transfer the Tokens to his wallet immediately after they are deposited in my account.
I already tried speaking to the smart contract developer to change the address in the smart contract, but they told me they are unable to change it due to the way the smart contract was designed.
Also I will hire someone on Freelancer to develop the same script for me to withdraw to a safe wallet.
Any other ideas you might have will be really appreciated.


texts: Gas problem creating Solidity contract with hundreds of pre-populated structs in array

texts:
I'm creating a time release contract for tokens with a simple struct and stored in a public array:
    struct Lockbox {
        address beneficiary;
        uint balance;
        uint releaseTime; // seconds since epoch
    }

    // Numbered lockboxes support possibility of multiple tranches per address
    Lockbox[] public lockboxes;

I've reduced the code to add each entry to it's simplest form:
    lockboxes.push( Lockbox( address(0x32...), 1666667, 1635711346 ) );

This project requires 1000+ of these Lockboxes to be created, but I'm running out of gas after just a few hundred.
Is there another pattern I can use? Or should I simply create the contract, and use separate transactions to add all the lockboxes?
Thanks!


texts: Simple transfer from contract not working

texts:
this is very basic but i just want to test the transfer function. I load the contract with the constructor with 1 eth, then when i click the transfer function 0 wei is transferred. I understand this contract isn't very secure or good. But I just want to get this simple transfer out to an address to demonstrate what can be done.

My below code is as follows:

pragma solidity ^0.4.20;

contract Escrow {

    address public a;
    address public b;
    uint balance;

    constructor() public payable {
        a = msg.sender;
        b = 0x14723a09acff6d2a60dcdf7aa4aff308fddc160c;
        balance = address(this).balance;

    }

    function payoutToSeller() payable public returns(bool) {
        if (msg.sender == a) {
            b.transfer(balance);
            }
        }

     function getData() public constant returns (uint) {
         return balance;
     }

}


texts: Deploy a token which you can only send in multiples of x

texts: Im a beginner in solidity. Is there a way to deploy an ERC20 token that can only be sent in multiples of X or else the tx fails?


texts:
I'm trying to test my contract functions in Truffle v5+ but getting TypeError: myContract.methods.register is not a function.

Contract MyContract {
    function register(uint256 amount) external {...}
}

In my Truffle migration file:

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

module.exports = async function(deployer) {
    deployer.logger.log("Deploying MyContract");
    await deployer.deploy(MyContract, someConstructorParam);
}

In my Truffle test file:

contract("MyContract", accounts => {
  let myContract;

  before(async () => {
    myContract = await MyContract.deployed();
  });

  it("can register", async () => {
     await myContract.methods.register(1000).send({ from: accounts[1] }); // <<<< This is where the error is thrown.
     ...
  });
}

When I console.log(myContract.methods), included in the methods is:

'register(uint256)': [Function] {
   call: [Function],
   sendTransaction: [Function],
   estimateGas: [Function],
   request: [Function]
}

And when I change it to await myContract.register(1000, { from: accounts[1] }); I get Error: Returned error: VM Exception while processing transaction: revert. What am I doing wrong?


texts: How to deploy Smart Contract on Ethereum 2.0

texts: I want to know how to deploy Smart Contract on Ethereum 2 Testnet using web3 ?


texts: When I tried to switch to testnet on Mist through develop->network->testnet, I met this problem, like the picture below. What's the problem? How can I fix this?


texts: I started learning about ethereum and dapps just a week ago.I totally understand the need and importance of writing tests for an ethereum smart contract. But what I didn't understand is that I already spent a lot of time working and testing the contract on remix ide. Still why most of the course instructors and experts focus on writing tests on the local environment again?


texts:
What inputs go into the RLP and Keccak function to calculate the block header hash?

I looked up the header struct. Which of those values are fed into the RLP, Keccak? Were nonce and mixed hash left out? Are there any test cases or example templates for reference?


texts:
I have created a wallet using geth on my mac. I have sent a small amount from Kraken to that account but its stuck on "sending".

Do I need to download the blockchain first on my node so it can be sent? What am I missing?


texts: Block data duplication when moving from Geth to Eth (or vice versa)

texts:
I've so far been using Geth (the Go client) as my client of choice. I'm now interested in using the Mix IDE, a requirement of which is that I use Eth (the C++ client) instead.

I've already synced the block data for the Geth client. Is it necessary that I also sync the same block data a second time, for the Eth client? If both clients use the same data structure to store the data, and they store it in the same place (~/.ethereum) then presumably they can just share (he says). Is this going to be the case?

(Follow-on question: Does Eth have an equivalent to Geth's --fast flag?)


texts: return msg.sender.balance not acting as expected

texts:
I'm using MetaMask to connect to Rinkeby and I'm deploying the contracts via Remix. When I call the function returnsenderbalance it returns

115792089237316195423570985008687907853269984665640564039456084007913129639935

rather than my balance in Wei. The code is below:

pragma solidity ^0.4.11;

contract returnbalance{
    function returnsenderbalance() constant returns (uint){
        return msg.sender.balance;
    }
}


texts: Can smart contracts become incompatible with new versions of the EVM?

texts: Can the EVM update deprecate operations of older smart contracts, making these contracts non-operative? If so, what are the solutions to upgrade these smart contracts to the new version of the EVM if they cannot be modified directly (due to immutability)?


texts: Are event logs still accessible after selfdestruct?

texts:
Are event logs still retrievable for a contract after selfdestruct?  Does fast sync or full sync in geth have any effect on this?

Basically, it looks like it would be useful to Ethereum if my contracts self-destructed after use(to remove them from the current state) but I still need to be sure I can access the logs for these contracts.


texts: How to access Parity node's mempool with web3.py?

texts:
I'm running a Parity node with parity --jsonrpc-api all, then connecting to it in python3 with w3 = web3.Web3(web3.HTTPProvider('http://localhost:8545')).

I can call print(w3.eth.getBlock('latest')) and see the results fine, but I cannot call w3.txpool.inspect - I get ValueError: {'code': -32601, 'message': 'Method not found'}

It seems that web3.py only knows about Geth mempool functions?
How can I call Parity's parity_allTransactionHashes method in python (https://wiki.parity.io/JSONRPC-parity-module.html#parity_alltransactionhashes)?


texts:
I'm trying to sign transaction and send it to remote node, but I keep getting this error:
UnhandledPromiseRejectionWarning: Error: Returned error: invalid sender

This is how I perform signing and then sending actions:

var Deployer = {
TxBuilder: function() {
    var signedTx;
    try{
        web3.eth.getTransactionCount(keyPair.address).then(function(res) {
            web3.eth.accounts.signTransaction({
                nonce: web3.utils.toHex(res + 1),
                from: keyPair.address,
                to: smartContractData.address,
                data: 'some encoded data here',
                gas: '4000000',
                gasPrice: web3.utils.toHex('5000000000'),
                gasLimit: web3.utils.toHex('4000000'),
                chainID: '2487'
            }, keyPair.privateKey).then(signedTx => {
                   //console.log(signedTx.rawTransaction);
                   web3.eth.sendSignedTransaction(signedTx.rawTransaction).on('receipt', console.log);
               });
        });
    } catch(error) {
        console.error('Error while sending signed tx: ' + error);
    }
}

};

Deployer.TxBuilder();

Here is account data, that I refer to in my code:

var keyPair = {
address: '0x413671Ef1633C4e31D07c4D36C92109792133C8a',
privateKey: ''

};

I'm able to sign the transaction, but I just can't send it, I tried what was described here: Invalid sender error on private chain  but it didn't help as well.

I have balance in my account in custom ethers. I can deploy smart contracts and make calls / send transactions to any method in deployed smart contracts to the same private network from the very same account via MyEtherWallet, for instance. The problem is that I can't do it via web3.

I'm using:
- web3 1.0.0 36 beta

Any help with this is much appreciated, thank you!


texts: Event data has insufficient length | What does this mean?

texts:
I've seen this warning from time to time when working with Brownie
Event data has insufficient length

This is after I made a call to a Chainlink node, calling a function like:
 function requestUsers() public returns (bytes32 requestId)
    {
        Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
        req.add("lat", "45.7905");
        req.add("lng", "11.9202");
        req.add("radius", "500000");
        req.add("start", "2021-01-01 20:00:00");
        req.add("end", "2021-02-21 20:30:00");
        return sendChainlinkRequestTo(oracle, req, fee);
    }

And I'll get an output like:
Running 'scripts/request_and_read.py::main'...
Transaction sent: 0x8ff15b5e313dceb0e47c5cdb95567b611b63f4066e4e5ce14b93008f42193b86
  Gas price: 25.0 gwei   Gas limit: 143119   Nonce: 2942
Waiting for confirmation... /Users/patrick/code/brownie/brownie/network/event.py:238: UserWarning: 0x56dd6586DB0D08c6Ce7B2f2805af28616E082455: Event data has insufficient length
  warnings.warn(f"{address}: {exc}")
  GeoDB.requestUsers confirmed - Block: 24049531   Gas used: 130109 (90.91%)

What does this mean? Is an event not the right size?


texts: How do you estimate the gas cost of any arbitrary function in Remix IDE?

texts:
I've found plenty of information on how to do this using Truffle and Web3, but nothing regarding how to achieve this in the Remix IDE.

Examples would be very much appreciated.


texts: "Price Impact Too High" swapping tokens back to ETH on basic contract with liquidity (Uniswap)

texts:
I created this basic smart contract on Rinkeby (uses OpenZeppelin ERC20PresetMinterPauser preset), minted 1m FOO, then added liquidity on Uniswap v2 with 10 ETH and 1m FOO. I then swapped 1 ETH for 90,661 FOO.
However, if I try to swap back, it says "Price Impact Too High", no matter how little amount of FOO I specify:

In fact, the info balloon says 0% price impact, so this makes it even more odd:

Any help appreciated. Of course, I set my price slippage to 30% to make sure, but there's clearly something else going on here.


texts: Mist 0.7.1 on Mac not updating blocks; unable to send Ether. How to send Ether given this problem?

texts:
Mist downloads new blocks upon a restart, thus is able to receive Ether, but I'm currently unable to send any Ether from any of the wallets in Mist.

I believe the issue is the lack of synchronization while Mist is open, and that my inability to send Ether is a symptom.  For example, I've currently had Mist open for 15 minutes and it says "15 minutes since last block"

EDIT: I seem to have bypassed the problem, thus have solved my immediate need (sending Ether), though others may encounter this as well.

What I did was to change the network setting (top menu > Develop > Network) from "Main Network" to "Testnet" and then back to "Main Network".  Restarting Mist hasn't fixed anything, but this 'restart of the network connection' seems to have made the difference.  Mist is now receiving new blocks in real time.


texts: Approval + Deposit each time, vs a one time Approval then only Deposits after

texts:
I've noticed that some token contracts are requiring me to do an approval before I make a deposit and some do not.

For example.  SNT and CVC do not require me to do an approval before I deposit.  It may be because, that first time you do an approval it stores that approval somewhere for all future deposits.  For BAT and BNT, I must do an approval before every single deposit.  Why is that?  And how can I programmatically determine this?  Can I make an "eth_call" to the contract and get some value that tells me whether or not I need to make an approval before my deposit?

My theory is that the SNT and CVC contracts are approving forever, where as the BAT and BNT contracts are approving that specific amount for that specific deposit.  How can I determine this programmatically through the ethereum network?  My Parity wallet seems to know, so it must be making some call to the network to learn whether or not it needs to do an approval before a deposit...

Note, i'm making these approvals and deposits to give permission to some other contract.

******************************** Edit ********************************

So I did some reverse engineering and discovered something. If I make this "eth_call" to the token address I get a response. Depending on what that response is tells me whether or not I need to make an Approval AND a Deposit or just a Deposit... I don't really understand it and am having a hard time finding documentation on this topic explaining how this works. But at least I have something to go off of for now. I'm not sure what method corresponds with "0xdd62ed3e".

"id": 1,
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
    {
        "data": "0xdd62ed3e000000000000000000000000" + walletAddress_With0xRemoved + "000000000000000000000000" + contractAddress_With0xRemoved,
        "from": walletAddress,
        "to": tokenAddress
    },
    "latest"
]

The response I get may look like this:

u'result': u'0x0000000000000000000000000000000000000000000000000000000000000000'

or like this:

u'result': u'0x00000000000000000000000000000000000000000000000456251106dda27079'

I've discovered that the result being zero means nothing is approved for deposit so it requires approval.  And the non-zero result means that amount has already been approved but has not yet been deposited.  So you can deposit that much or less.  If you want to deposit more than that amount, it seems you have to send an approve with a 0 amount to zero it out, then approve again for a higher amount...


texts: How to access public contract storage with Go?

texts:
I have a mapping defined in a contract:

mapping(bytes32=>string) public name;

How can I access this in Go?  abigen provides bindings for functions but not variables.  This question shows how to do this in Javascript but I can't find the equivalent for Go.

Note that I cannot create an Name() function as this is a deployed contract not under my ownership.


texts: How to encrypt an API key if using oracalize for some API in a smart contract?

texts:
In my smart contract, I want to use the random.org API to generate a random number, but when publishing the verified source code I don't want anyone to see what API key I'm using. The etheroll contract  uses the random.org API and does this as follows:

bytes32 rngId = oraclize_query("nested", "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"serialNumber\",\"data\"]', '\\n{\"jsonrpc\":\"2.0\",\"method\":\"generateSignedIntegers\",\"params\":{\"apiKey\":${[decrypt] BLTr+ZtMOLP2SQVXx8GRscYuXv+3wY5zdFgrQZNMMY3oO/6C7OoQkgu3KgfBuiJWW1S3U/+ya10XFGHv2P7MB7VYwFIZd3VOMI/Os8o1uJCdGGZgpR0Dkm5QoNH7MbDM0wa2RewBqlVLFGoZX1PJC+igBPNoHC4=},\"n\":1,\"min\":1,\"max\":100,\"replacement\":true,\"base\":10${[identity] \"}\"},\"id\":1${[identity] \"}\"}']", gasForOraclize);

I'm confused how this is working - where does decrypt come from and, if this works, how do I get an encrypted version of my API key that I can use decrypt on like the above?


texts: erc20 token swap contract example needed

texts:
is there a contract example which allows to exchange one erc20 for another?

i have 2 tokens

i want to exchange from tokenA to tokenB 1:1 and keep 1% as a fee

the sender should just make a normal erc20-send to the contracts address and receive back the other token.

the contract will have a pool of tokens, A and B

if someone pays 1 tokenA to the contract, the contract should send 0.99 tokenB back to the sending address and keep 0.01 tokenA in the pool.

i saw uniswap is doing something like this but with variable rates and more complex.

please point me to an example of such a contract or even point me to some good solidity programmer who could make this for me.

thanks for your time


texts: What does IP address 127.0.0.1 mean in enode URI?

texts:
enode is the URI for an ethereum node, consisting of node-id-in-hex@ip-address:port. Here are 2 enode examples:
 enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@10.3.58.6:30303?discport=30301
 enode://a32e5f06c1523c42d732ab8b9bdf569a75d1dad0581ba734b8cc99c5876758132a9b0807b26d79d45cada1a0064db5680efc71350f6030d9a9b1e0a589ef9315@127.0.0.1:30303

The ip-address is the IP address of the node, such as 10.3.58.6 in first enode example. But what does the 127.0.0.1 mean in 2nd example above? 127.0.0.1 is the localhost itself and can not be any other node.


texts:
I would like to know how my custom ERC721 0x marketplace can be customized.
I know the FAQ has a walkthrough and I already found out how to inject my custom ERC20 token address, symbols etc. but I still have a problem replacing the logo for my exchange or marketplace.
I wonder if a documentation also exists regarding that topic? (I was able to replace to logo, but I can't get rid off the applied css filter that makes the svg paths green / grey depending on the theme applied).
I would also be curious how the collectibles card can be changed?


texts: Past transactions inconsistent on Metamask with Ganache

texts:
I completed the truffle framework pet shop tutorial using Metamask and Ganache. The blokchain (locally hosted on port 7545) stores my "pet adoptions" which are represented as ethereum transactions. I can view the past transactions either in Ganache or by clicking on the Metamask icon in Chrome.

The problem arises when I close Ganache and start it again. There are now no transactions shown in Ganache, as (according to my understanding) the blockchain is stored in memory, so after restarting Ganache it is blank.

However, Metamask still shows my past transactions, even though they should be gone. This leads to inconsistencies in my pet shop app. Furthermore, my adoptions now don't work: Upon trying to adopt a pet, I get the following error:

Error: the tx doesn't have the correct nonce. account has nonce of: 0
tx has nonce of: 10

Does Metamask store the transactions somewhere, and that's why they're still displaying? How does Metamask actually interact with the blockchain?

Edit: Turns out the only solution I have found is to remove Metamask and install it again.


texts:
I have 2 Ether in my wallet contract:0x83ca83fF078f651E1B69CD70F43Ec11B4Aa0af2b

I created this contract from my main Ethereum (Mist) address: 0xB3C3e20312Ded30a651Ce746CdE0534dc0433604

I have been trying to withdraw from this contract with no success. I tried everything I could think of:
- I used MyEtherWallet
- I added another owner (my Jaxx address: 0x34106338b3ff3539dc2a183b7c49da67a7ac8ce6)
- I removed this other owner
- I even tried to KILL the contract, both from Mist (Ethereum Wallet) and from MyEtherWallet, and from both addresses - nothing happens!

Can anybody help me?
The history of my transaction to this contract are here.


texts: How can I measure block processing time on a given Ethereum client?

texts:
I'm looking for a tool or library to measure block processing time on a given Ethereum client. My scenario would be to be able to compare block processing time to State size. The goal is to understand how state size impacts block processing time. The network I would set up would be of only one private node as I'm only interested in the client performances.
I know infura "versus" (https://github.com/INFURA/versus) but I'm not sure if it suits my need as it mostly measures the API response time for each request.
Does anyone know any tool/library/test suite that could help me?


texts: How to intercept Metamask error to display a more user friendly message?

texts:
I have a Dapp with smart a contract that has a revert function that can only happen in a specific case.

When the revert is triggered, Metamask shows the error like this:

Is there a way to "intercept" this error and display something else more user friendly?


texts: Getting Opcode error in remix using transfer method

texts:
This is the contract:

pragma solidity ^0.4.15;

contract Test {

    address public owner = msg.sender;

    function sendWeis(address _receiver, uint256 _amount) returns (bool) {

        _receiver.transfer(_amount);
        return true;

    }

    function getBalance(address _owner) constant returns (uint256) {

        return _owner.balance;
    }
}

I'm trying to send ether from account A(owner of the contract) to B.

I get this error in solidity browser:

  Exception during execution. (invalid opcode). Please debug the
  transaction for more information.

If I use send() instead of transfer() I don't get any errors, but ethers are not transferred, even though the transaction is executed successfully.

Seems that I'm doing something fundamentally wrong since it doesn't work either in testrpc or  geth. Thanks.


texts: Solidity Math: What's wrong with the function

texts:
What is wrong with the math logic in the function? It shorts the supply of tokens and it distributes much less than expected.

if the contract owns 1000 tokens and the total ether fund size is 30 ether (accumulated by two contributions of 10 ether & 20 ether), then 33,33% of the 1000 tokens should be given to the contributor with a contribution of 10 ether and the rest to the contributor of 20 ether.

function distribute() external onlyOwner {

    for (uint256 i = 0; i < contributors.length; i++) {
        if (contributed[contributors[i]]) {

            uint256 tokensToDistribute = ((token.balanceOf(environment)).mul(((contributions[contributors[i]].mul(100)).div(funds))).div(100));
            token.transfer(contributors[i], tokensToDistribute);

            tokensDistributed = tokensDistributed.add(tokensToDistribute);

            emit TokensDistributed(contributors[i], environment, token.balanceOf(environment), tokensToDistribute, true);
        }
    }
}


texts: Why is one of my transactions using more gas when both carry out the same function of sending ether?

texts:
Below are two functions that I have in a simple lease smart contract. I am running a TestRPC node with Remix on version 0.5.1.

When I call the terminate function, it executes and terminates the contract as it is supposed to, sending the balance of ether to the landlord. However the withdraw function is supposed to allow the landlord to withdraw without terminating the contract.

 function withdraw () public
    {
        emit withdrawn();
        address payable landlordAddpayable = address(uint160(address(landlordAdd)));
        landlordAddpayable.send(address(this).balance);
    }

    function terminate() public
    {
        emit contractTerminated();
        address payable landlordAddpayable = address(uint160(address(landlordAdd)));
        landlordAddpayable.send(address(this).balance);
        //rents paid are forwarded to the landlord
        state = State.Terminated;
    }

Original code sourced from medium.com and altered

Thanks


texts:
I am unable to solve the error mentioned below.
Error: Data location must be "memory" for return parameter in function, but none was given.
    function fromHex(string memory s) public pure returns(bytes)

Please help to solve the same.
Here is the code:

pragma solidity ^0.5.0;
contract SampleContract
{
    function fromHexChar(uint c) public pure returns(uint)
    {
        if(byte(c) >= byte('0') && byte(c) <= byte('9'))
        {
            return c - uint(byte('0'));
        }
        if(byte(c) >= byte('a') && byte(c) <= byte('f'))
        {
            return 10 + c - uint(byte('a'));
        }
        if(byte(c) >= byte('A') && byte(c) <= byte('F'))
        {
            return 10 + c - uint(byte('A'));
        }
    }

    function fromHex(string memory s) public pure returns(bytes)
    {
        bytes memory ss = bytes(s);
        require(ss.length%2 == 0);

        bytes memory r = new bytes(ss.length/2);
        for(uint i=0; i<ss.length/2; ++i)
        {
            r[i] = byte(fromHexChar(uint(ss[2*i]))*16 +
            fromHexChar(uint(ss[2*i+1])));
        }
        return r;
    }
}


texts: Sending transactions without downloading the blockchain

texts:
I'm rather new to this world and it's a bit overwhelming.

I would like to manage an eth address from a lightweight device (think of a raspberry). I want to handle incoming transactions i.e resend some of the received eth to another address. Here are my issues:

Can I do this handling without having to sync all the ethereum blockchain?
If so, what language/framework do you advise?
I want to handle an existing wallet and I got the private key, how could I use it? I mean, just pass the private key in a function or I have to restore it somehow? (I guess this depends on point 2)

Any pointing to the right direction will be greatly appreciated :)

Thanks a lot for the help.


texts: reference a deployed contract in truffle or node.js

texts: I have a previously deployed contract on my PRIVATE-NET which I know its address. Now I am using truffle. How do I reference this contract in truffle console using its address? I looked through web3.eth interfaces but cannot find a function which does this. The contract deployed is done using Mist, I tried use the contract name in Mist but truffle cannot find it.


texts: Error: VM Exception while processing transaction: out of gas - Truffle

texts:
I'm facing some issue with test cases, I wrote some simple function in my smart contract as following:

function Create (
    bytes32 _a,
    address _b,
    string _c,
    address[] _d,
    uint256[] _e,

) public pure returns(bool){
    return true;
}

And here is the test case:

describe("Unit Test For Create Method", () => {
    it("first test case", async () => {
        const estimateGas = await Instance.Create.estimateGas(a, b, c, d, e);
        console.log(estimateGas);
    });
});

while running test case, it's giving an error Error: VM Exception while processing transaction: out of gas

If I remove any single parameter, it starts working..
so, I assume there is an issue with number of arguments..any help?

Edit:
I have defined variable globally:

contract('Unit Test for smart contract', function(){
    let a = "XVXIJLO-9XNQ-ZQWF-OLAF-E14L09FHZALQ",
        b = web3.eth.accounts[1],
        c = "fileHash",
        d = ['s1','s2'],
        e = [0,1,2],
        Instance;

        // test case here
}


texts:
The ERC20 token standard specifies balanceof() to return a constant.

function balanceOf(address _owner) constant returns (uint256 balance)

But the balance amount might change or am I getting something wrong here?


texts: Sending ether from one contract to another

texts:
I have a function makePayment in one Contract:

function payLoan(Loan _loanAddress) payable onlyOwner public {

// Outgoing payment
Loan myLoan = Loan(_loanAddress);
uint256 payment = msg.value;

// Make payment if sufficient funds, otherwise only pay what is available
if (funds >= payment){

    // Make payment
    myLoan.makePayment.value(payment);
    funds -= payment;
}else{

    // Partial payment
    myLoan.makePayment.value(funds);
    funds = 0;
}

and I want to make a payment into another contract with the function makePayment:

    function makePayment() onlyOwner payable public {

        received = msg.value;
        if (received >= balance){
            received    -= balance;
            amtPaid     += balance;
            balance     = 0;
        } else {
            balance     -= received;
            amtPaid     += received;
            received    = 0;
        }

    }

It seems to work and the funds are received by the first contract, but the amount sent is never received. None of the variables are changed as a result of the call. Any idea what is wrong? Thanks.

Here is a further simplification and revised attempt. I still get the error "transact to Borrower.payLoan errored: VM error: revert.
revert  The transaction has been reverted to the initial state.
Note: The constructor should be payable if you send value.  Debug the transaction to get more information."

    pragma solidity ^0.4.18;

contract Borrower {
    uint256 public amountReceived;

    function Borrower() payable public {
    }

    function payLoan(Loan _loan) payable public {

        // Outgoing payment
        Loan loan = Loan(_loan);
        amountReceived = msg.value;

        // Make payment
        loan.payLoan.value(amountReceived)();
    }

    function getThisBalance() public view returns (uint256){

        return this.balance;
    }
} // Borrower

contract Loan {
    address public borrower;
    uint256 public loanBalance;

    function payLoan() payable public {
        uint256 received = msg.value;
        loanBalance -= received;
        }

    function Loan(address _borrower) payable public {
        borrower    = _borrower;
        loanBalance = msg.value;
        }

    function getThisBalance() public view returns (uint256){

        return this.balance;
    }
} // Loan


texts: Error Truffle Console: web3.fromWei is not a function

texts:
I am executing commands from a tutorial at:
JustDev Tutorial on Medium
I am executing the command:
> truffle(ganache)> balanceInEth = address =>
> web3.fromWei(getBalance(address).toString())

I am getting the message:

[Function: balanceInEth] truffle(ganache)>
balanceInEth(victim.address) evalmachine.:0 balanceInEth =
address => web3.fromWei(getBalance(address).toString())
^
TypeError: web3.fromWei is not a function
at balanceInEth (evalmachine.:0:32)
at evalmachine.:0:1
at sigintHandlersWrap (vm.js:98:15)
at ContextifyScript.Script.runInContext (vm.js:56:12)
at runScript (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:465120:21)

Somebody please guide me.
Zulfi.


texts: Warning! Error encountered during contract execution [Reverted] web3

texts:
When calling from Remix IDE, it executes successfully.
But when calling from web3 v1.2.9, it gives the above error.
Here is the contract :
https://ropsten.etherscan.io/address/0x8ec0ca8b2fb402ff86cee42ade5e9072a6156b63#code
sol code:
/**
 *Submitted for verification at Etherscan.io on 2020-07-16
*/

pragma solidity 0.5.1;

contract SendEther {

    event Transferred(uint256 value , address sender);

    function() external payable{}

    function SendEtherToAddresses(address payable[] memory _addresses, uint256[] memory _amounts) public payable {

        for (uint256 i=0; i < _amounts.length; i++) {
            _addresses[i].transfer(_amounts[i]);
        }

    emit Transferred(msg.value, msg.sender);
    }
}

js code:
window.web3 = new Web3(ethereum);
ethereum.enable();
eth_Contract = new web3.eth.Contract(abi, contractAddress);

var addresses = '0xB0Dc12Ef30D707A52a079d915435Ee0B5C03e8CC';
var amounts = '0.0005'

const address = web3.utils.toChecksumAddress(ethAddress); // metamask address

  Eth_Add_Arr = addresses.split(",");
  Eth_Amt_Arr = amounts.split(",");

                        var Eth_Amt_Arr_1=new Array();
                        TotalAmount = 0;

                        for (var i = 0; i < Eth_Amt_Arr.length; i++) {

                            var x = parseInt(web3.utils.toWei(Eth_Amt_Arr[i], "ether"));
                            Eth_Amt_Arr_1[i] = x.toString();
                            TotalAmount += x;
                        };

                        eth_Contract.methods.SendEtherToAddresses(Eth_Add_Arr, Eth_Amt_Arr_1).send({
                            from: address,
                            to: contractAddress,
                            value: TotalAmount,
                            gasPrice: web3.utils.toWei("1", "Gwei"),
                            gas: 40000
                        },
                            (error, transactionHash) => {
                                if (!error) {
                                    console.log(transactionHash);
                                    SaveRegistration(address, sponsorId, transactionHash);
                                }
                                else {
                                    swal(e);
                                }
                        })

Please help!


texts: false Transaction mined but execution failed

texts:
I was trying to deploy my smart contract to Kovan test network using Remix IDE,although it compiles successfully but when I try to deploy it I get this error message
"false Transaction mined but the execution failed"
My transactions hash is "0x1e15c237c4329c63d74f7a3e63e3c9a2b3921d4eaf4bce304baf734a6c35df68"
The smart contract code is a flattened version of several contracts. see it here on a pastebin.


texts: When i am deploying contract getting the "Error: The contract code couldn't be stored, please check your gas amout"

texts:
case 1.
When my contract estimate gas is 72,75,790 by web3.eth.estimateGas method in my private blockchain.It works fine and contract deployed.
case 2.
My Contract estimate gas is 50,000,000.and passing gas amount as 50,000,000 + 300,000.
but unable to store contract in ethereum-blockchain using web3 api in nodejs
Error: The contract code couldn't be stored, please check your gas amount.
Note:- I have already setted  gasLimit is 200,000,000,000(i.e more than estimated gas) at the time of private blockchain creation.


texts: Ganache: How to see block data in every node?

texts:
I'm using ganache to simulate and a local blockchain network, and web3.py to interact with it.
One aspect of blockchain is transparency: all transactions, once mined, are written into the ledgers of every node.
How do I see this for myself with the ganache GUI?
I'd like to verify for myself that the tx has been written into all of the nodes


texts: Uncaught Type Error when calling a contract function using the web3 JavaScript API?

texts:
I wrote a contract to enable registration of a name. As an example, one of the functions takes in a name as a string, then outputs information on the registration of the name (name, registrant, last time that name was updated, registration ID, and whether or not it's currently registered). I can call the function in the Truffle console just fine, but keep getting an Uncaught TypeError when using the web3 JavaScript API to call the same function and I don't know why.

Here's what it looks like in the Truffle console:

When I try to call this same function in a JavaScript console in Chrome (using React to develop a front-end), I get this error and I'm not sure why:

inpage.js:7928 Uncaught TypeError: Cannot read property 'match' of undefined

Here's an image showing the function I'm calling with the error:

The nameRegContract object was created like this for reference:

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
var nameRegABI = [... ABI ...];
var nameRegAddress = '0x23fa6b40bdf47a6a41feb62077dab84213daa624';
var nameRegContract = web3.eth.contract(nameRegABI).at(nameRegAddress);

Wondering if anyone knows why I'm getting this error/if I'm using the web3 JavaScript API incorrectly?


texts: How to convert an address to bytes in Solidity?

texts: What is the recommended way to convert an address to bytes in Solidity?


texts:
On sending a number of concurrent transactions to geth running a private network with a small number of mining peers , i notice that transaction hashes are generated for each of those transaction , but most of the time , some of them do not get mined and the getTransaction method for the hashes of these transaction returns null. Why is this occurring ?

The ratio of these transactions is almost 10 : 1 (total transactions : null transactions). All other transactions get successfully mined.

I am mining only on the peers whereas the node that generates transaction is not mining . What is wrong here ?

Geth Instance details are - instance: Geth/v1.5.9-unstable-29645045/linux/go1.7.4


texts: How to guarantee the order of transactions in MetaMask?

texts:
I create my transactions with ethers.js and push them into an array like this:

const promises = [];
promises.push(createTokenApprovalTx());
promises.push(createFooTx());

It's important that the token approval transaction is signed and submitted before the foo transaction, because the latter moves tokens around. Therefore, I order them properly and set a higher nonce on the foo transaction.

I then submit them like this:

const txs = await Promise.all(promises);
await Promise.all(
  txs.map(tx => {
    return tx.wait(1);
  }),
);

The catch is that the order is not guaranteed. Sometimes, roughly 3 in 4 times, it is indeed the case that the token approval comes first, but not all the time.

How to accomplish this with MetaMask or, generally, with any JSON-RPC provider?


texts:
can someone please tell me an alternative to Ganache? Tried installing ganache on my laptop and it's not supported. Ganache works on 64 bit computers and mine is 32bit. Is there a way I can go round this problem?
I have contracts I want to deploy but I can't because I don't have a local block chain. Or is there a way I can import the whole project file to remix IDE and run it there?


texts: simulation or performance evaluation with Ethereum testnet

texts:
I was if you could help me about simulation.

How can I simulate the performance of my following IoT-based Application with Ethereum testnet?

In my senario,there are some nodes that store sensor data in Distributed Hash Tables (DHTs) while the pointer to the DHT storage address is stored in the blockchain.

How I can show the performance of system and other parameters such as required time to add new block, proccessing time, update peer's blockchain with received transaction?


texts: I have been working on a project, where I would like to trace all transactions from a block and for this reason I have been using a fast-syncing node. It works well, the only issue is that querying the node using the debug_traceBlockByHash endpoint is very slow. Slower than the speed of new blocks being mined. For this reason after a few blocks, I get behind and eventually due to pruning of the data, I don't have access to trace information anymore. So, my question is if it's possible to save the trace information during syncing or when receiving a new block. Thanks!


texts: What is the difference between web3.js and ethjs?

texts:
I've seen people using both in their codes - https://github.com/ethereum/web3.js and https://github.com/ethjs.

Do I need both? Does ethjs depend on web3?


texts: How to programmatically detect and accept ETH and ERC20 deposits

texts:
I'm looking to replicate the functionality provided by cryptocurrency exchanges such as Kraken and Poloniex when it comes to depositing ETH and tokens. Namely:

Users can generate and send funds to one or more deposit addresses for ETH, EOS, OMG, and other tokens
The relevant user's balance is updated when a deposit is detected for a given token or asset
Sent funds are stored in accounts controlled by the exchange

What's the best way to achieve this?

I have a few ideas using web3, but I'm not sure they're the most efficient or scalable solutions:

ETH

For each user who wants to make a deposit, generate an ETH address and private key using web3.eth.accounts.create(). Map the generated address to the user and store the private key.
Use web3.eth.filter to monitor the latest block on the ETH blockchain. Match transactions in the block against the user addresses stored and update user balances as appropriate.

Issues with this approach: monitoring each block and matching against stored addresses is computationally intensive especially if the number of addresses tracked becomes large (hundreds of thousands). How can this scale?

ERC20 Tokens

For each user who wants to make a deposit, generate an ETH address and private key using web3.eth.accounts.create(). Map the generated address to the user and relevant token, and store the private key.
ERC20 contracts emit Transfer events when a transaction happens on the contract. Monitor this event using web3.eth.filter. When a Transfer event occurs for an address that exists in our database, update the relevant user's balance on the exchange with the transferred amount.

Issues with this approach: How do you set up the web3 filter to detect Transfer events only from the token in question, not the entire network? Should I set up 1 filter per address, or 1 filter for all user addresses? How many addresses can web3 filter track at a time? What if the tracked addresses become very high (hundreds of thousands)?

Is this the right way to think about all this or am I missing something? I'm surprised there isn't more obvious documentation around this flow since it's quite popular (in exchanges and any other service that accepts digital currency payments).


texts: Forward vs Reverse Resolver for ENS domains?

texts:
what is the difference between setting forward vs reverse Resolver for a .eth ENS domain? what is the difference, and what matters for handing out to your benefactors so that they can send you Ether to that domain?
"public resolver" also doesn't make much sense


texts: I sent ETH to Ledger Nano S address before updating firmware

texts:
I saw an option to update firmware from 1.2 to 1.3 on my Ledger Nano S, and and after I accidentally set up Ledger Nano S as a new device as I didn't realize that restoring was an option.

I sent ETH to an address in the wallet from my Coinbase wallet, the address i got from myetherwallet after connecting to Nano S.

Is there any way to import or recover that wallet address into the Nano?

Thanks for any help.


texts: DeclarationError: identifier not found or not unique 'candidate'

texts:
I got the above error at the mapping 'candidate'

pragma solidity ^0.4.22;

contract Election {
  struct Candidates {
    string name;
    uint voteCount;
  }

  struct voter {
    bool authorized;
    bool voted;
    uint vote;
  }

  address public owner;
  string public electionName;

  mapping(address => voter) public voters;
  Candidate[] public candidates;
  uint public totalVotes;

  modifier ownerOnly() {
    require(msg.sender == owner);

    _;
  }

  function electionName(string _name) public {
    owner = msg.sender;
    electionName = _name;
  }

  function addCandidate(string _name) ownerOnly public {
    candidates.push(Candidate(_name, 0));
  }

  function getNumCandidate() public view returns(uint) {
    return candidates. length;
  }

  function authorize( address _person) ownerOnly public{
    voters[_person].authorized = true;
  }

  function vote(uint voteIndex) public {
    require(!voters[msg.sender].voted);
    require(voters[msg.sender].authorized);

    voters[msg.sender].voted = true;
    voters[msg.sender].voteIndex = _voteIndex;

    candidates[_voteIndex].voteCount += 1;
    selfdestruct(owner);
  }
}

Error

browser/Election.sol:22:5: DeclarationError: Identifier not found or not unique.
    Candidate[] public candidates;
    ^-------^


texts:
I want to know if my use case can be implemented on Ethereum network's smart contracts.

This is my use case:

A P2P app (similar to torrent clients) installed on PC or phone

I (sender) click on a send button on my client app
a data packet is sent from my device to a destination device using a P2P network, at the same time this triggers Smart contract A between sender and receiver.
When data packet is received by receiver, it check the authenticity of the data packet
Receiver client app sends the result of the authenticity check to the smart contract A
If the data received is authentic, smart contract takes X ETH amount from receiver wallet and send it to sender wallet. If not contract is over without nothing

Is such a use case manageable using smart contracts, does it require external components, and what should I expect in term of gas.

Thanks a lot for your help.


texts: (uint256(keccak 256(block.blockhash(b) make an ethereal dice game with hash?

texts:
https://etherscan.io/address/0xa65d59708838581520511d98fb8b5d1f76a96cad#code

Ether system gets 50 numbers in 100 figures and  (Fixed_value = (17) Compare with Process according to result

Get the code and:
Contract owner full

   pragma solidity ^0.4.2;

library Deck {
    // returns random number from 0 to 51
    // let's say 'value' % 4 means suit (0 - Hearts, 1 - Spades, 2 - Diamonds, 3 - Clubs)
    //           'value' / 4 means: 0 - King, 1 - Ace, 2 - 10 - pip values, 11 - Jacket, 12 - Queen

    function deal(address player, uint8 cardNumber) internal returns (uint8) {
        uint b = block.number;
        uint timestamp = block.timestamp;
        return uint8(uint256(keccak256(block.blockhash(b), player, cardNumber, timestamp)) % 52);

additional:

Fixed_value = (17)
payment = 2.07

if (uint256(keccak256(block.blockhash(b) ==Fixed_value {
true
      total= Player's ether * payment;
        ether Send to player account;

if (uint256(keccak256(block.blockhash(b) ==Fixed_value {
  false
     Stop
}
}


texts: ethereum.org/crowdsale ALSO FOR USER TOKENS?

texts:
The information of the webpage says something about crowdsale/equity token. Since the token I want to distribute is a user/utility token; is this a good source to learn the code?

If not, what would be a good source to retrieve information about issuing a user token?


texts:
I deleted a file from my Ethereum 'Chaindata' directory, the blockchain got reset and all the accounts and mined blocks were gone. Also, I could add random text into one of the log files.

How does this justify the immutability feature of Blockchain?

Is there any way I can prevent deletion of the file from the Chaindata directory?


texts: Will sharding allow for a much lower gas limit?

texts: The current gas costs are for all nodes to process a transaction or contract function call. Once we have sharding, only a subset on the nodes(1 shard) will process that transaction/contract function call. So is it safe to assume that gas costs will basically be current gas costs/total number of shards?


texts: Unable to deploy contract on Besu network(docker) using dynamic IP

texts:
I am stuck with a weird situation. I create a local Ethereum network with Hyperledger Besu in docker environment. I try to deploy contracts to a rpc node using Truffle(different container in same docker network).

1.) When I have static IP configured for Besu nodes in the docker-compose, and I use the service name in truffle, contract deployment goes through fine.

2.) If I do not configure static IPs, in the docker-compose, for some reason the contract deployment is stuck. Why?

I have tried to see if there is network connectivity issue. Pinged the Besu node via hostname and IP(dynamically allocated by docker) which went through.
Here's the trailing logs I see, post which it is indefinitely stuck -

truffle-envt-besu-setup |
truffle-envt-besu-setup | 1_initial_migration.js
truffle-envt-besu-setup | ======================
truffle-envt-besu-setup |
truffle-envt-besu-setup | Deploying 'Migrations'
truffle-envt-besu-setup | ----------------------
truffle-envt-besu-setup | > transaction hash: 0x1a673f0f62c4f0690eb444d4922cd257b16f72bfff3e4d0362a50f3f9353ede6
truffle-envt-besu-setup | - Blocks: 0 Seconds: 0

Here's a snippet of the docker-compose -

 node2.eth.local:
    image: hyperledger/besu:1.3.9
    command: >-
      --data-path=/var/lib/besu --genesis-file=/var/lib/besu/genesis.json --rpc-http-enabled
      --rpc-http-host=0.0.0.0 --rpc-ws-enabled --rpc-ws-host=0.0.0.0 --discovery-enabled=false
      --p2p-host=0.0.0.0 --rpc-http-api=ETH,NET,WEB3,DEBUG,MINER,ADMIN,TXPOOL,CLIQUE
      --rpc-ws-api=ETH,NET,WEB3,DEBUG,MINER,ADMIN,TXPOOL,CLIQUE --rpc-http-cors-origins='*'
      --host-whitelist='*' --min-gas-price=0
    ports:
      - 8545:8545
      - 8546:8546
    volumes:
      - './besu/node2:/var/lib/besu'
    networks:
      local_net:

  rpc.node2.eth.local:
    image: pegasyseng/ethsigner:0.4.0
    command: >-
      --chain-id=12345 --downstream-http-host=node2.eth.local --downstream-http-port=8545
      --http-listen-host=0.0.0.0 --http-listen-port=8555 file-based-signer
      --password-file=/var/lib/ethsigner/password.txt --key-file=/var/lib/ethsigner/keystore/account.txt
    ports:
      - 8555:8555
    volumes:
      - './ethsigner/node2:/var/lib/ethsigner'
    depends_on:
      - node2.eth.local
    networks:
      local_net:

networks:
  local_net:
    driver: bridge

Here's a snippet of the truffle-config.js file -

     besu_docker: {
            host: "rpc.node2.eth.local",
            network_id: "*",
            port: 8555,
            gas: 4500000,
            gasPrice: 0
       },

Is there something obvious I am missing?


texts:
How do we start mining Ether on a Debian / Ubuntu / GNU+Linux based computer?

Are there PPAs or special repositories?


texts: Is there available source code for the Ethereum parser (JS/Solidity or Python/Serpent?

texts: I've tried looking at the source code, but I'm unfamiliar with the structure. I can't seem to find a parser module or source code. I'm attempting to understand the parser and perhaps write one from scratch (personal project). It would really help if there was source code for either of the parsers for Serpent or Solidity that could be found.


texts: Is the signature generated by "web3.personal.sign" different with "web3.eth.sign"?

texts:
Are web3.personal.sign and web3.eth.sign difference in value of generate signature ? Or both of them generate an equal output ?

I could test web3.eth.sign using testRPC, however web3.personal.sign with testRPC gives error and I could not compare the output of both method with the same input.


texts: How is Ethereum's Proof-of-Stake different from Peercoin and NXT's Proof of Stake?

texts: Currently peercoin and nxt are one of the few POS coins out there. How is Ethereum's POS different from these 2 and others if they are available?


texts: Why are there errors in the code I copied in a book called Ethereum smart contracts development”

texts:
pragma solidity ^0.4.11;
contract simpleVotingDapp {
/*
The key of the mapping is candidate name stored as type bytes32 and value is an unsigned integer to store the vote count
*/
mapping (bytes32 => uint8) public votesReceived;
/*
We use an array of bytes32 instead to store the list of candidates
*/
bytes32[] public candidateList;
/* This is the constructor which will be called once when we deploy the contract to the blockchain.
When we deploy the contract, we will pass an array of candidates who will be contesting in the election
e.g.["Tom","Dick","Harry"]
*/

function simpleVotingDapp(bytes32[] candidateNames) {
    candidateList = candidateNames;
}

// This function returns the total votes a candidate has received so far
function totalVotesFor(bytes32 candidate) returns (uint8) {
    if (validCandidate(candidate) == false) revert();
    return votesReceived[candidate];
}

// This function increments the vote count for the specified candidate. This
// is equivalent to casting a vote
function voteForCandidate(bytes32 candidate) {
    if (validCandidate(candidate) == false) revert();
    votesReceived[candidate] += 1;
}

function validCandidate(bytes32 candidate) returns (bool) {
    for(uint i = 0; i < candidateList.length; i++ ) {
        if (candidateList[i] == candidate) {
            return true;
        }
    }
    return false;
}

}

I copied this code on a book by by Mukhopadyay, M. “Ethereum smart contracts development”;
function simplevotingDapp says
Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.
function simpleVotingDapp(bytes32[] candidateNames) {
^ (Relevant source part starts here and spans across multiple lines).
Every function says Warning: No visibility specified. Defaulting to "public".
function validCandidate(bytes32 candidate) returns (bool) {
^ (Relevant source part starts here and spans across multiple lines).
Lastly function validCandidate says Warning: Function state mutability can be restricted to view
function validCandidate(bytes32 candidate) returns (bool) {
^ (Relevant source part starts here and spans across multiple lines).
What is wrong with it?


texts: Transfer ether from one payable contract to another not working

texts:
Scenario:

I have users who will initiate booking for one product with x price. This contract will create a wallet contract between that user and the product so that he can return/cancel the booking at any time and get the refund or succeed.

Code:

User talks via contract EthBooking

contract EthBooking {
    function addBooking(uint listingId) public payable returns(uint bookingId) {
    bookingId =  BookingLibrary.book(ethDB, listingId, msg.sender, msg.value);

    //Send money to the contract
    return bookingId;
}
}

Booking Library code:

library BookingLibrary {

function book(address db, uint listingId, address sender, uint value)
        internal returns (uint bookingId)
{
    var cost = ListingLibrary.getCost(db,listingId);
        //Create Contract wallet
        EthWallet wallet = new EthWallet();
        //Send money to the contract
        wallet.receiveFunds.value(cost);
    return bookingId;
}

EthWallet Code:

contract EthWallet is Mortal {

function ethWallet() {
}

function receiveFunds() payable {

}

function sendFunds(address receiver, uint amount) {
    receiver.transfer(amount);
}

}

PROBLEM

The ethers sent is held in contract EthBooking and is not transferred to EthWallet as expected with code wallet.receiveFunds.value(cost); .

Please guide me about if the chosen approach is right and also why the ethers are not transferred to the destination.
PS: The code is shortened with removal of irrelevant parts to avoid confusion


texts: Is there any way to browse DeFi apps with "watch-only address" wallet?

texts:
I like to sign my transactions with a offline computer, then broadcast on the network with an online computer. This way I never get hacked.
With MEW, it is possible to send ETH to another address like this.
My question is: I want to explore DeFi DAPPS like uniswap, aave, ... with a browser like chrome and extract unsigned transaction.
Metamask and all other wallet will not let me connect front-end DAPPS with a "watch-only address" to give me a chance to extract unsigned transaction.
I started to look for a solution to connect front-end with a self injected script from console debug, but I could not find any way to do this!
I don't know if I am an idiot!


texts: ERC token not showing up in Etherscan.io search. Duplicate names exist

texts:
I created a token called LUV. There are other tokens with this name and they all show up in a search on etherscan.io but mine doesn't. The contract address is  0xaa0Cf928DBd96C8109c54f8809A0317581bC8BAe
I also sent 1000 of the tokens to another address and it didn't make a difference. It still doesn't show up in a search. Does anyone know how to resolve this issue?


texts: Transferring tokens to hardcoded addresses

texts: If i have a list of addresses and the exact amount of tokens that I want sent to each address, how can I hardcode a transfer function to transfer the exact amount of tokens to all specific addresses if called?


texts: Is there any way to ecrecover something twice? (I.e. something signed by two different people)

texts:
I have a signature. That signature was then signed by someone else.

If I pass this doubly-signed message as an argument to my function, is there a way to recover both signers?


texts:
This is my code:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Web3 from 'web3';

var ETHEREUM_CLIENT = new Web3(new Web3.providers.HttpProvider("http://localhost:8585"));

var peopleContractABI = [{"constant":true,"inputs":[],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getPeople","outputs":[{"name":"","type":"bytes32[]"},{"name":"","type":"bytes32[]"},{"name":"","type":"uint256[]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_firstName","type":"bytes32"},{"name":"_lastName","type":"bytes32"},{"name":"_age","type":"uint256"}],"name":"addPerson","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"people","outputs":[{"name":"firstName","type":"bytes32"},{"name":"lastName","type":"bytes32"},{"name":"age","type":"uint256"}],"payable":false,"type":"function"}]
var peopleContractAddress = '0xd2304e34972744ac6eba5548b54e7377539e1085'

var peopleContract = new ETHEREUM_CLIENT.eth.Contract(peopleContractABI).at(peopleContractAddress);

This is the error I get:

TypeError: (intermediate value).at is not a function

▶ 1 stack frames were collapsed.
Object../src/App.js
src/App.js:11
   8 | var peopleContractABI = [{"constant":true,"inputs":[],"name":"getContractAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getPeople","outputs":[{"name":"","type":"bytes32[]"},{"name":"","type":"bytes32[]"},{"name":"","type":"uint256[]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_firstName","type":"bytes32"},{"name":"_lastName","type":"bytes32"},{"name":"_age","type":"uint256"}],"name":"addPerson","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"people","outputs":[{"name":"firstName","type":"bytes32"},{"name":"lastName","type":"bytes32"},{"name":"age","type":"uint256"}],"payable":false,"type":"function"}]
   9 | var peopleContractAddress = '0xd2304e34972744ac6eba5548b54e7377539e1085'
  10 |
> 11 | var peopleContract = new ETHEREUM_CLIENT.eth.Contract(peopleContractABI).at(peopleContractAddress);
  12 |
  13 | class App extends Component {
  14 |   componentWillMount(){

Initially, I was getting the error:

"×
TypeError: ETHEREUM_CLIENT.eth.contract is not a function"

then I followed this solution by making 'ETHEREUM_CLIENT.eth.contract(abi)' into 'new ETHEREUM_CLIENT.eth.Contract(abi)' as per the second solution

When I saved these changes my error changed to "TypeError: (intermediate value).at is not a function".

Any ideas?


texts:
how to access the element of struct in array and mapping using assembly?
my code case:
contract Test {
    struct User {
        address addr;
        uint256 tokenAmount;
    }

    mapping (uint256 => User[]) public user;
    mapping (address => uint256) public userId;

    function test(uint256 pid, uint256 uid) {
        // how to implement the two code lines using assembly?
        User memory user_ =  user[pid][uid];
        userId[user_.addr] = userId[user_.addr] + 1;
    }
}

Thank u very much!!


texts: Opinions on setting variables via constructor vs setter function?

texts:
I haven't found any opinions about this online so far, so I'm soliciting opinions here.
What are the pros/cons of setting variables in the constructor of a Solidity contract versus having no constructor and setting those variables later via a setter method?
Are there significant gas tradeoffs?
Is it just a matter of style/opinion?
Appreciate any thoughts :)


texts:
I try deploy a contract to rotten network with truffle. I checked the last gas limit value in ropsten and I give the gas limit value of the last block But I get this error:
"Migrations" exceeded the block limit (with a gas value you set).
then I increase the gas value, I get an error again:
ran out of gas (using a value you set in your network config or deployment parameters.
can I automatically get the gas value in truffle-config file for ropsten?
thank you


texts: How can i connect my private blockchain network with public ERC20 token?

texts:
I have setted up a private blockchain network which is running in my server. I am ok with the process of creating smart contracts. We have to create a token that can be available in exchanges.

Question 1:
Can i connect with main network token using my private blockchain network?

Question 2:
How can i manage the token's transaction process with my private blockchain network?


texts: Is it possible to process tranactions only after a certain number of calls are made (without a significant increase in the gas price)?

texts:
I would like to process N number of transactions in batches.

When N people make a call to a transfer function, I would like to process all N transfers (and not before that last call is made).

Then, after all N transactions are processed, I would like to wait until another N number of calls is made (and so on).

I understand that I can make a map of addresses and their amounts to track the transfers, however, I do not want the gas price to be much higher because I am doing it in batches.

Can I do this (as explained above) without having a significant increase in the gas prices ?

Solidity version is 5.0 and above.


texts: How many key-value entries can be stored in Solidity Mapping data structure?

texts:
mapping(uint => uint) public myMap;

function store(uint key, uint val) public {
   myMap[key]=val;
}

function retrieve(uint key) public view returns (uint){
    return myMap[key];
}

Considering the above code, if we assume the size of uint is 256 bits(or 32 bytes), then can we store all possible 2^256 entries as key values in the mapping? each of these 2^256 can hold a uint value. So, the total space requirement to store the entire mapping data structure is (2^256)*32 bytes. Right? Since the state variables are stored in the blockchain itself, how it is possible to allocate and store such a huge memory in blockchain? What is the mechanism?
I have read an article, where it says for storage type state variables like mapping, we can populate a single entry (i.e. key-value pair). Only the caller need to pay the gas cost associated with a single entry writing. It also takes memory space for a single entry in the BC.
So, if that is the case- Can't I populate a mapping data structure using a loop(say, 10 lakhs entries in one go)? because then it consumes a huge gas cost? right? for e.g. the below code will not run due to excessive gas cost.
for(uint i=0;i<1000000;i++)
{
myMap[i]=2*i;
}
*How many entries can be populated at max in a single go using a loop?
But if I can populate a single entry every time(by calling the store function, mentioned above) and calling this function for 10 lakhs times, hopefully, this will work. Isn't it?
I am a little bit confused, please help me to understand the concept.


texts:
i added some data in smart contract mapping on remix i am getting values but with web3 i am getting 0 values

 const escrowCount = await neutralG.methods.totlaEscrows().call()

  for (var i = 1; i <= escrowCount; i++) {
  const escrow = await neutralG.methods.escrows(i).call()
  console.log(escrow)
  this.setState({escrows: [...this.state.escrows, escrow]})
}

this is my code

remix values

and this is web3 values where i am wrong?


texts: How exactly is computation performed on EVM by every node

texts:
Or in other words how smart contracts are mined?

I need help with filing some blanks to really understand that issue. Let me start with what I know.

The bitcoin approach (level easy)

In the standard blockchain, the miner composes the block of all transactions.

In the high abstract view it could look like this:

[PREVIOUS BLOCK HASH]
addr1 sends X to addr2
addr4 sends Y to addr3
.
.
.
nonce

The miner finds a nonce and publish the result to the network.

Then all other can check if the block is valid. A miner can, of course, ignore it, and mine but risks ending up with a smaller chain that everyone ignores.

The Ethereum approach

It is said that smart contracts are executed on each node, so I imagine it like this:

each miner get's a list of transactions and smart contract functions call, run those and create a block with results and try to solve it.

does the miners have deterministic way of choosing transactions/contracts' calls or every miner composes their own mix, and one wins?
If any creates different mix, so we cant think of each miner as running the same contracts (the order may differ, and the results would have been different, and those which were not solved on time are discarded)

one of the miner wins, and publishes the block which has transactions and run opcode, so it can be reproduced. The block includes also the results (like storage variables)
in order to confirm the block, other miners have to get the block, run the opcode, check for results and check the hash if correct

as I understand this is the part we mean, when we talk that code is run by every node (is that correct?)

I have a feeling I can have some wrong concepts about how it all works, so I need someone to show me where I'm wrong.

Is my idea of and Ethereum block correct (high abstract):

[PREVIOUS BLOCK HASH]
addr1 sends X to addr 2
addr4 calls function foo on contract Z
.
.
.
nonce

(probably the addr4 calls function foo on contract Z would be expanded to the actual opcode, so there's no room for interpretation anymore by other miners)

Hashing the whole thing gives a special hash, and the rest of the story is like with bitcoin - some other miner could ignore it, but risks being left with a chain that no one else accepts.


texts: Difference between types of sale activities for tokens

texts: I want to underatand whats the difference between a crowdsale,  airdrop,  ICO, ILO, ipo and presale. Are all these types of presale activities?


texts: Blockchain stalls on Testnet (and Main Network) - mist wallet 0.8.8, geth 1.5.6-stable

texts:
I am new to Eth.
I got the mist wallet, version 0.8.8
I got the geth 1.5.6-stable
I am running everything on Linux Mint 18.
The CPU is not an issue, RAM is not an issue, Connectivity is not an issue. The number of peers on the Main Network is 25, and on Testnet 10.

The download of the block-chain on the Testnet stalls saying 282 blocks left.
The download of the block-chain stalls in the Main Network stalls at 668,493. Every time I restart, the number of blocks that need to be downloaded goes up.

I am aware that people already had this issue, but I am not aware that anyone had the same issue with the Testnet. I have tried downloading using: geth --cache=1024 --jitvm but I do not see any progress (I am not sure if I am supposed to?) and the number of blocks to download in a wallet does not go down (I am not sure if that is the way it works).

I would like to download the block-chain data (lets say, with geth and be able to see some kind of a progress), and import it into a wallet, but to remain secure without downloading a third-party data. I would also like for the download not to stall.

Any advice?
Please explain all steps since I have started using Eth just a few days ago.


texts:
I'm  trying to test validAddress function from my contract ValidationUser, using truffle and test with JS. I checked the V value from the signature and its 27,28 so it is not the problem.
Also, I have the code inside Unity side that works ok with this function!
But inside the test it's failed on: addressCheck != to the sender address - the owner.
Any suggestions how to fix the test?

ValidationUser.sol:

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

function validAddress(
    int256 theMsg,
    uint8 v,
    bytes32 r,
    bytes32 s
) public payable returns (uint8) {
    bytes32 hash = keccak256(abi.encodePacked(msg.sender, owner, theMsg));
    address addressCheck = ecrecover(hash, v, r, s);
    if (addressCheck != owner) {
        revert(addressToString(addressCheck));
        //  return v;
    }
}

ValidationUser.js:

it('should return valid result from validAddress function', async function () {

    var EthUtil = require('ethereumjs-util');
    const messageToSign = web3.utils.toBN(12);
    //privateKey ot the owner - accounts[0]:
    const privateKey = "b25421d6dabd6e9119c45c4daf4ca4f8f86bd6761cc20c095906073da7c02471";
    var hash = EthUtil.hashPersonalMessage(new Buffer(accounts[2] + accounts[0] + EthUtil.intToHex(messageToSign)));
    var signature = EthUtil.ecsign(hash, new Buffer(privateKey, 'hex'));
    var signatureRPC = EthUtil.toRpcSig(signature.v, signature.r, signature.s)
    console.log(signatureRPC);

    const contract = await ValidationUserContract.deployed();
    const owner = await contract.getOwner();
    const theMsg = await contract.validAddress.call(messageToSign,
        signature.v,
        signature.r,
        signature.s, {
            from: accounts[2]
        });

});


texts: Am I wondering how can I validate simple money transfer from one address to another?  I'm querying the blockchain with etherscan and have transaction hash. Is it enough just to check from, to and amount, or I need to check something else?


texts:
I stumbled upon this Ethereum address. Etherscan calls it the ENS-BurnAddress. Currently, the account holds more than $9,000,000 US. My guess is that this is used to impose a cost on each bid so people don't spam the system.

What exactly is the ENS-BurnAddress? Does it make sense to simply throw away $9,000,000 (couldn't it be given to charity)? As unlikely as it is, what happens if someone coincidentally finds the private key?


texts: delegatecall (assembly) didn't change state variable in Remix with Web3 Provider

texts:
I am trying to test proxy pattern in Remix, which connected to my private chain with Web3 Provider. By the way, miner is working all the time. After invoking add function of Proxy contract, the state variable total of Proxy contract has not change. But with Javascript VM, it changed as expected.

Here is the code:

pragma solidity ^0.5.0;

contract Proxy {

    address public implement;
    // with Web3 Provider, it didn't change.
    // but with Javascript VM, It changed as expected.
    uint public total;

    function changeImpl(address _impl) public returns(bool) {
        implement = _impl;
        return true;
    }

    // according to proxy pattern, this should be fallback function.
    // i change it as named function just for convenience
    function add(uint a, uint b) external {
        address _impl = implement;
        assembly {
            let ptr := mload(0x40)
            calldatacopy(ptr, 0, calldatasize)
            let result := delegatecall(gas, _impl, ptr, calldatasize, 0, 0)
        }
    }
}

contract ImplContract {

    address public implement;
    uint public total;

    function add(uint a, uint b) public returns(uint) {
        total = a + b;
        return total;
    }
}

I am so confused why same code make different outcome. Any help would be appreciated.

Edit

Problem solved. The reason causing the failure is insufficient gas.


texts: Is opening a connection with geth secure?

texts:
I'm newly trying to do some tutorials in dapp development and I ran into an issue with security.

I was trying to sync with testnet through geth. For the most part, it went smoothly. However, I was alerted that the geth command tried to communicate with a suspected malicious IP address. The IP in question (and information about where the address has been used maliciously in the past) is: https://www.virustotal.com/#/ip-address/74.119.194.18

The command I used specifically was:

geth --testnet --syncmode "fast" --rpc --rpcapi db,eth,net,web3,personal --cache=1024  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"

Though I also tried the one on Github: https://github.com/ethereum/ropsten

Now I'm afraid of continuing to run the command. Can someone with more experience explain what are the implications of this and if it's secure to continuing running geth on my machine? How do I minimize risks if I want to continue developing on a personal computer? I'd prefer not to buy a completely separate computer just for dabbling in dapp development.

Thanks in advance for any help on this.


texts: How plausible are smartcontract enforced debt payments?

texts:
Quoting from a coindesk article,

  Recall that a blockchain is just a database, in this case a financial
  ledger containing the issued bond and some cash. So, when we talk
  about coupon payments, what we're actually talking about are database
  operations which take place automatically at an agreed time. While
  this automation is technically feasible, it suffers from a financial
  difficulty. If the funds used for coupon payments are controlled by
  the bond's smart contract, then those payments can indeed be
  guaranteed. But this also means those funds cannot be used by the bond
  issuer for anything else. And if those funds aren't under the control
  of the smart contract, then there is no way in which payment can be
  guaranteed. In other words, a smart bond is either pointless for the
  issuer, or pointless for the investor. And if you think about it, this
  is a completely obvious outcome

.

Is this objection fair? What are plausible responses? Do you all agree or disagree? What are plausible solutions? Curious to hear.


texts: Web3.js : eth.sign() vs eth.accounts.sign() -- producing different signatures?

texts:
I'm getting to grips with web3.js and have noticed an unusual issue with signing data.

When I sign a string with the web3.eth.sign() method, I am getting a different signature than if I use web3.eth.account.sign(). Note this latter method takes the private key as an argument.

I'm using the the latest web3.js beta and ganache. The test public address & private key I'm using in the examples below are:

address: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57
pkey: 0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3
//note 0x prefix

Code:

const signTest = async function(){

    // Using eth.sign()

    let accounts = await web3.eth.getAccounts();
    let msg = "Some data"

    let prefix = "\x19Ethereum Signed Message:\n" + msg.length
    let msgHash1 = web3.utils.sha3(prefix+msg)

    let sig1 = await web3.eth.sign(msg, accounts[0]);

    // Using eth.accounts.sign() - returns an object

    let privateKey = "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"

    let sigObj = await web3.eth.accounts.sign(msg, privateKey)
    let msgHash2 = sigObj.messageHash;

    let sig2 = sigObj.signature;

}

sig 1 and sig 2 do not match - the last 4 chars are different.

sig1: 0xb3bd48482d2c13a1d1f3bba070fb9de9375ffc61347504fb4e3aed903fbc073e65588de1207ed716e0e439bfa527d44ea13a28ba08f79ac025a0e42b683967ec00
sig2: 0xb3bd48482d2c13a1d1f3bba070fb9de9375ffc61347504fb4e3aed903fbc073e65588de1207ed716e0e439bfa527d44ea13a28ba08f79ac025a0e42b683967ec1b

However, note both signatures recover the correct account:

    let whoSigned1 = await web3.eth.accounts.recover(msgHash1, sig1)
    let whoSigned2 = await web3.eth.accounts.recover(sigObj)

Is this behaviour normal or could it lead to problems?

Thanks


texts: Does ERC-20 balanceOf function cost no gas?

texts:
Given that this is a sample balanceOf function code:

function balanceOf(address tokenOwner) public view returns (uint balance) {
    return balances[tokenOwner];
}

and this function is view function, does it's execution cost gas? If I understand correctly, balances array has to be read with SLOAD, and this is not gas free. balances is mapping(address => uint256) variable.

So how come that sites like etherscan.io provide interface to query balance of erc-20 tokens for free? E.g. this old EOS token contract, where I can run balanceOf on any address and get response instantly free of charge.

Thanks for explaining!


texts: can someone help me find what happened to my eth

texts:
I transferred some eth to my account from a trading platform and it shows transaction complete but there is an additional transaction which i didnt make which transfered my funds to an unknown address
0x8F8A1f9A6ba8ccbfebA7e3DA5ee6a4CFC82dCF2E this is my address
https://etherscan.io/address/0x8f8a1f9a6ba8ccbfeba7e3da5ee6a4cfc82dcf2e
the first 3 transactions were mine but i didnt make the last
the funds never showed up in my wallet either or someone drained it the second it arrived but i dont know how


texts:
I have a following contract:

pragma solidity ^0.4.17;

contract FileDetail {
 struct File{
    string fileName;
    string fileHash;
 }

 File[] private files;

 event Uploaded(
       string fileName,
       string fileHash
    );

 function setFile(string fName, string fileHash) public{
 File memory file = File({fileName:fName,fileHash:fileHash});
  files.push(file);
 emit Uploaded(fName,fileHash);
 }

 function getFile(uint256 index) external view returns(
 string fileName,
 string fileHash

 ){

   File memory file = files[index];
   fileName = file.fileName;
   fileHash = file.fileHash;

 }
}

I want to listen to the event emitted by this contract at server-side(not client-end) in Node.js. I want that a controller's method should be invoked when event is emitted so that I can save the values returned by contract in database.


texts: What is the safest way to use WS-RPC server in geth?

texts:
In this answer, it is suggested that it is not safe to use --wsorigins="*" for security reasons. What are the security reasons?
=> How could I make WS-RPC server connection secure in geth?
If I use following flags, would it be enough for security: --ws --wsaddr="127.0.0.1" --wsorigins "*"; where I have replace -wsaddr="0.0.0.0" with -wsaddr="127.0.0.1" in order to connect only from localhost.

--wsaddr value         WS-RPC server listening interface
--ws                   Enable the WS-RPC server
--wsorigins value      Origins from which to accept websockets requests


texts: How to check my sync status on Geth 1.5.5, Raspberry Pi 3

texts:
Have a Geth 1.5.5 node running on a raspberry pi 3.  When I type in

sudo systemctl status geth

I'll get ever changing time and block information.  Neat, but how do I know when I am synced up?  Is there another sudo command I should do?


texts:
require("babel-register");
require("babel-polyfill");
require("dotenv"),config();

module.exports = {
   networks: {
    development: {
      host: "127.0.0.1",
      port: 7547,
      network_id: "*"
    }
  },
  contracts_directory: './source/contracts/',
  contracts_build_directory: './src/abis/',
  compilers: {
    solc: {
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }
}


texts: Searching for a similar Dapp - finding the difference between datasets using the Merkle Tree

texts:
I am struggling with the project for my thesis. I need to develop a Đapp, which can

store a query ID as an integer and a large string array (which is
actually the output of a query to a database, given as a CSV file),
if the user provides an ID and another CSV file, the Đapp has to return the values, which do not match the ones stored on the blockchain for the given query ID.

For this reason, Ethereum's modified Merkle Patricia trie should be used. I should store the values of the CSV file in a trie, where the hashed values are the leaves and they are hashed pairwisely again and again, until reaching the root hash. Then, if the user provides an ID and a dataset, I should compare the root hash of the dataset with the one stored on the blockchain. If they don't match, I have to compare the hashes in the next level. Based on this comparison, I should go into the direction, where there is a mismatch and find the leaves in the end that do not match.

I'm really stuck with it and I'm not sure, how I should proceed. Should I implement a store and a validation function in Solidity? Or what is the right way to start?
I would love to see a sample application, which is similar.


texts: TheDAO difference between a hard and a soft fork?

texts:
There are currently different scenarios examined which include soft or hardforking the ethereum blockchain to mitigate the DAO attack.

What plans are there exactly and what are the difference between the hard and the soft fork?


texts: Block gas limit lower than required to deploy a contract

texts: I am trying to deploy a contract on ropsten network that requires ~7000000 gas, however the current gas limits are ~3.5mil on ropsten and I am unable to deploy the contract. What can I do about this?


texts:
Does Casper FFG in phase 0 take its checkpoints from the current ETH 1.0 POW chain?

I'm reading some conflicting material on this. The Casper FFG paper describes taking a checkpoint at every 50 POW blocks - has this changed? Blocks on POW chain are created every 12 - 15 seconds, so 50 blocks is ~ 60 - 75 seconds, but it will take 2 checkpoints ( 120 - 150 seconds) to finalize a transaction. So is this the case? Will it take 2 minutes for my transaction to finalize with Casper FFG POS?


texts: Contract creation - "previous existence" of the contract

texts:
I am reading the ethereum yellow paper, chapter 7, on contract creation.
There it mentions how the address a of the created contract is derived and then describes the state after the creation. Namely, it says that the newly created contract's balance is v+v' (where v is the endowment and v' is

  the acount's pre-existing value, in the event it was previously in
  existence

)

I wonder, in what case is it possible that account existed before its creation? (Or did I get something completely wrong?)


texts: Hi guys I am thinking of buying some serious rig for mining. Since AMD GPUs are out of stocks, I am thinking to buy 1080Ti. The problem is that I can't find any comparison of hashrate for this card and other 'high end' GPUs from AMD... My second question is: What about Titan X GPU? I am planning to invest about 5k in USD for this rig.


texts:
Can I get the ABI from an interface?
Let's say I have a file named ContractInterfaceExample.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
interface ContractInterfaceExample {

  function doStuff(bool val) external;
}

Can I get the ABI from this in web3.py?
# something like
import ContractInterfaceExample.sol?

w3 = Web3(Web3.HTTPProvider(os.getenv('RPC_URL')))
contract = w3.eth.contract(address=address, abi=???)


texts: Can I mix graphics cards on a mining rig RX480 and RX 470?

texts:
I want to experiment with building a mining rig to better understand ethereum. And to motivate myself to really learn as much about it as possible.

Is it possible to mix graphics cards on the same rig? I was thinking of mixing rx 470s and 480s due to them selling out.

I wanted to try and only buy 8gb models because i am afraid the 4gb models wont be usable too far into the future.

Could i run rx 470s along side rx 480s on the same rig or is this a terrible idea? I planned on starting with one card confirming I can join a pool and everything works and then scaling up.

Sub question, could i mix different models of the same graphics card? could i do a Nitro+ RX 470 with 8gb memory along side a 4gb rx 470? or could this be possible if I did them in pairs of two?

And even if its possible is there some reasons why this isnt ideal? I planned on mixing rx 470s and rx 480s because they seem to be some of the best hashing power per dollar out there right now. My electricity costs are very cheap and even if I loose money I am not concerned as my primary focus is learning.

My concern was so i could get started quicker without trying to buy cards that are super common so I need to find the exact same one to scale up.

http://forum.ethereum.org/discussion/comment/60436

It appears its possible, for what its worth I planned on running ubuntu because I am familiar with many linux distros and I think the Hash rates are typically better.


texts: How does a plot "Gas price to call / memory allocated" looks like?

texts:
Pretty simple question: i.e. I have a dummy contract like this one:

contract simple {
    uint[] dataArray;

    function push_one_more() {
        dataArray.push(1);
    }
}

How does the cost of calling push_one_more function depends of the dataArray size? Is it line, quadratically or maybe even exponential correlation?


texts: Trying to send ARC (Arcade City) tokens via MEW and encountering issues

texts:
I'm trying to move some ARC tokens from one place to another but encountering an error.

Link to transaction: https://etherscan.io/tx/0xd350ac4b5eba650957c9a086f851f1914bec0fe4808566bdc5fa26e0e0d9d80a

I'm receiving the following error on multiple attempts: Warning! Error encountered during contract execution [Bad jump destination]

According to the Arcade City whitepaper, tokens should be able to be moved around the second you take possession of them.

Any advice?


texts: How do you call a getter created by solidity?

texts: Apparently, solidity creates getter functions for public variables. How does one call them using javascript? (for testing within truffle)


texts:
I am trying to call a function on a smart contract using web3 and web3-eth-contract but I get the error Provider does not have a request or send method to use.
Here is the general code I am attempting:
const provider = new Web3.providers.HttpProvider(infuraEndpoint);
const web3 = new Web3(provider);
const contract = new Contract(tokenAbi.abi, tokenContractAddress);
contract.methods.someFun().call()
        .on('receipt', (res) => {.....

I am clearly missing something about how this works, but I can't figure out what it is.  Does anyone have an example of making a call to a function on an ethereum contract from node?


texts: API to get transactions between 2 blocks in Ethereum

texts: Assuming that I have a starting block and an ending block and I want to retrieve all the transactions that have occurred between these two blocks, is there any API that can help me achieve this?


texts:
I know that mist is the gui of geth and geth represent the real node of client.

here i have a question is that:

when i use geth to construct a contract named greeter1,

then i type eth.getCode(greeter1.address) in web3 i can directly get the
greeter1's address.

But when i use mist to construct a contract named greeter2,

then i use geth to type eth.getCode(greeter2.address), i can't directly get the greeter2's address in web3.

I use var "greeter2 = eth.contract(greeter2's abi).at(greeter2's contractaddress)" in web3 then i can get the address.

Isn't the mist just a gui of geth?

Why i can't directly get the contract's address from geth after using mist contruct the contract?

Isn't the abi just used between node from node, why in the same node i should use abi?

please help to correct me, thank you all!


texts: Error while doing truffle init. EDIT: Truffle isn't working itself

texts:
I am getting the following error while doing truffle init. I have followed the steps here:

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

When I get to truffle init, I get the following error:

/usr/local/lib/node_modules/truffle/build/cli.bundled.js:60353
!function(e,a){ true?module.exports=a():"function"==typeof define&&define.amd?define("ganache",[],a):"object"==typeof exports?exports.ganache=a():e.ganache=a()}(global,function(){return function(e){var a={};function t(c){if(a[c])return a[c].exports;var n=a[c]={i:c,l:!1,exports:{}};return e[c].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=e,t.c=a,t.d=function(e,a,c){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:c})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},t.p="",t.w={},t(t.s=1036)}([function(e,a,t){try{var c=t(1);if("function"!=typeof c.inherits)throw"";e.exports=c.inherits}catch(a){e.exports=t(1021)}},function(e,a){e.exports=__webpack_require__(3)},function(e,a,t){"use strict";var c="function"==typeof Symbol

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)

Can anyone tell me what is the problem here?

EDIT
While using truffle, truffle init, truffle unbox webpack, I am getting the same error.


texts: How to know if Dev renounced ownership of smart contract?

texts: Any help would be greatly appreciated. Also if someone can show the difference between a renounced and unrenounced coding that would be helpful.


texts: Who decides what kind of token reward a miner gets for mining a block?

texts:
Preamble:

To my understanding, a Bitcoin miner creates a new block, put
some necessary information in it incl. some transactions from other
participants and one transaction which sends 25 Bitcoin to his
own address as 'Reward' in case he manage to actually 'mine' the
block by solving a cryptologic riddle.

My Question:

How does it behave on ethereum?

On the ethereum blockchain new blocks will be also mined. But who
decides which reward the miner gets in case he successfully manage to
solve the riddle? Is it like on BTC that the miner itself just adds (one)
transaction with a specific amount of a specific Token?


texts: Can't withdraw from Crowdsale multiple times

texts:
I'm using a crowdsale contract (listed below) and on Ropsten network I just set founding goal to 1ETH send it to crowdsale address and then I can withdraw to beneficiary address but when I send ETH a second time I can't withdraw it anymore.

I find myself in need of a Crowdsale code where I can withdraw founds anytime or a way to automatically send ETH from crowdsale to ETH address just like someone sends 1 ETH to crowdsale:

That person receives Tokens
Crowdsale sends that ETH to specific ETH address
Owner of that address can withdraw anytime needed / multiple times

Here's the code I'm trying to use but only 1st withdrawal works (second stucks)

pragma solidity ^0.4.18;

interface token {
    function transfer(address receiver, uint amount) external;
}

contract Crowdsale {
    address public beneficiary;
    uint public fundingGoal;
    uint public amountRaised;
    uint public price;
    token public tokenReward;
    mapping(address => uint256) public balanceOf;
    bool fundingGoalReached = false;

    event GoalReached(address recipient, uint totalAmountRaised);
    event FundTransfer(address backer, uint amount, bool isContribution);

    /**
     * Constructor function
     *
     * Setup the owner
     */
    constructor(
        address ifSuccessfulSendTo,
        uint fundingGoalInEthers,

        uint milietherCostOfEachToken,
        address addressOfTokenUsedAsReward
    ) public {
        beneficiary = ifSuccessfulSendTo;
        fundingGoal = fundingGoalInEthers * 1 ether;

        price = milietherCostOfEachToken * 0.0001 ether;
        tokenReward = token(addressOfTokenUsedAsReward);
    }

    /**
     * Fallback function
     *
     * The function without name is the default function that is called whenever anyone sends funds to a contract
     */
    function () payable public {

        uint amount = msg.value;
        balanceOf[msg.sender] += amount;
        amountRaised += amount;
        tokenReward.transfer(msg.sender, amount * 10**18 / price);
       emit FundTransfer(msg.sender, amount, true);
    }

    /**
     * Check if goal was reached
     *
     * Checks if the goal or time limit has been reached and ends the campaign
     */
    function checkGoalReached() public  {
        if (amountRaised >= fundingGoal){
            fundingGoalReached = true;
            emit GoalReached(beneficiary, amountRaised);
        }

    }

    /**
     * Withdraw the funds
     *
     * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
     * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
     * the amount they contributed.
     */
    function safeWithdrawal() public  {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                if (msg.sender.send(amount)) {
                   emit FundTransfer(msg.sender, amount, false);
                } else {
                    balanceOf[msg.sender] = amount;
                }
            }
        }

        if (fundingGoalReached && beneficiary == msg.sender) {
            if (beneficiary.send(amountRaised)) {
               emit FundTransfer(beneficiary, amountRaised, false);
            } else {
                //If we fail to send the funds to beneficiary, unlock funders balance
                fundingGoalReached = false;
            }
        }
    }


texts: is there a way to estimate STARTGAS for a smart contract

texts:
From what I've read of the Ethereum white paper, it seems that the system is designed to charge you some GASPRICE per instruction in a smart contract's code.

Given this, it seems that there would be some premium placed both on efficient code, and on accurate STARTGAS estimates for existing contracts.

Does there exist some part of the Ethereum ecosystem that:

allows you to chain some contracts together via some kind of import-style syntax
allows you to see estimates of STARTGAS for an existing smart contract

and, most importantly,

(effectively) validates that STARTGAS amount so that you're certain that the contract that you're using is accurately pricing its instruction set?

Relatedly, is there any part of the Ethereum ecosystem that looks to measure and improve the efficiency of existing contract code? It seems like, if you are effectively paying per computational resource used, there would be a big market available in finding more efficiencies.


texts:
As stated on this website http://fluidai.co/examples/ one of Solidity's vulnerabilities is using an open version in pragma:

pragma solidity ^0.4.11;
You're telling the Solidity compiler to use the latest version of solidity bigger than 0.4.11. This is a problem because you're writing code with the way of doing things in an older version. Newer versions of Solidity deprecate functions like throw; and break your program if you're using them.

Is it really a problem?