texts: Geth traceTransaction: missing trie node

texts:
I have a fully synced Geth node and am trying to run the debug.traceTransaction() method, but it keeps giving me this error:

Error: missing trie node 60c376cdb14aec29386df043d081afcfa38a97da22e25d344c4104fd91cf6cc1 (path )

Here is the code I'm running (in Node):

web3.currentProvider.sendAsync({
    method: "debug_traceTransaction",
    params: ['0x3fac854179691e377fc1aa180b71a4033b6bb3bde2a7ef00bc8e78f849ad356e', {}],
    jsonrpc: "2.0",
    id: "2"
}, function (err, result) {
    console.log(err);
    console.log(result);
});

Oddly, it does seem to work for some transactions, so I think the code is correct. I've also tried deleting the data and re-syncing, but I keep get the same error.

These are the parameters I'm using for Geth:

geth --cache=1024 --rpc --rpcaddr "127.0.0.1" --rpcport "3010" --rpcapi "eth,net,web3,debug"

Is this a problem with the state trie? Is there something I need to do to make sure Geth is saving the states? Alternatively, is there a way of running the state for specific transactions?


texts:
I'm trying to switch a dapp to MATIC/Polygon.
I get this strange error:
Something went wrong: Error: Internal JSON-RPC error.
{
"details": "Unauthorized method: net_listening.",
"code": -32005
}
My code is like this:
 App = {
                web3Provider: null,

            init: function() {
                return App.initWeb3();
            },

            initWeb3: function() {
                if (typeof web3 !== 'undefined') {
                    App.web3Provider = web3.currentProvider;
                    web3 = new Web3(web3.currentProvider);
                } else {
                    App.web3Provider = new Web3(Web3.givenProvider || 'wss://rpc-mainnet.maticvigil.com/ws/v1/XXXXXXXXXXXXXXXXXXXXX'); //
                    web3 = new Web3(App.web3Provider);
                }

                web3.eth.net.getId().then(netId => {
                    switch (netId) {
                        case 137:
                            break
                        default:
                          $('#div_wrong_network').show()
                    }
                });

                getAccounts(function(result) {
                    App.account = result[0];
                });

                return App.initContracts();
            },

            initContracts: function() {$.getJSON("../XXXX.json", function(Response) {
                    var abi = Response.abi;

                            App.listenForEvents();
                            return App.render();

                        }

            },

            listenForEvents: function() {
                ...
            },

            render: async function() {
                if (App.loading) {
                  return;
                }
                App.loading = true;

                if(ethereum.selectedAddress !== null)
                {
                    web3.eth.net.isListening()
                   .then(() => {})
                   .catch(e => console.log('Something went wrong: '+ e));

                    if(window.ethereum) {
                        await ethereum.enable();
                    }
                }

....
Looks like web3.eth.net.isListening() is failing. What could be the problem? Thank you!


texts: Web3 and Metamask interaction doesn't work

texts:
I have my Metamask open connected to the Rinkeby network.
In Andreas' Mastering Ethereum book he has the following instructions to interact with Web3.
"Open a Javascript Console in a Broswer with Metamask running... and then type web3.eth.getTransactionCount('0xF962e09a92F4127bbC770c22aF41a0c3BaF0b66a')"
Why is this not working for me?  Thank you


texts: Why do most of my SHARES while mining eth read 0.00?

texts:
Im new to mining. I have 15 rigs. 8 AMD 5600 cards on each rig. I am mining on RAVEOS.
My workers are all hashing but only about half the cards on each rig show shares. Most say 0.OO shares. Is this normal? Some rigs have only one card sharing. and 7 say 0.00
How do I get them to share more? Sharing is caring, no?


texts: Is there any way to only find blocks where state changes of a contract occurred?

texts:
I'm currently using the ethereumjs libraries (https://github.com/ethereumjs) to iterate over the blockchain, replay transactions and read the state trie of a contract from the geth leveldb.

Currently I'm iterating over the blockchain sequentially to find state changes of the contract.

Is there any way to only find blocks where state changes occurred? Maybe through the state trie references depicted here (How Ethereum state tree is formed?)?

I know there could be a way using bloom filters if the contract produces logs but what if not? (correct me if I am wrong with this statement)


texts: DB - How do I roll back to a block height?

texts:
I was informed on this post that I was, indeed, on a fork. My client starts syncing and encounters a discrepancy with my local DB copy. My peers then vanish.

In my case, it would be a great hassle if I had to delete my entire DB copy, since it seems like I need to download GB of data again.

Fortunately, my client (Parity) kind of informs me of the block height where things went wrong.

2017-09-21 02:11:00  Syncing #1701857 4507…7213     0 blk/s    0 tx/s   0 Mgas/s      0+    0 Qed  #1701857    2/25 peers   516 KiB chain 66 MiB db 0 bytes queue 10 KiB sync  RPC:  1 conn,  4 req/s, 124 µs
2017-09-21 02:11:05  Stage 3 block verification failed for #1701858 (dec2…31af)
Error: Block(InvalidDifficulty(Mismatch { expected: 102912444, found: 102995535 }))
2017-09-21 02:11:35     0/25 peers   658 KiB chain 66 MiB db 0 bytes queue 54 KiB sync  RPC:  1 conn,  0 req/s, 100 µs

How do I roll back my DB copy to block height 1701857 so I can start syncing from that point?


texts: Where does geth store data except for the AppData\Roaming\Ethereum folder?

texts:
The AppData\Roaming\Ethereum folder on my computer weighs 5GB, but geth has reduced my disk space by a lot more than 5GB.

Where else does it store data?


texts: When running geth to sync a full node, what is the meaning of cache and handles?

texts:
What does it means:

cache=128 handles=1024

how to change those values?


texts:
I am trying to understand how multiple inheritance in Solidity works with this snippet of code. where contract C inherits from A,B with each having function foo.

pragma solidity ^0.6.0;

contract A {
    function foo() public pure returns (uint8){
        return 1;
    }
}

contract B {
    function foo() public pure returns (uint8){
        return 2;
    }
}

contract C is A,B {

}

I got the following error when I tried to compile

contract C is A,B {
^ (Relevant source part starts here and spans across multiple lines).
browser/multiple_inheritance.sol:4:5: Definition in "A":
function foo() public pure returns (uint8){
^ (Relevant source part starts here and spans across multiple lines).
browser/multiple_inheritance.sol:12:5: Definition in "B":
function foo() public pure returns (uint8){
^ (Relevant source part starts here and spans across multiple lines).

Does it mean in Solidity 0.6 name collision for multiple inheritance is not resolvable.


texts: Can't find address in abi encoded data of event

texts:
I have an event with the signature Event(address, uint256, string) which my smart contract emit from time to time. I am testing said contract on a ganache test net where when the Ganache picks up these events, it decodes them perfectly. Yet when I try to decode the abi encoding of said event using the rpc-json response there seems to be something wrong with the encoding even though everything else (tx-hash etc.) lines up:

I tested with address being 0xa96403a52c4b63fefda2f24734a7c1f69a36b24a, the uint256 being 1 and the string being hello and get this result:

0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000

This is the uint256 which is 1:

0x0000000000000000000000000000000000000000000000000000000000000001

I don't know what this is:

0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000

This is the length of the string, followed by the utf8 encoding of "hello", correctly by 27 bytes of padding to make it 32 bytes in total:

568656c6c6f000000000000000000000000000000000000000000000000000000

Could anyone help me out in decoding the address here and correct me in case I did something wrong decoding the other stuff? Thank you so much in advance!


texts: Can i broadcast a transaction by my other geth-core?

texts:
I have serveral geth-core running on different regions cloud-server, one running on my local computer.

I don't know why my geth-core(local computer) can't keep up the newest block , it always delay about 10w block. but my geth-core on cloud-server is sync the newest block.

Sometime i want to send a transaction from my local computer , it will return the tips about balance not enought (the balance had not sync to the newest block ).

So, how can i broadcast the transaction by my other cloud-server using json-rpc ? i don't want to send my keystore to my cloud-server .

Thx.


texts:
I am trying to get started and learn Ethereum development, mainly using the tutorial at dappsforbeginners.wordpress.com. However, several features referred to in the tutorial are simply not appearing in my client, or the client has been changed since the article was written. My client has no "pending" panel or a "contract" panel.

In addition to this, my Mix client crashes upon opening. I understand these aren't stable releases yet, so should I give up using these tools for now? If so, what tools can I use to start getting hands on experience? I am uncomfortable with CLI but I will do if I need to. Any good suggestions on how to get started?

EDIT: I am using Windows 10 and Mist Version 1.01. Now I see that when I run the executable, the first message displayed in the terminal window that appears is Qt: Untested Windows version 10.0 detected!. This must be what's causing the intermittent crashing.


texts:
In solidity, is there any way  to throw custom Exceptions along with error messages? I am using throw to prevent further execution of my code but this always results in invalid JUMP(in geth console, on debugging) and Intrinsic gas too low (in Mist).Can I have custom error messages?
For example can we modify transfer(..) function to produce error message account balance is low when balance of sender is less than amount he wants to transfer?

 function transfer(address _to, uint256 _value) {

    if (balanceOf[msg.sender] < _value)        // Check if the sender has enough
{
        throw;
        // some code to display  "account balance is low" to  user instead of 'Intrinsic Gas too low'
}

    balanceOf[msg.sender] -= _value;                     // Subtract from the sender
    balanceOf[_to] += _value;                            // Add the same to the recipient
    Transfer(msg.sender, _to, _value);                // Notify anyone listening that this transfer took

}


texts:
I'm now trying to use scalar multiplication to recover v, but I have questions with ECC scalar multiplication.

I'm wondering if the following equations are correct.

If scalar * P = Q, then scalar * (-P) = (-Q) ?

For example, assume that 5 * P = 5 * (Px,Py) = (Qx, Qy)

Is 5 * (-P) = 5 * (x,-y) = (Qx, -Qy) correct?

If there is anyone familiar with elliptic curve cryptography, please help me. Thanks!


texts: Minimum requirements for private chain miner

texts:
We are currently building a model with raspberry pi 3 to demonstrate a usecase in our university. When we try to run a miner on the raspberry pi 3 it crashes when creating a new block.

We want to look for a small atx-board to take over the mining, however we don't know what the minimum requirements are for a private ethereum blockchain.

Our genesis configuration set the difficulty at 400 and we changed the geth-function so the difficulty stays the same.

Any pointers or recommendations would help!


texts:
I have written a contract as follows:

pragma solidity ^0.4.0;

/*
Simple contract that mediates disputes using a trusted arbiter
*/
contract Taxi {

    enum State {IDLE, FINDING_DRIVER, AWAITING_PAYMENT, AWAITING_DESTINATION, COMPLETE}
    State public currentState;
    mapping (address => uint) public balances;
    bytes32 STRING_COMPLETE = "Complete";
    bytes32 STRING_PARTIAL = "Partial";

    modifier customerOnly() { require(msg.sender == customer); _; }
    modifier driverOnly() { require(msg.sender == driver); _; }
    modifier arbiterOnly() { require(msg.sender == arbiter); _; }
    modifier inState(State expectedState) { require(currentState == expectedState); _; }

    address public customer;
    address public driver;
    address public arbiter;

    function Taxi(address _customer, address _driver, address _arbiter) public {
        customer = _customer;
        driver = _driver;
        arbiter = _arbiter;
    }

    function assignDriver() customerOnly inState(State.IDLE) public {
        //arbiter.transfer(this.balance);
        currentState = State.FINDING_DRIVER;
    }

    function confirmAmount(uint amount) driverOnly inState(State.FINDING_DRIVER) public returns (bool ) {
        if(amount < 0) {
            amount = 20;
        }
        //driver has set this amount and user has accepted this fare, return true if customer has sufficient balance
        if(balances[customer] < amount) {
            return false;
        }
        currentState = State.AWAITING_DESTINATION;
        balances[arbiter] += amount;
        balances[customer] -= amount;
        return true;
    }
}

First I execute the assignDriver function which runs correctly. Later, when I execute the confirmAmount function, I get the error:

transact to Taxi.confirmAmount 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.

I tried to add the payable keyword to the constructor, but still I got the same error. What can be the problem?


texts:
So I've sent a few tokens from my MEW which I haven't used in a two years and some of the transactions are taking 2+ hours and are still pending.
Does anyone know what I did wrong or what's going on?
My mew address is
Ox28272da8c3814C57B952D2c35399D706B83 C79a3


texts:
I've finally managed to get my web3.js to work.. I did this only for the purpose to display one specific value on my website.. I'm not so good with jquery and hope you guys can help me out.

This is the Direct link to the ABI Value

https://api.etherscan.io/api?module=proxy&action=eth_call&to=0xD2354AcF1a2f06D69D8BC2e2048AaBD404445DF6&data=0xd679677a&tag=latest

Contract Link ( https://etherscan.io/address/0xd2354acf1a2f06d69d8bc2e2048aabd404445df6#readContract )

Line ( 28. currentTier )

It is in HexDec. and I need to output it in Decimal. I quess I will need to store the Value in a Var and output it in html.. but kinda lost how to exactly do it.

Hope you can help me out. Thank you very much


texts:
I'm building a sort of ether exchange. Now suppose I have 2eth in my wallet, and I want to transfer all of it to any user. What value should I transfer from my 2 ethers such that gas can also be deducted from my account and my account becomes empty at the end of the transaction?
What is the math? How do I calculate it?? If it is dependent upon the difficulty level of mining then how can my calculations co-op up with it??
Any help would be appreciated, thanks.


texts: what happens if I do using SafeMath for uint256 but then divide by uint8?

texts:
example
using SafeMath for uint256;

uint8 number8 = 10;
uint256 number256 = 1000;

function something() {
  return number256.div(number8);
}

is it still using safemath even if my number8 is uint8?


texts: How does ethereum keep track of changes on smart contract storage?

texts:
I'm aware that ethereum has essentially 3 tree-like structures:

State data
Receipts data
Chain data

As I've just learned from this question, contract storage resides on state data tree.

Digging around, I've found the image bellow:

If the image above is correct, only the changes in state are taken in account to create the state root of each block.

Here are the questions:

If I only associate the changes with the block, in order to get the full state of ethereum, do I have to assemble it by following the state trie until there is no pointers to older nodes [in the tree]? Or the nodes [in the network] keep an updated database with only the current state?
How exactly does one node under the state tree reference another? I'm sure there is a "pointer" within the node structure, but how is it possible to know which node it references?
Thinking about smart contract storage, how is the data arranged?

About 3., I know that every variable within a contract has an unique ID, therefore, it's possible to create a node with a structure like <varID, value> and organize something like:

                                    DATA_ROOT
                                        |
                    /----------------------------------------\
                   /                                          \
              H(H1 + H2)                                 H(H3 + H4)
                   |                                          |
          /-----------------\                        /-----------------\
         /                   \                      /                   \
H(<varID1, value1>)  H(<varID2, value2>)  H(<varID3, value3>)  H(<varID4, value4>)

Which leads to question 3.1:

3.1. Is this tree/trie full structure in the state tree under the node that identifies the contract account that owns this data?


texts: Why wouldn't changing Difficulty variable help out in scaling?

texts:
I'm writing a thesis about smart contracts and one of my appraisers asked me to explain why changing the difficulty variable on the ethereum blockchain wouldn't help scaling.

I know ethereum is abandoning PoW anyways and making mining easier would not be enough, but I lack that explanation, which I didn't find anywhere. If you do, please give me the reference. Else, I'd appreciate a "good enough" explanation.


texts: Check coinbase balance in Ethereum online compiler (Remix)?

texts: Is there a way to check the balance of the accounts when using the online compiler in Javascript VM mode?


texts: Calling an address array in web3 returns an error that the method needs arguments

texts:
I'm declaring a public address array in my contract, but when I call it, I get an error saying it's expecting an argument. Can someone shine a light on what is happening here?

Contract.sol

uint public buyIn;
address[] public playersRegistered;

index.js

// this works
console.log(await contract.methods.buyIn.call());

// this throws an error
console.log(await contract.methods.playersRegistered.call());

Error message:
Unhandled Rejection (Error): The number of arguments is not matching the methods required number. You need to pass 1 arguments.


texts:
Whenever I attempt to run geth on the command line, it seems to have trouble syncing with the blockchain. I am absolutely a novice so I could be completely overlooking. I am getting these warnings continuously(This is run on testnet):

WARN [04-21|17:40:40] Ancestor below allowance                 peer=20c9ad97c081d633 number=647267 hash=000000…000000 allowance=647267
WARN [04-21|17:40:40] Synchronisation failed, dropping peer    peer=20c9ad97c081d633 err="retrieved ancestor is invalid"

Please let me know if there is a solution for this. Thank you!


texts: how does Storing and Fetching data works in Smart contracts

texts:
Please help me out with these questions.

1)Where does the contract stores the data?

2)when we access the value of a variable form of a contract, how does it retrieve the latest value?

3)how is the new value of a variable is linked to the original contract? what happens to fetch it?


texts: How to call this solidity function with Web3js when executing the contract?

texts:
I’m new with ethereum.
I’m definitely struggling with the last 4 parameter of this function, so I’m asking the problem directly.

mapping(address => uint256) nonces;
/*
 * Proxy transfer token. When some users of the ethereum account has no ether,
 * he or she can authorize the agent for broadcast transactions, and agents may charge agency fees
 * @param _from
 * @param _to
 * @param _value
 * @param fee
 * @param _v
 * @param _r
 * @param _s
 */
function transferProxy(address _from, address _to, uint256 _value, uint256 _fee,
    uint8 _v,bytes32 _r, bytes32 _s) public transferAllowed(_from) returns (bool){

    if(balances[_from] < _fee + _value) revert();

    uint256 nonce = nonces[_from];
    bytes32 h = keccak256(_from,_to,_value,_fee,nonce);
    if(_from != ecrecover(h,_v,_r,_s)) revert(); // THE PROBLEM I’m STUCK ON SEVERAL HOURS IS HERE.

    if(balances[_to] + _value < balances[_to]
        || balances[msg.sender] + _fee < balances[msg.sender]) revert();
    balances[_to] += _value;
    Transfer(_from, _to, _value);

    balances[msg.sender] += _fee;
    Transfer(_from, msg.sender, _fee);

    balances[_from] -= _value + _fee;
    nonces[_from] = nonce + 1;
    return true;
}

First, keccak256 takes normally only one argument (the data to hash). I have no idea what using multiple parameters does. Adding the data ? If yes how ? Hashing the hashs ? all at once or rehashing after each results ?
Second thing, I think that in order to get _v I need to use web3.eth.sign with web3.eth.sign("0x395BE1C1Eb316f82781462C4C028893e51d8b2a5",keccak256("data")). But if it‘s not the case, I don’t know what I need to use
Third, no idea about _r is about.
Four, I think to understand _s is about an HTtp callback (by reading documentation). But it seems that I cannot just left it to 0 since I don’t know what to callback.
AND THE HArdest thing. How to determine exactly the nonce parameters in keccak256 ? (even If I have no idea on how to call it), because I’m having a hard time at understanding what mapping(address => uint256) nonces; and uint256 nonce = nonces[_from]; really do. And obviously I need to know the value in order to set _v _r _s


texts: How can i confirm transaction in geth from other peer of blockchain?

texts:
I have a query , I have create a private blockchain in which one geth node1 is use for transaction taking and other one(node2) is for mining .They are peered with each other and perfectly synchronizing. But when i am doing so every thing is fine but the transaction are not conforming . I have to run miner on node1 them it is confirming .

setup node1

geth --datadir firstserver  --networkid 1300 --port 30303 --rpcport 8000 --rpc  --maxpeers 3 --rpcaddr 127.0.0.1 --nat=any --rpcapi="db,eth,net,web3,personal,admin,miner" --bootnodes enode://bcf91ae94b3ab1505d1607c2b936422da23d6a67b5cbdf4eb6f1bc7cc78ada47bfdea80e10b56f99e35b380e9af1b8ff3f6ee334e2b210db8ae97c539cbc2414@127.0.0.1:30304 --rpc   --rpccorsdomain "*" --targetgaslimit 210060000000   console

setup node2

geth --datadir secondserver  --networkid 1300 --port 30304 --rpcport 8001 --rpc  --maxpeers 3 --rpcaddr 127.0.0.1 --nat=any  --rpcapi="db,eth,net,web3,personal,admin,miner" --etherbase 0x31b4138e4594ece4d8f900db0589fa319b694c8e --rpc --rpccorsdomain "*" --targetgaslimit 210060000000   console

and addPeers in both the server . And i started mining (miner.start(1)) in  second node the first on is importing the data perfectly . then i create contract in first node by web3 and it is not generating contract address until ii start mining in node1

NOTE: coinbase is same , genesis code is same


texts: Can't store the value of a math operation. It's always 0

texts:
contract MyContract {
  uint public priceUSD = 1.70 * 10**8; // USD
  uint public priceEth;

   .........

  function setPrice(uint newPriceUSD) external ownerOnly() returns(uint, uint) {
    uint priceUSDInt = newPriceUSD * 10**8;
    // make a small number like 2 equal 200,000,000.

    /**
    I'm hard coding the price here just to debug it
    but eventually, I'd be calling Chainlink
    like this...
    (int price,) = getLatestPrice();
    **/

    int price = 132556000000;

    // this like evaluates to
    // 150879.62823259603
    // I'm attempting to set it to the state variable priceEth
    priceEth = priceUSDInt / uint(price) * 10**8;

    // storing the number to state variable
    priceUSD = txtPriceUSDInt;

    // return both new prices
    return (newTxtPriceUSD, priceEth);
  }

  function getLatestPrice() public view returns (int, uint8) {
    (
      ,int price,,,
    ) = priceFeed.latestRoundData(); // Chainlink call

    uint8 decimals = priceFeed.decimals();
    return (price, decimals);
  }

  .........
}

Whenever setPrice() is called with e.g. setPrice(2), the intention is to set a new price in USD and in Eth.
But I can't seem to ever set priceEth. It's always 0.
I'm really new to fixed-point math. It could be I'm doing something totally wrong here. But, when I use the Remix debugger and type of the result of txtPriceUSDInt / uint(price) * 10**8; I get a non zero number.
But when I check the value of priceEth, it's always 0.
I'm not sure I'm doing something wrong with fixed-point arithmetic or something else. If anyone has any pointers?


texts: Can division underflow or overflow in Solidity?

texts:
We know that:

Since Solidity v0.8, the compiler has checks for {over,under}flow by default for all arithmetic operations.
Division is an arithmetic operation that rounds down to the integer part of the quotient.

Excluding the case when the divisor is zero, is underflow or overflow possible?


texts: Can i disable direct transactions to smart contract address?

texts:
I want to use rewardsAmount variable to calculate my rewards:

uint rewardsAmount = 0;

// Only here i can withdraw rewards

function withdrawRewards() onlyOwner external
{
    require(rewardsAmount != 0);
    owner.transfer(rewardsAmount);
    rewardsAmount = 0;
}

// If the contract doesn't have users funds, then i can destroy it

function kill() onlyOwner external
{
    require(address(this).balance - rewardsAmount == 0);
    selfdestruct(owner);
}

function someFunction() public
{
    // some code
    rewardsAmount += 100;
}

If someone sends to the contract address some ether, I can never kill the contract, right? So how can I prevent ether from being sent to my contract?


texts: Startup script for creating an account and running geth

texts:
I am trying to create a startup shell script to create a geth instance with a pre-configured genesis file at the nodes on an Ubuntu Wily OS with geth installed on the system. The objective is to create a private test net with one of the nodes accountable for seeding the accounts and allocating ether to the accounts?

For this purpose, I would need to create the genesis file with a preset allocation of ether to an account.

The only way I found is to create an account non-interactively is to use:

geth --password <path to password file> account new

This would require creating an account and then using the path to the password file created on the system.

Questions:
1. Is it possible to pre-generate a password file on the local host and then use this file to create an account, using the above command? What is the best way to preset a password file? The main goal is to not having to start a geth instance, use personal api for creating an account and then again restarting the geth instance with a modified genesis.json file - the idea is to consolidate these steps in a non-interactive fashion.
2. Any recommendations/suggestions on how this password file can be generated using standard key generation software like Hashicorp Vault and utilized for running the geth instance? On the same note, what are the steps to generate password, protect using Hashicorp Vault or GnuPG and then utilize the same password for creating a geth account?
3. Alternatively, if the geth instance were to be started with a genesis file without allocation of accounts across the nodes on the private net, would it matter if accounts were not part of the genesis file for the private test net?


texts: Mapping member isn't initialized when creating a struct

texts:
pragma solidity ^0.4.0;
contract TestcaseResetObject {

    MyObject ob;

    struct MyObject {
        mapping(uint8 => uint) map;
    }

    event Output(uint number);

    function makeNew() {
        ob = MyObject();
        ob.map[0] += 1;
        Output(ob.map[0]);
    }
}

When I run makeNew repeatedly in browser-solidity, I'm expecting to get every time the event Output(1). Instead, I get Output(1), Output(2), Output(3), etc.

It seems when I create a new MyObject, the map isn't actually created again.

Another question relates that freshly initialized struct should have a "zero" value in all its members. This seems true for uint's etc. but since mapping seems to "remember" its old values this seems not to be the case.

Any ideas?


texts: Google chrome error after installing Ethereum Wallet and vice versa

texts:
Anybody here knows why Google Chrome runs into error opening up after Ethereum wallet is installed?

And when I reinstall Google Chrome, the Ethereum Wallet is gone. What the hell?

I am using Linux Mint.


texts: parity vs geth - language and enterprise variant/adoption

texts:
Geth is written in Go (Golang). What language is parity developed in?

Also why do enterprise ethereum such as quorum go with Go-Ethereum (Geth) instead of Parity?


texts: Oraclize external rest api call failure handling

texts:
Using https://oraclize.it, I can perform something like this
oraclize_query("URL","json(https://api.postcodes.io/postcodes).status",
              '{"postcodes" : ["OX49 5NU", "M32 0JG", "NE30 1DP"]}');

but now, when the oraclize offchain bot access the url, what if

dns resolution of api.postcodes.io fails?
the answer doesn’t contains the expected json status field?
the expected answer is received, but with an http status code of 404? or 403?
the Oraclize request asks for 2 differrent json fields of the same request but only 1 of the 2 is found by the parser (is neither fields provided in the __callback() or only one)?

In each case, is the Oraclize call to __callback on the contract cancelled? or sent with garbage? or empty?


texts: What is ETH useful for appart from being a cryptocurrency? Does it have something specific due to smart contracts?

texts:
It seems the main cryptos are divided into (very roughly) two parts: the original plain blockchain-based cryptos such as BTC, BCH, LTC... on one hand, and ethereum on the other hand which allows the deployment of smart contracts. At first, I thought ETH was the currency used by these smart contracts on the ethereum network, but then I saw that each company willing to run on ethereum (OmiseGO, Golem, etc.) issue their own tokens that should be used to pay for their services.

Sure, those tokens can be bought using ETH, but they can also be bought using e.g. BTC, so it seems one could just use smart contracts/dApps, BTC and tokens, and never has to use any ETH. Am I missing something and does ETH plays some special role?

(Please note my question is not about transaction fees nor velocity. I am not trying to advocate using BTC: it just happens to be very widely used on exchanges.)


texts: Handling keccak collisions in decoupled storage pattern

texts:
The decoupled storage pattern (https://blog.colony.io/writing-upgradeable-contracts-in-solidity-6743f0eecc88) uses a hash function (keccak) to turn arbitrary length values into 32 byte keys for the storage mappings.

Am I supposed to worry about hash collisions? Or is keccak256 magic, and not ever do that? Seems like having a collision could break a lot of things.


texts: How to access Token functions in remix.ethereum.org?

texts:
I'm looking at Crowdsale.sol from OpenZeppelin / zeppelin-solidity. Here's a snippet:

import '../token/MintableToken.sol';

contract Crowdsale {

  MintableToken public token;

After I create the Crowdsale contract on remix.ethereum.org, Crowdsale's functions and MintableToken token's address are shown.  But it does not show token's functions such as balanceOf and totalSupply.  Is there a way to see this, or is this lacking in remix.ethereum.org?

[Added on 2017-08-05] I want to create Crowdsale contract, send some funds there and see my balance.  This does not seem possible on remix.ethereum.org.  This is possible on wallet.ethereum.org because after watching Crowdsale contract, it will show the token's address.  Then you can watch the token contract and balanceOf and totalSupply will appear and be accessible.  After creating Crowdsale contract on remix.ethereum.org, it shows the token's address, but there seems to be no way to access the token's functions.  Is this lacking in remix.ethereum.org?  On remix.ethereum.org, you can create Crowdsale.sol and MintableToken.sol contracts, but the token created by the second contract is not the same token that Crowdsale created and therefore, when you send funds to Crowdsale, your funds are going to the token that Crowdsale created, not the token that the MintableToken.sol contract created.


texts: How can I check if a contract contains a specific function signature in the ABI?

texts: I'm using Geth and thinking maybe I'll have to deep dive into the Go code to make this happen, but it should be possible. What would I need to do to check if a function signature exists in a contract?


texts:
I have a function in one contract that that takes a different user defined contract as the parameter and then does something with it. When I make an RPC call externally I can provide virtually any address as the parameter regardless if it matches the contract interface of my user defined contract type. I'm assuming this is by design since I think in the ABI user defined types just become address.

Example:

contract MyContract is MyParentContract {
   string private foo;

   function MyContract(string _foo) {
       foo = _foo;
   }

   function getFoo() public returns (string) {
       return foo;
   }
}

contract ExternalContract {
    MyParentContract private myParentContract;

    function ExternalContract(MyParentContract _myParentContract) {
        myParentContract = _myParentContract;
    }

    function setMyParentContract(MyParentContract _myParentContract) external {
        myParentContract = _myParentContract;
    }
}

If I am to send a transaction to ExternalContract.setTestParentContract() I can provide the address of any contract regardless of whether it is a MyParentContract contract or even matches the interface of that contract.

I am wondering if anyone has come up with a solution to disallow incompatible contracts? Or if there are solidity/ethereum changes in the works to solve this issue?


texts: What are the runtime scopes in contract interopability?

texts:
It seems that there is a scope per contract. This subtlety is debated on Reddit:

https://www.reddit.com/r/ethereum/comments/5hiy29/solidity_throw_after_selfdestruct_why_does_the/

I can reproduce this claim with a emulated js blockchain

contract Client{
    Server public s  = new Server();
    function doit(){
        s.homicide();
        throw;
    }
}
contract Server{
    bool public alive = true;
    function homicide(){
        Suicide();
        suicide(msg.sender);

    }
    event Suicide();
}

https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.6+commit.2dabbdf0.js&optimize=undefined&gist=9a48bde651631bff7591817811610070

After calling doit() the property Server#alive returns an error.
Interestingly I can't execute it on Ropsten because the Gas needed to remotely call suicide and throw is over the block limit.

This scoping per Contract is a severe flaw when it comes to interopability of contracts, IMHO. What is the reason for it and more importantly where is it specified?


texts: VM error: revert. Try to send ether from contract to another contract

texts:
I just facing a little issue here in sending some ether from Sender contract to another contract Escrow by msg.sender value.
Btw, I'm executing code on Remix, and specify the value from the sender after calling sendEth().
pragma solidity ^0.5.11;

contract Sender {
    event sent(
        address indexed escrowAddress
    );

    function sendEth() external payable{
        Escrow escrow = new Escrow();

        address payable _payableEscrow = address(uint160(address(escrow)));
        _payableEscrow.transfer(msg.value);

        emit sent(_payableEscrow);
    }
}

contract Escrow {
    function getBalance() external view returns(uint256) {
        return address(this).balance;
    }
}

And IDK why exactly I received this error:

transact to Sender.sendEth errored: VM error: revert.
The transaction has been reverted to the initial state.

Thank you for your help!


texts: I could not use web3.js module and perform getAccounts etc. for Consortium networks. Hyperledger Besu

texts:
const Web3 = require('web3')

//var web3 = new Web3('http://127.0.0.1:8585');
var web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
//  https://rinkeby.infura.io/v3/a4ba0f8e6dbf4ef78e2a0ab377767ebb

const besucheck = async () => {
    //console.log('account ',await web3.eth.getAccounts());
    let blockcount = await web3.eth.getBlockNumber();
    let count = 0;
    //let blockcount = 10721114;
    //for (let x = blockcount; x > blockcount-5; x--) {
        console.log("hii");
        console.log(blockcount);

};

besucheck();

that was my code and my consortium block chain network is runing absolutly fine. Irrespective to whether the network running or not I am receiving this error
UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (D:\UQEducation\Networking\besutest\node_modules\web3-core-helpers\src\errors.js:42:16)
    at XMLHttpRequest.request.onreadystatechange (D:\UQEducation\Networking\besutest\node_modules\web3-providers-http\src\index.js:98:32)
    at XMLHttpRequestEventTarget.dispatchEvent (D:\UQEducation\Networking\besutest\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (D:\UQEducation\Networking\besutest\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpRequestError (D:\UQEducation\Networking\besutest\node_modules\xhr2-cookies\dist\xml-http-request.js:349:14)
    at ClientRequest.<anonymous> (D:\UQEducation\Networking\besutest\node_modules\xhr2-cookies\dist\xml-http-request.js:252:61)
    at ClientRequest.emit (events.js:198:13)
    at Socket.socketErrorListener (_http_client.js:392:9)
    at Socket.emit (events.js:198:13)
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:11480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.


texts:
I'm just trying to get web3.eth in node.js to tell me what the current block number is but I get an error 'UnhandledPromiseRejectionWarning: Error: Invalid JSON RPC response: ""', I have "geth --syncmode "light"" running in a different console tab and I thought that would be all I needed to get a data feed from the main-net, is there something I'm just not understanding or is it something about my environment that is causing this
var Web3 = require('web3');
var web3 = new Web3("http://localhost:8545");
web3.eth.getBlockNumber().then(console.log);

node v14.4.0
npm v6.14.5
"dependencies": {
"ethereumjs-testrpc": "^6.0.3",
"web3": "^1.2.9",
"web3-eth": "^1.2.9"

}


texts:
Situation:

let's assume we have

a data storage contract
libraries that import the data storage contract
a business logic contract that implements the libraries

Question:

can we use ENS, or more specifically it's approach with registry, owner and resolver, as "upgrade tool", by publishing a "name" for the contract, and letting the resolver point to the currently valid business logic contract?


texts:
According to specs, for proposer slashing i need to compare the slot with previous block.slot
my question is- is it enough to check that the current block slot is greater than the last block slot i saved to the hard disk or do i need to save all the slots since my first validator created?
Also, do i use the same data for all my validator clients (and their validators)? i mean if i actually can save only the last slot, i need to save the last slot for each validator or one for all of them (the maximal)?
I was based on this info:
https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/validator.md#how-to-avoid-slashing


texts: Get variable state at specific block number

texts:
Is it possible to get a variable state at a specific block number?
Let's take the balance mapping in an ERC20 contact for example. I want to know which user had what balance at a specific time (blocknumber). Copying the balance into another map should be costing too much gas. is there a way to have a smart contract see the state of a variable at a specific block with solidity? Or any other gas efficient way to copy a map into another smart contract?


texts: How can you figure out if a certain key exists in a mapping, Struct defined inside Library (in Solidity)?

texts:
pragma solidity ^0.4.8;

library Library {
  struct data {
     unit val;
   }
}

-

contract Array{
    using Library for Library.data;
    mapping(address => Library.data) clusterContract;

    function addCluster(address id) returns(bool){
        if(clusterContract[id] == address(0) ){ //error occurs!
            clusterContract[id] = list;
            return true;
        }
        return false;
    }
}

Following comparission if(clusterContract[id] == address(0)) gives the following error:

Operator == not compatible with types struct Library.data storage ref and address
E               if(clusterContract[id] == address(0) ){...

[Q] How could I fix this error?


texts: How to destroy a token or list of token from a another contract?

texts:
[Edit 14-03-2018]
I want to create a contract A that can generate a random number of Token A and another contract B that receive and destroy one or many of this token to generate a new Token B.

It's like sending one CryptosKitty to another contract B, burn the kitty, and generate a Dog with the kitty's gen.

Thanks for the help.


texts: How to deploy a compiled stateless contract and which doesn t have creation code/transaction?

texts:
I got a deployed contract bytecode from an internal project which I d like to publish on the mainnet.
The problem is it s just the bytecode without the creation code.
Is there a simpler way to deploy it on the mainnet beside crafting assembly with codecopy and dealing manually with addresses?


texts: Can the contracts in the Solidity repository be used in production?

texts:
In the solidity repository there are some standard contracts:

owned
mortal
token
StandardToken

they are all imported in a file std.sol

I was wondering if these contracts could be used in solidity and if yes how?

The contracts are on my hard disk as I have solc but providing the full path to import them seems awkward.


texts: Parity chain data location in Windows 10

texts:
I first installed Mist, which downloaded 23GB of blockchain data, and the deleted all the blockchain data and mist-related files.

Then, I installed the parity on my windows 10 machine. Within a 10 min, parity shows that chain data is synced. However, I cannot find any chain data on my PC. The remaining storage has not been changed. I cannot find the folders mentioned in this answer:
Location of parity blockchain in Windows

I could send and receive ETH with parity. So, I guess the parity client does not download any chain data.

I was wondering whether my guess is correct or not. If it is getting the blockchain from the web, would it be safer option than the Mist?

Thanks.


texts: Why doesn't web3.js/metamask have a decrypt with private key function yet?

texts:
For smart-contracts and dApps it is in many cases important to put encrypted data on the blockchain, encrypted with the public key.
I have been searching, but there doesn't seem to be a way to decrypt the data using an extention like metamask through web3.js. If I would want to build a dApp with encrypted data on the blockchain, I could only decrypt it by asking the user to insert his private key every time the app needs to decrypt data. The user needs to copy the private key from the metamask extention, where he needs to insert his password in order to expose it, then proceed to copy it and paste it into the app, so that the app can decrypt the data. This is tiresome for the user and also a huge security flaw.
A much better way (the way it should be done) is where Web3.js has a function to decrypt data, so that the extention can decrypt it there, and return the decrypted data. But this doesn't seem to be possible.
Why haven't they implemented this (yet)? It seems quite important to me in order to build safe dApps and smart-contracts. If there are better ways to do this, I would like to hear it.


texts: Does private Ethereum blockchain like Quorum need ether?

texts: Does private blockchain built on Ethereum like Quorum need/require ether? How will the emergence of such private blockchains impact ether's value.


texts: Is it possible to transfer an ENS address to an anonymous owner?

texts: If I wanted to transfer an ENS address I won to an anonymous / unlinkable owner, is that possible?


texts:
Is it possible to interact with a smart contract with bytecode only (without ABI)?
If yes, how can I do this?


texts:
Is there any good API for accepting and sending Ethereum like blocktrail for bitcoin ?
Why is working with Ethereum so complicated?


texts: From my purse ETH was sent a transaction that I did not send

texts: What should I do? I sent a transaction from my ETH wallet that I did not send. Help me please


texts: I did not dowload the keystore when I created my etherwallet account

texts: Last year I created a account in my etherwallet, when it finished, i just saved the address of wallet and password,did not save keystore file also private key. Now I access in my etherwallet, they require the keystore or private key, how can i do it?


texts: Call array variable from solidity contract in web application

texts:
I have declared one array inside solidity contract like "uint256[] public machineList; " and initialize the values of that array inside the constructor.

But when I call that array inside js usgin web3 mentioned as below :

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

    let getMachineList = contractInstance.machineList;
    alert(getMachineList);
});

It is returning below output in getMachineList variable:

    function () {
  var instance = this
  var args = Array.prototype.slice.call(arguments)
  var tx_params = {}
  var last_arg = args[args.length - 1]
  if (Utils.is_object(last_arg) && !Utils.is_big_number(last_arg)) {
    tx_params = args.pop()
  }
  tx_params = Utils.merge(C.class_defaults, tx_params)
  return C.detectNetwork().then(function () {
    return new Promise(function (accept, reject) {
      var callback = function (error, result) {
        if (error != null) {
          reject(error)
        } else {
          accept(result)
        }
      }
      args.push(tx_params, callback)
      fn.apply(instance.contract, args)
    })
  })
}

this type of data I am getting in alert(contractInstance.machineList);

So, how can we get array values in side JS without making explicit getter function inside solidity rather to call in built in getter function which is provided by solidity for state variable ?


texts: Does Removing Something From an ABI Render It Non-Functional?

texts:
If remove a single feature from the ABI, will it work with other contracts that have that feature still? Does the order of functions matter in the ABI?

Use Case:

For simplicity, I want to build a Web3.js frontend to interact with contracts, however, some of the contracts will have function to look up the ENS domain of a person, and others won't. I don't need to worry about this function at all in the frontend, I just need to make sure the ABI in the JS works and doesn't generate errors.


texts: As we know memory wallets more specifically Brainwallet 1.0 is a failed technology. I want to know how secure is this wallet system? It uses blockchain transaction hash and passphrase to calcualte entropy from which you can generate your private keys/mnemonic codes. As claimed by the creator of the wallet this can be super easy to memorize the few data precisely saying 4 numbers/words rather than 12 mnemonic phrases. Additionally the user can train himself visually until he memorizes.


texts: I'm currently trying to test my contract code on Rinkeby. If I'm not mistaken, I need to run a full Rinkeby node on my hard drive right? I did geth --rinkeby but it's taking a long time to sync. Am I approaching this correctly? Do I even need a full node?


texts: How to install web3j command line to generate smart contract wrapper

texts:
I am trying to generate a simple smart contract wrapper using solc and web3j in ubuntu.

I have downloaded the source as defined in https://docs.web3j.io/command_line.html

Release package can be obtained from https://github.com/web3j/web3j/releases/tag/v4.1.0.

I have download the source from https://github.com/web3j/web3j/archive/v4.1.0.zip

After unwrapping the zip package I can't find any bin directory as the document page shows

unzip web3j-<version>.zip
creating: web3j-3.0.0/lib/
inflating: web3j-3.0.0/lib/core-1.0.2-all.jarcreating: web3j-3.0.0/bin/
inflating: web3j-3.0.0/bin/web3j
inflating: web3j-3.0.0/bin/web3j.bat

How to get the bin directory?


texts: Would running an ethereum node of a private network in android drain battery?

texts:
I am building an android application where users can pay for items they buy with ether. Application will use a private ethereum network.

As I understood, I have to run an ethereum node in the android device as a separate process and my android app has to communicate with it using either sending commands or through JSON RPC.

Since android is very concerned about the power consumption, would android allow running a separate process continuously? Would android kill the process after some time?

Also, would running the node continuously in the device cause a huge battery drain?


texts:
I am building a loan dapp. The functionality is not easy to build but relatively straightforward. My question is though does anyone have any suggestions of how to build in user logins and security? The contracts are written in Solidity and I am using a Web3JS HTML front-end.

I would really appreciate any pointers you can give me.

Thanks


texts: solution of No visibility specified & declaration shadow existing declaration warning?

texts:
pragma solidity ^0.4.18;

contract TwoD {

    address creater;
    string a;
    string b;

    function compareStrings (string a, string b) view returns (bool)
        /* warning 1: this line is showing No visibility specified warning but when i
           am using public it is showing error that expected token LBrace got public
           function?
           warning 2: this declaration shadows existing declaration?
        */
    {
       return keccak256(a) == keccak256(b);
   }
}


texts: Do miners have to store the whole blockchain?

texts:
I was reading the ethereum whitepaper and encountered this paragraph.

Ethereum is likely to suffer a similar growth pattern, worsened by the fact that there will be many applications on top of the Ethereum blockchain instead of just a currency as is the case with Bitcoin, but ameliorated by the fact that Ethereum full nodes need to store just the state instead of the entire blockchain history.

Now this post says that ethereum full nodes stores complete blockchain.
I am curious how miner nodes verify the block. So, miners don't store the whole blockchain history and stores only the most recent system state?


texts: Is one node mining enough in the private network to transfer and verify transfer?

texts:
i have setup private blockchain. there are two node in that network. i started mining in only node1. i able transfer in node1 and node2.

Questions:
Should i start mining in all node?
if start mining in node2, that mining helps to verify all transaction?
or
without minging in node2,transaction will be verified?


texts: All my mined coins are going to address 0x000000

texts:
I have an ethereum miner up and going for about 24 hours now. For the first 15 hours or so I saw the following text repeated on the screen (each time updating only the timestamp).

23:17:27.282|gpuminer0 workloop 1 #6f9a4b23... #6f9a4b23...
23:17:27.342|gpuminer1 workloop 1 #6f9a4b23... #6f9a4b23...
23:17:27.763|gpuminer2 workloop 1 #6f9a4b23... #6f9a4b23...
23:17:28.120|gpuminer3 workloop 1 #6f9a4b23... #6f9a4b23...

However I woke up this morning (so about 15 hours passed total) and the output changed such that only the hash changed to something like this

21:52:56.111|gpuminer0 workloop 1 #5e57d24f.. #5e57d24f...
21:52:56.156|gpuminer1 workloop 1 #5e57d24f.. #5e57d24f...
21:52:56.212|gpuminer2 workloop 1 #5e57d24f.. #5e57d24f...
21:52:56.678|gpuminer3 workloop 1 #5e57d24f.. #5e57d24f...

I had assumed this meant I mined a block while I slept. However when I went to my account it didn't have any additional ether in it and i could find no signs of any mined blocks on my account. Sadly my scroll buffer is too shallow to scroll back and actually see if I mined a block.

So any ideas? Does the hash update on the output even when you don't mine a block? Or did I mine a block and somehow it didn't make it into my account and got lost due to bad configuration or something?

EDIT

So I finally saw the notification that I did in fact successfully mine a block. The block I mined can be seen here: https://www.etherchain.org/block/960905

What is confusing is apparently the block mined went to miner 0x0000* instead of to my own account. What is even weirder is that I am running the miner as follows:

geth --rpc --rpccorsdomain localhost --etherbase '0xblahblahblah'&
ethmine -G

and when I go into geth to confirm the coinbase address it is set correctly to my own address. I check using:

eth.coinbase

So why is it still using the 0x0000 miner?


texts:
Am I right, that  Ethereum do it the same way as Bitcoin (Bitcoin dev guide), and the only difference is that the Ethereum use it's own OP_CODES?

UPD I mean, what is the Ethereum's alternative for <Sig> <PubKey> OP_DUP OP_HASH160 <PubkeyHash> OP_EQUALVERIFY OP_CHECKSIG ?


texts: Is it possible to mount ~/.ipfs folder to an external drive?

texts:
Please note that this question is related to IPFS (https://ipfs.io).

Is it possible to mount ~/.ipfs folder to an external device (such as: hard-disk, network drive, WD My book etc.)? This will help to share ~/.ipfs folder between different nodes. I was not sure that IPFS is designed to have that file system shared between nodes (simultaneously?).

Please note that I am mounting into my WD My book External Hard Drive (https://www.wdc.com/products/wd-recertified/my-book.html , File system NTFS). Please see my mounting line of code:

    $ mkdir /mnt/cifs
    $ sudo mount -t cifs //server-name/share-name /mnt/cifs -o \
                                    username=admin,password=my_password,uid=1000
    $ mount | grep 'cifs’
    //server-name/share-name on /mnt/cifs type cifs (rw)

After I have mount ~/.ipfs folder, when I try to run ipfs init or ipfs add <filename>, I have faced with the following error:

Error: fsync: invalid argument

When: ipfs add <filename> runs, it creates block files inside created folders as follows:
~/.ipfs/blocks/<created_folder_name>.

~/.ipfs/blocks$ ls
CIQA2  CIQBE  CIQCP  CIQDV  CIQF7  CIQGF  CIQHL  CIQIY  CIQK5  CIQLB  CIQMG  CIQNM  CIQOR
CIQA3  CIQBF  CIQCQ  CIQDW  CIQFA  CIQGG  CIQHM  CIQIZ  CIQK6  CIQLC  CIQMH  CIQNN  CIQOS
CIQA4  CIQBG  CIQCR  CIQDX  CIQFB  CIQGH  CIQHN  CIQJ2  CIQK7  CIQLD  CIQMI  CIQNO  CIQOU

Ex: After ipfs init is executed, only one file is created under each created folder.

$ ~/.ipfs/blocks$ ls */
/home/.ipfs/blocks/CIQMJ:
CIQMJCAMEI4UXBQ35CUDVVJOGU3DNWNHI7O7JCWHWNMUWPGKPOTLFYY.data //coming from mounted device.

/home/.ipfs/blocks/CIQMK:
CIQMKGZXBKZV262ZN6ABE4SUO5BNGKVSPTGAQXSOC35UUK7FUPIIAIY.data //coming from mounted device.

Further, after running ipfs add <filename> a new folder is created with a file inside. I have mounted that folder to my external device, it fixes the error I was facing with.

But if ipfs add <filename> adds a new block file into a already created folder under ~/.ipfs/blocks => it gives the same error: Error: fsync: invalid argument.

/home/.ipfs/blocks/CIQMI:
CIQMI5TLEXEWEYC3G3WELU6ONMKNLAF6CZUXU5BTWEU453LHPTUNNEI.data //coming from mounted device.
CIQMIRQGFPT23SZ6XYFFU45GLZENEWRYI7PR3YJ7EP7ZC6I4ME7GPFQ.data //newly added file

The script I have write to test:

After running ipfs init only one time following script is executed.

$ sudo mount -t cifs //server-name/share-name /mnt/cifs -o username=admin,password=my_password,uid=1000
$ ipfs init
$ cd ~/.ipfs/blocks/
for d in */ ; do
   if [ ! -d /mnt/cifs/$d ]; then
        mkdir /mnt/cifs/$d
        cp $d/* /mnt/cifs/$d/
   fi
done

To revert the files from external device before running: ipfs add <filename>: Now all the folders inside ~/.ipfs/blocks/ actually mounted to my external device.

sudo mount -t cifs //<ip_address>/mybloc/ ~/.ipfs/blocks/ -o username=admin,password=my_password,uid=1000

Thank you for your valuable help and time.


texts: How bad are future blockhashes as source of entropy exactly?

texts:
This is not a duplicate (see below)

Before you answer “bad, the miner can influence them”, please let me specify the question.

It’s clear that things like timestamp should not flow into a random number computation because the miner mining the block can choose it quite freely.

But what about the blockhash?

The only kind of influence a miner can take here is to sacrifice the block reward and not publish the mined block (or am I missing something) - but in what situations does that give him any statistically relevant advantage?

I read somewhere else, that it would make sense to the miner to do so as soon as the possible reward is higher than the block reward, but that does not seem true, since sacrificing the block reward doesn’t automatically make him the winner, it just leaves his winning chances at what they statistically are. So it seems to only make sense when the block reward is lower than the average return expectency value of the random draw - or am I missing something?

So, how bad a source of entropy are future block hashes really, and in which scenarios are they actually fine?

And, important follow-up question: how is that assessment going to change once ethereum switches to a proof of stakes algorithm (this is not discussed in the question marked as possible duplicate)?


texts: How does ETH handle smart contract conflicts?

texts:
Say I have an auction contract, highest bid wins after a certain time (# of blocks). Participants put in their bids.

Say 100 participants simultaneously puts in their bids (unlikely but let's assume), and their bids are 1-100, so perfectly spaced by 1.

So we have tons of miners constantly trying to pack blocks. Some may take 1 of these calls, some take 40, some none, etc. They all pack their blocks, then 1 miner wins and rest are uncles.

Those who packed different subsets of the auction contract calls will come out with different results - i.e., if the highest bid I had in my block is 50 then that guy wins the auction, if the highest is 51 then he wins, etc. So you get a ton of miners coming out with different, conflicting results.

So the participant who actually ends up winning the bid is very unlikely to be the the actual highest bidder.

Is this what actually happens? Or are there ways ETH has to mitigate this type of conflict? Thanks!


texts: Can I use Events as a sort of volatile data store?

texts:
I'd like to make an application where a transaction occurs that creates a new contract, and an event is kicked of informing the listeners that this new contract has been created.

After that, the person who called the transaction is expected to listen to the Event and store the new contract address on their own persistent data store (the user has a monetary interest in storing the contract address until they wish to destroy it basically)

Is this a normal/secure pattern in the EVM?


texts: How to test light client on private testnet?

texts:
I am building a private testnet using Geth 1.5.6. I set up two nodes (miner and user) with two different datadir and listening port. Miner is a full node and mining blocks. User is just an ordinary node, syncing the blockchain and do some transactions. Both has the same custom genesis block. User connects to miner via it's enode URL.

When running in full node mode, User can connect to miner and sync the blockchain successfully. But, when I try the light client (LES) mode, miner is not responding to LES request and user is not syncing the blockchain. I am curious, how to correctly enable light server feature on miner so I can test the light client mode on private testnet? (Note: light client works flawlessly on Frontier and Ropsten).

Relevant parameters:

Miner: --lightserv 75 --lightpeers 100
User: --light
Enabling Topic Discovery (--v5disc) on both nodes has no effect.


texts: Deploying smart contract on Testrpc with Truffle

texts:
I followed this tutorial(read point 2 and 3)1: https://blog.zeppelin.solutions/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05 to create and deploy a simple smart contract, but at this point:

$ truffle console

// get the deployed version of our contract

truffle(default)> var poe = ProofOfExistence1.deployed()

// and print its address

truffle(default)> console.log(poe.address)
0x3d3bce79cccc331e9e095e8985def13651a86004

I can't print the address..
[]


texts:
I'm trying to work on ethereum and currently I'm using ethers npm package and I was trying to connect it to my private net which I will be using it for testing.

I've run my geth with this command.

geth --port 3000 --networkid 5  --rpc --rpcport 8545 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,net,web3,personal"

Now, I have assigned one public IP to that machine and accessing from outside through RPC. But that's not correctly working.

I'm running this code and I'm able to generate address, but on geth console, I'm not able to get any log about the created wallet.

var ethers = require('ethers');
var providers = require('ethers').providers;
var p = new providers.JsonRpcProvider('http://MY_RPC_PUBLIC_IP:8545', false, 5);
ethers.Wallet.provider=p;

var privateKey = "0x0123456789012345678901234567890123456789012345678901234567890123";
var wallet = new ethers.Wallet(privateKey);
console.log("Address: " + wallet.address);

Can anyone point out the mistake I'm doing here?


texts: dApp index.html fails to load for dAppUniversity election application

texts:
Hit a brick wall with this.

git clone https://github.com/dappuniversity/election

The following is the Shell output I get when I npm run dev. I’m using the cloned project from GitHub but I’ve changed the solidity version because it wouldn’t compile on 0.4.2. There’s nothing startling in the shell output so I’m finding it impossible to debug.  The issue is the page won’t load and get’s stuck on the loading screen.  In your tutorial it immediately loaded once you’d made a connection between Ganache and Metamask.  I connected to localhost:7545 and imported the key for one of the accounts but no joy.   No idea what to do now.

Last login: Mon Apr 22 14:27:24 on ttys001
Alans-MacBook-Air:Election alancameron$ npm run dev

> pet-shop@1.0.0 dev /Users/alancameron/election
> lite-server

** browser-sync config **
{ injectChanges: false,
  files: [ './**/*.{html,htm,css,js}' ],
  watchOptions: { ignored: 'node_modules' },
  server:
   { baseDir: [ './src', './build/contracts' ],
     middleware: [ [Function], [Function] ] } }
[Browsersync] Access URLs:
 -------------------------------------
       Local: http://localhost:3000
    External: http://100.75.50.91:3000
 -------------------------------------
          UI: http://localhost:3001
 UI External: http://100.75.50.91:3001
 -------------------------------------
[Browsersync] Serving files from: ./src
[Browsersync] Serving files from: ./build/contracts
[Browsersync] Watching files...
19.04.22 14:29:54 200 GET /index.html
19.04.22 14:29:54 200 GET /js/app.js
19.04.22 14:29:54 200 GET /css/bootstrap.min.css
19.04.22 14:29:54 200 GET /js/bootstrap.min.js
19.04.22 14:29:54 200 GET /js/web3.min.js
19.04.22 14:29:54 200 GET /js/truffle-contract.js
19.04.22 14:29:55 200 GET /Election.json
19.04.22 14:33:40 304 GET /index.html
19.04.22 14:33:40 304 GET /css/bootstrap.min.css
19.04.22 14:33:40 304 GET /js/bootstrap.min.js
19.04.22 14:33:40 304 GET /js/web3.min.js
19.04.22 14:33:40 304 GET /js/truffle-contract.js
19.04.22 14:33:40 304 GET /js/app.js
19.04.22 14:33:40 304 GET /Election.json

The following is the output from the page/inspect console.

app.js:106 Error: Invalid number of arguments to Solidity function
    at Object.InvalidNumberOfSolidityArgs (inpage.js:1)
    at u.validateArgs (inpage.js:1)
    at u.toPayload (inpage.js:1)
    at u.call (inpage.js:1)
    at u.execute (inpage.js:1)
    at truffle-contract.js:136
    at new Promise (<anonymous>)
    at truffle-contract.js:127

Just noticed it fails to compile properly:

2_deploy_contracts.js
=====================

   Replacing 'Election'
   --------------------
Error:  *** Deployment Failed ***

"Election" -- Invalid number of parameters for "voters". Got 0 expected 1!.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)


texts: Is it possible to burn an NFT (ERC20 or ERC721) from other provider/creator?

texts:
I want to create a wallet/gallery for NFTs and I was wondering if it could be possible for the user to send NFTs made in other providers/minters to burn in my platform. The thing is that I want to give a 'grace period' where the NFT is not burned yet. Is possible to do something like this? The ideal way is that the user allows the permission to burn but is not done until the proper time arrives.
Thanks a lot for any hint*


texts: Is it possible to verify multiple accounts' attached main parent user?

texts:
[Q] Is there any unique ID for geth or parity usage, which might help use to detect multiple created accounts' main parent creator? (I assume all those multiple accounts are created by the same main user, using the same geth node).

For example, using a geth or parity node same user can create multiple accounts which are attach to actually one user. If there is unique geth or parity ID, maybe that might help us the identify all created accounts are actually attach to one user using the linked to the same geth or parity node where accounts are created.

Another example: we wrote contracts for voting using msg.sender for voters. I realise that a user can create many dummy users, which he could use them to vote for himself. We cannot prevent this from happening since each ethereum account is different from each other.

       function becomeMemberCandidate(bytes32 ipfsHash) public
        not_member returns(bool) {

        members[msg.sender] = uint32(membersInfo.length); //contains addresses which can vote within the contract.
        memberAddresses.push( msg.sender );
        return true;
    }


texts: Ethereum-Wallet Unable to connect to node, see the logs for more details

texts:
Previously I had the official windows desktop ethereum-wallet synced and working, but the other day my computer crashed and corrupted my blockchain sync, so I deleted my chaindata folder and started over.  This time I synced with geth --fast --cache=2048.  When it was caught up I closed geth and attempted to open the wallet, but ever since then I immediately get an error that says something like "Unable to connect to node, see the logs for more details."  I made sure I was allowing geth to communicate through my firewall, but that didn't fix anything.

My question is, where are the logs and how can I view them? Also when running geth --fast, what is the proper way to close geth once it is caught up? I used CTRL-C in the command prompt because I couldn't figure out a better way.  And for future reference, can geth --fast be stopped before it's caught up and then resumed later?


texts:
I'm looking to generate a random ethers.js BigNumber in a certain range. While this question has answers about random number generation, the answers as of this writing (April 2021) only cover BigInt, BN.js, and web3.js, and in addition, does not discuss ranges.
My primary use for this is generating random token amounts during tests. Tokens traditionally have a large amount of decimal places, making Big Number libraries necessary.
I've tried adopting the answers there, but cannot get them to work ethers, even before addressing the issue of creating a min/max range. For example, I tried:
const randBytes = randomBytes(16); // from the node.js crypto library
const amount = BigNumber.from(`0x${randBytes.toString()}`);

or in place of the second line:
const amount = BigNumber.from(`0x${new BN(randBytesMint.toString('hex'), 16)}`);

which give me:
Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.0.13)```

Since in my personal case I do not need security guarantees, I'm also open to a solution using Math.random() and then scaling up using ethers.utils.parseUnits(), though secure random number answers are certainly appreciated too.


texts:
I work in a Ropsten testnet. I have a Python application that sends a transaction and returns the transaction's txHash. It is possible to send a maximum of 500 transactions in one request.
The application uses the web3 library. I called up a request with 500 transactions, and before that request ended, I started a new one. My application received txHash but the transaction is not visible in Etherscan. The message "Sorry, we can't locate this TxnHash" appears. Can more than one request be the cause of an invisible transaction? Can this transaction be canceled? If so why?
Please, help.


texts:
Can an interface enforce a modifier on a function?

For example, does this work:

contract TokenSeller {

  modifer enforceSale(uint256 amount) {
    ERC20 t = token();
    uint256 beforeBalance = t.balanceOf(msg.sender);
    _;
    uint256 afterBalance = t.balanceOf(msg.sender);
    require(afterBalance == beforeBalance + amount);
  }

  function buyToken(uint256 amount) public enforceSale(amount) returns(uint256);

  function token() public returns(ERC20);
}

Is there another way to achieve this kind of interface?


texts:
I just reinstalled parity and I'm getting an error now.
In my config.toml file when I add

cors = "null"

I get following error

Loading config file from /root/.local/share/io.parity.ethereum/config.toml
You might have supplied invalid parameters in config file.
invalid type: string "null", expected a sequence for key `rpc.cors`

the weird thing is it worked previously and now it doesn't


texts: How are funds returned in the Solidity docs Simple Open Auction example?

texts:
I was looking at the simple open auction example from the solidity docs. I don't understand the withdrawal part where a previous bidder wishes to withdraw his funds after he has been over bid.
This is an excerpt from the code.
/// Withdraw a bid that was overbid.
function withdraw() public returns (bool) {
    uint amount = pendingReturns[msg.sender];
    if (amount > 0) {
        // It is important to set this to zero because the recipient
        // can call this function again as part of the receiving call
        // before `send` returns.
        pendingReturns[msg.sender] = 0;

        if (!payable(msg.sender).send(amount)) {
            // No need to call throw here, just reset the amount owing
            pendingReturns[msg.sender] = amount;
            return false;
        }
    }
    return true;
}

How are the funds returned? Or is the process facilitated by some other way?


texts:
I tried to send test ethers to the main account address created on Ethereum wallet by using the Ropsten faucet (http://faucet.ropsten.be:3001/) but did not receive any . My wallet is synced with Ropsten test network.

Any suggestions on how I can get some ethers into my testnet account?


texts: Tx.origin and msg.sender when sending signed Raw transaction

texts:
A client with address A signs a raw transaction, and leaves it all ready to be sent, gives it to the server with address B, which later will send it with sendSignedTransaction(...).

What will be the values of:

  msg.sender

  tx.origin

EDIT: Notice this is NOT a duplicate of this other question, since in the other question the answers and the questions are oriented towards contract vs. non-contract addresses, whereas here both addresses A and B are not contracts, but in this case A signs and server with address B sends.


texts: What kind of node use for Ethereum development?

texts:
I am working with ethereum and to connect my backend to the blockchain I use an ethereum node: full node or a light node. I was asked a question but I didn't quite understand how to answer.
The question is: Suppose we are using a light node. If in the future I want to use a full node what changes at the interface level?
I know that a full node stores complete blockchain data and participates in block validation, verifies all blocks and states.
While a light node stores the header chain and not the entire blockchain.


texts: Truffle console: Exception instead of transaction

texts:
I am running the tutorial at:

Medium Just Dev

pragma solidity ^0.5.0;

import './Victim.sol';
contract  Attacker{
   Victim  public v;
   uint public  count;
   event LogFallback(uint c, uint balance);

   constructor (address victim) public {
      v=Victim(victim);
   }

   function attack() public {
      v.withdraw();
   }

   function () external payable{
      count++;
      emit LogFallback(count, address(this).balance);
      if(count < 10 ) {
         v.withdraw();
      }
    }
}

== Victim Contract
pragma solidity ^0.5.0;
    contract Victim{

       function  withdraw() public{

          uint transferAmt = 1 ether;
          (bool success, ) = msg.sender.call.value(transferAmt)("");
          //require(!success);
       }
       function deposit() payable public {}
    }

They have invoked the following method on the console
> attacker.attack()

and shown that they are generating a transaction but I am getting following exception:

truffle(ganache)> attacker.attack() Error: Returned error: VM
Exception while processing transaction: revert
at evalmachine.:0:10
at sigintHandlersWrap (vm.js:98:15)
at ContextifyScript.Script.runInContext (vm.js:56:12)
at runScript (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:222:1)
at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:237:1)
at ReplManager.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/repl.js:129:1)
at bound (domain.js:301:14)
at REPLServer.runBound [as eval] (domain.js:314:12)

Somebody please guide me how to correctly generate the transaction by avoiding theexception
Zulfi.


texts: Address.transfer(amount); What does it mean? who is recipient?

texts:
I have been learning solidity from yesterday.

One thing is so confusing to me.

address someone = msg.sender;
someone.transfer(10);

If you look at the code above. It is too ambiguous.

someone send 10 ether to X, who is X? It's not specified in the code.


texts: How to compute pairing in a smart contract

texts:
I am working on the elliptic curve and pairing stuff in Ethereum smart contract. How can I compute pairing such e(p1,p2)?

I know that we have a pre-compile pairing check in Ethereum client which is live at 0x08, and performs the pairing check.

  From the documentation:

success := call(sub(gas, 2000), 8, 0, add(input, 0x20), mul(inputSize, 0x20), out, 0x20)

This means we can just check equality of two pairings in a smart contract. However, I require the computation of exactly one pairing such as e(p1,p2)=? in Solidity.


texts: Signing raw transaction AssertionError: The field v must have byte length of 1

texts:
I have followed every option present in net to do Raw transaction I have followed

  ethereumjs-tx

let resData = {};
var Tx = require('ethereumjs-tx')
var privateKey = new Buffer('0xe331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109', 'hex')
var gasPrice = privateWeb3.eth.gasPrice;
var gasPriceHex = privateWeb3.toHex(gasPrice);
var nonce = privateWeb3.eth.getTransactionCount(req.body.fromAddress);
var nonceHex = privateWeb3.toHex(nonce);
var rawTx = {
    nonce: nonceHex,
    gasPrice: gasPriceHex,
    gasLimit: '0x2710000000',
    to: req.body.toAddress,
    from: req.body.fromAddress,
    data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
    chainId: req.body.chain
}

var tx = new Tx(rawTx)
console.log(tx.v);
tx.sign(privateKey)

var serializedTx = tx.serialize()
console.log(serializedTx.toString('hex'))

privateWeb3.eth.sendRawTransaction(serializedTx.toString('hex'), function(err, hash) {
    //  if (!err)
        console.log("hiii", err, hash); // "0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385"
});

This approach give me error in tx.sign(privateKey)

  AssertionError: The field v must have byte length of 1
      at Transaction.setter [as v] (node_modules/ethereumjs-util/index.js:609:9)


texts: Truffle deployment address keeps changing

texts:
I have a contract with a mapping that maps a number to an address and I'm trying to test the contract. Here is the relevant solidity code:

function _spawnPlayer(uint256 id) external {
    require(playerIndexToOwner[id] == address(0));
    players.push(Player(id));
    playerIndexToOwner[id] = address(this);
}

And here is how I'm testing that the created object is indeed assigned to the contract's address as an owner (the line line in the function).

it("Contract is assigned as the player's owner", () => {
    return BaseInstance._spawnPlayer(301).then(function (res) {
        BaseInstance.playerIndexToOwner.call(301).then((playerOwner) => {
            assert.equal(playerOwner, account, "Contract is not the spawned player's owner.")
        })
    })
});

My problem is for some reason playerOwner keeps changing every time I run the test and account is just accounts[0] so that should never change. So why does playerOwner keep changing? Is the address that deploys the contract not the same every time?


texts: 2-phase commit between IPFS and Ethereum

texts:
I'm interested in integrating IPFS and Ethereum, i.e. by putting metadata in the blockchain / contract, and underlying assets in IPFS.

Has anyone done any work bridging the two? The only way I can think of doing it is to write a nodejs server that makes web3 calls and also simultaneous IPFS api calls - but there is no 2-phase commit between these.


texts: How can read the data field in a transaction?

texts: if im sending a transaction including a hex data, who can read it? Is it encrypted and only the receiver can read it? If not, everyone can read the data...


texts: How can I include an abstract contract as an interface reference?

texts:
If I try to deploy the following with truffle, I get an error:

  Error encountered, bailing. Network state unknown. Review successful
  transactions manually. Error: The contract code couldn't be stored,
  please check your gas amount.
      at Object.callback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:222830:46)

contract Foo{

    function a(uint _amount);

}

contract Bar {

    Foo foo;

    function Bar(address _foo){
        foo = Foo(_foo);
    }

}

So, what's the right way to include references to other contracts without including the whole contract?
I'm using Truffle v3.4.9

I don't want to craft the function signature manually like this:

fooAddress.call(bytes4(bytes32(sha3("a(uint256)"))), 100);


texts:
contract test  {

    bytes32 private constant ownerSlot = keccak256("ownerSlot");

    constructor(address _implementation) public {
        bytes32 s = ownerSlot;
        assembly {
          sstore(s, _implementation)
        }
    }

}

I saw this code in openZeppelin. I just removed lots of parts that don't matter for this question that I have..
so s variable in the constuctor will be 17d3e5a50a85cedc34e47ec97ca2e5dc1811e6f47a6d397255c987f7c733e0bd because this is what the keccak256 returns for the ownerSlot.
Question 1) As we know, storage slots start from 0. How is it possible that I can store something at 17d3e5a50a85cedc34e47ec97ca2e5dc1811e6f47a6d397255c987f7c733e0bdth slot ?
Question 2) One of the answers from this stackExchange  told me that if you're using let's say 15th slot, and you didn't put anything in previous slots, you still have to pay for all those slots. Is this correct ? if so, since 17d3e5a50a85cedc34e47ec97ca2e5dc1811e6f47a6d397255c987f7c733e0bd this number is so huge, paying for all previous slots is cruel. What's your opinion ?


texts: Clique - too few transaction inside a limited block

texts:
i have got the problem that my private node doesn't put all transactions that would be possible inside a block.

Concret i am running a private poa node which should have a fixed blocksize. Therefore i started the node by using: geth --targetgaslimit 210000 --networkid XXXX --mine --datadir "." --nodiscover --rpc --rpcport "XXXX" --port "XXXX" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password XXXX --ipcpath "~/.ethereum/geth.ipc" (XXXX are here just placeholder)

The private node runs sucessfull and mines block and put transactions inside the blocks. But therebye not all transactions that would be possible are put into a block. For example i have got 42 waiting transactions with a size of 21.0000 so that 10 transactions should be put inside a block. But only 6 transactions ar put inside a block.

I don't understand why only 6 and not 10 transactions are put inside a block. Can it be because of the targetgaslimit that i have set?


texts:
I wrote the following script to send Ether. I can't figure out why the balance is still the same after I send out the Ether. I re run this script multiple times but nothing changes with the balance. Even when I check the blockchain network at https://ropsten.etherscan.io/address/0xbf14644246ebb0209bdb03be0cd1a3b27fc009af

I don't see either the test Ethers that I mined nor the transaction.

I am currently using the test network geth --testnet

What is wrong?

var Web3 = require('web3');
var web3 = new Web3();

web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

var coinbase = web3.eth.coinbase;
console.log('coinbase address',coinbase);

var balance = web3.eth.getBalance(coinbase);
console.log('balacance', balance.toString(10));

var recipient_address =  web3.eth.accounts[1]
console.log('recipient address',recipient_address);

web3.personal.unlockAccount(coinbase, 'love2017');
console.log('coinbase address',coinbase);
web3.eth.sendTransaction({
    from: coinbase,
    to:recipient_address ,
    gas: 200000,
    value: web3.toWei(1, "ether"),

}, function (err, address) {
    if (!err) {
        console.log('success transaction address is', address); // "0x7f9fade1c0d57a7af66ab4ead7c2eb7b11a91385"
        var balance = web3.eth.getBalance(coinbase);
        console.log('balance', balance.toString(10));

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

This is what I get in the console:

coinbase address 0xbf14644246ebb0209bdb03be0cd1a3b27fc009af
balacance 8930000000000000000000
recipient address 0x15fd7829542d2e851a9787d76f027992b89b2398
coinbase address 0xbf14644246ebb0209bdb03be0cd1a3b27fc009af
success transaction address is 0x093b9306e7b0517e105168b9cd4f42344eddcb7cfa10e9f6d9a095cf9cd1e66c
balance 8930000000000000000000


texts: How do I access the owner's funds in the Truffle test environment?

texts: I'm trying to test my simple coin-based contract in the Truffle test environment by sending funds to the first user's address. My understanding is that the contract is created (thereby calling the constructor) by migrating the contract to the blockchain, which then creates X amount of tokens. These tokens are then owned by me, accessible in the solidity code as "msg.sender." My question is: how do I access the funds located at "my" address?


texts: My node lags behind, and more and more so

texts:
A few months ago, I had no problem to synchronize my Debian node.

Now, I lag behind and I cannot catch up. There are long delays between blocks Here, a gap of several hours:

I0507 03:40:13.321969   16722 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 1378 txs in 45.488001366s. #1338740 [52e1c2f7 / 3d439d7a]
I0507 03:42:08.166768   16722 blockchain.go:1251] imported 120 block(s) (0 queued 0 ignored) including 2242 txs in 1m54.838952559s. #1338860 [74d6bc48 / 571a00ed]
I0507 07:03:40.398729   16722 blockchain.go:1251] imported 1 block(s) (0 queued 0 ignored) including 5 txs in 1.689365821s. #1338861 [3c7c01e5 / 3c7c01e5]
I0507 07:03:44.060437   16722 blockchain.go:1251] imported 4 block(s) (0 queued 0 ignored) including 16 txs in 2.390481608s. #1338865 [927ea50a / adffd667]

Restarting geth helps for a while, then it lags again. Here, in ten minutes, it handled only 1792 blocks:

 I0507 10:42:34.436031   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 717 txs in 1m31.364560511s. #1339483 [23503255 / 62f7a23e]
I0507 10:45:20.742741   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 1586 txs in 2m46.304754148s. #1339739 [8d414a9e / e03acc8d]
I0507 10:48:32.431543   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 1775 txs in 3m11.686776776s. #1339995 [03107cee / bd02756b]
I0507 10:49:55.772369   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 1006 txs in 1m23.296969827s. #1340251 [12803cd1 / 2db0e35c]
I0507 10:51:03.415782   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 984 txs in 1m7.641494118s. #1340507 [c012afb1 / 3fbdfcc5]
I0507 10:52:05.977043   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 1125 txs in 1m2.545164795s. #1340763 [102cda33 / 61ddeea2]
I0507 10:53:02.005868   14563 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 979 txs in 56.026910217s. #1341019 [f99249f3 / 80edeedc]

It would be enough if there were not these long stops. What can I check on my machine/network?

geth -fast does not help. May be because of this message at startup:

I0508 13:29:49.476026   30960 handler.go:92] blockchain not empty, fast sync disabled

Geth/v1.3.6/linux/go1.5.1

[Added later]

To be sure it was not the fault of the machine/network, I bought a dedicated server, 4cores and so on, and a proper Internet connection, which I monitor with Icinga to be sure there is no glitch. The problem goes on. For instance, the machine did nothing in the last hours. It is now 0902 and the last block was 12 hours before:

I0510 20:29:57.981100   30192 blockchain.go:1251] imported 256 block(s) (0 queued 0 ignored) including 229 txs in 6.654488036s. #263709 [df5a5d05 / 2cf0a4a3]
I0510 20:30:01.578214   30192 blockchain.go:1251] imported 122 block(s) (0 queued 0 ignored) including 97 txs in 3.594111842s. #263831 [62820dc4 / 8c183313]
>

On the same machine, testnet is synchronized in a few hours, without these stops.


texts: Token transfer from private network to public

texts: I want to transfer my token from private network(quorum) to public network(ethereum), so I have burned the equal amount of tokens in quorum network and minted same amount of tokens in ethereum network. How could I know that these minted tokens came from quorum network. Is there any way to get that quorum block information from ethereum so that it could tell that these minted tokens came from quorum network ?


texts: Noob: If everything is public, how do I restrict access by clients?

texts:
Lets say I want to create a protocol for storing user data for ecommerce stores.

If Walmart and Macy's sign up, how do I prevent Walmart from accessing Macy's user data when they do something like user.all ? Is there a way to scope it to just Walmart?

Perhaps if I created a ClientUser smart contract that Walmart and Macy's interact with directly and created a separate private / public key for each client, and each had a config for store_name: "Walmart" and store_name: "Macy" and had the ClientUser contracts talk to my DatabaseContract that would work? Not sure how I would store the users honestly.


texts: Is there any way to access abstract contract in web3?

texts:
I have a IERC20.sol file which is the interface of ERC-20 standard.
In my Dapp, I don't want to implement any ERC-20 tokens. I just want to use the existing tokens so all I need is a interface and the existing token address to interact with them right?
when I want to load the IERC20.json using web3.eth.contract, it will throw an error, because there is no address for the IERC20.json
const networkId = await web3.eth.net.getId()
const erc20Data = IERC20.networks[networkId]
if(erc20Data) {
  const erc20 = new web3.eth.Contract(ERC20.abi, erc20Data.address)
  this.setState({ erc20 })
} else {
  window.alert('erc20 contract not deployed to detected network.')
}

note that I have imported the related address and abis. I have loaded multiple contracts in my web page using this method, but the IERC20 can't be loaded using this method.


texts: Multiple Inheritance at particular contract address

texts:
I'm attempting to have 4 different contracts sharing the same data fields.  The reasoning behind having 4 instead of 1, is that the different functionality can be broken down so that it is cleaner, and easier to understand.  However, I wish to share particular storage between the contracts.  The desired relationship can be seen below:

Thefactory contract will store the data required by each of the other 4 controller contracts Admin, user, Operator, and System, and spawns other contracts that will be interacted with by the controller contracts.

I have tried hierarchical inheritance:

import "./Admin.sol";
import "./User.sol";
import "./Operator.sol";
import "./System.sol";

contract Factory is Admin, User, Operator, System{

    uint public stage;
}

contract Admin {
    function adminDoesSomething () { if(stage == 1){ stage = 2} }
}

contract User {
    function userDoesSomething () { if(stage == 2){ stage = 3} }
}

contract Operator {
    function operatorDoesSomething () { if(stage == 3){ stage = 4} }
}

contract System {
    function systemDoesSomething () { if(stage == 4){ stage = 5} }
}

However, this results in Admin, User, Operator and System not having access to stage as it is isn't declared in their own contracts.  Leading me to then try it in the opposite way:

import "./Factory.sol";

contract Factory {

    uint public stage;
}

contract Admin is Factory {
    function adminDoesSomething () { if(stage == 1){ stage = 2} }
}

contract User is Factory {
    function userDoesSomething () { if(stage == 2){ stage = 3} }
}

contract Operator is Factory {
    function operatorDoesSomething () { if(stage == 3){ stage = 4} }
}

contract System is Factory {
    function systemDoesSomething () { if(stage == 4){ stage = 5} }
}

Now this results in multiple different instances of the factory contract, and that stage variable is not shared among the contracts.

So another potential solution is having an eternal storage contract.  This is a good solution, apart from the total amount of calls being made, changing of data, grabbing data so the gas costs may be high.

Does anybody have any suggestions, a little bit stuck right now?


texts: How to view and access the smart contract deployed by some other node in the Private Network?

texts: If First node in the private blockchain deploys the contract and second node in the network wants to request data from that contract, then how the second node will send request to the smart contract?


texts: What are the "basic features" of tokens that allow the Wallet to display them?

texts:
Here it says:

  Since all tokens implement some basic features in a standard way, this also means that your token will be instantly compatible with the ethereum wallet and any other client or contract that uses the same standards.

Are those standards documented?


texts: Gas costs of storing in mapping, initial vs subsequent

texts:
I have the following simple storage code:

pragma solidity ^0.4.17;

//The Oracle contract provides the reference prices for the contracts.  Currently the Oracle is updated by an off chain calculation by DDA.  Methodology can be found at www.github.com/DecentralizedDerivatives/Oracles
contract Test_Oracle {

  /*Variables*/
  //Mapping of documents stored in the oracle
  mapping(uint => uint) oracle_values;

  //Allows the owner of the Oracle to store a document in the oracle_values mapping. Documents
  //represent underlying values at a specified date (key).
  function StoreDocument(uint _key, uint _value) public {
    oracle_values[_key] = _value;
  }

  //Allows for the viewing of oracle data
  function RetrieveData(uint _date) public constant returns (uint data) {
    return oracle_values[_date];
  }
}

Now I create the Test Oracle and do the following transactions:

a)StoreDocument(1,1000)
b)SotreDocument(1,1000)
c)StoreDocument(1,1000)
d)StoreDocument(2,999999999999)

The following transaction and execution costs are recorded:

a)42024,20304
b)27024,5034
c)27024,5034
d)42216,20304

Some questions...
Why are a and b different?
Why are a and d different on transaction cost but not execution cost?

Maybe someone a bit more familiar with the low level EVM knows an answer.   Thanks for any help in advance!


texts:
I am making a project on blockchain where in I am using ganache for private blockchain, meta mask to interact with the same.
Since ganache provides 10 nodes in the private blockchain, I want all the nodes or at least 2 of them to interact with the one another through UI.
For ex:
I have this UI running which I made in App.js file and on the UI there is an option of uploading a photo and after uploading, the picture is displayed on the same UI page.
What I want is, uploading part should be done by the another node of the ganache, after uploading the 1st node's UI should display the image. Image is stored on IPFS.


texts: Unable to use wallet.ethereum.org with my own node

texts:
I'm running my own ethereum node on my LAN with command line:

nohup geth --rpc --rpccorsdomain "https://wallet.ethereum.org" --rpcaddr <ip> &

When running a curl command on a git bash console on my other PC it works:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' <ip>:8545
{"jsonrpc":"2.0","id":67,"result":"Geth/v1.6.7-stable-ab5646c5/linux-amd64/go1.8.3"}

But my issue is that https://wallet.ethereum.org/ doesn't connect to it. Have I missed something here?


texts: How to listen for contract creation, or all block events?

texts:
I'm building a web app with web3 where users can deploy a certain contract and assign some people to it. Inside the constructor of that contract I also output a certain event. I want these assigned people to get notified when something like this happens, but so far, I haven't found anything.

So my question is, is it possible to somehow listen for contract creation events in general, or better yet, a custom event emitted from any new contract?


texts: eth_getLogs only returns logs for last transaction


texts:
I have created a contract using solidity which has a comment field. I want to provide multi language support  so that user can insert and retrieve comment in any language.

Please suggest how we can achieve this feature?


texts: Use new to generate an instance of a sub-contract in a smart contract

texts:
When we write a smart contract, we can use the keyword new
in the code to generate an instance of a sub-contract. I want to know whether the instance of this sub-contract has an address, and can external addresses access the instance of this sub-contract?
Hope you can give me some help, thanks!


texts: What is 'the last add pending transaction' in web3 filter?

texts:
I run this code using MetaMask to inject web3 object:

var filter = web3.eth.filter('pending');
filter.watch(function (error, log) {
  console.log(log);
});

From web3 api docs:

  When using the "pending" parameter, it returns a transaction hash of the last add pending transaction.

My log looks like this:

I can't fing anything that would look like a transaction hash of the last add pending transaction.

I'm not sure if it's an issue with MetaMask. Could anyone running the node please run this code and post here the log?


texts: How to make users trust my contract and me?

texts:
I bought a ticket to attend StrangeLoop 2017 (IMO, one of the best conferences out there), but something came up and I can no longer attend.

Since I'm learning about Ethereum, I thought it might be a good, fun idea to raffle off my ticket using a smart contract that is provably fair and publicly auditable.

The idea is that people would buy raffle tickets by sending X amount of ether to the contract, and once the deadline finishes the contract itself would randomly choose a winner. But I wonder...

If I were someone interested in participating in the raffle... how could I trust that if won I would actually receive the conference ticket?

In other words, more than trusting the contract, in this case, I would need people to trust me.

Is there anything I can implement in the contract itself in order to gain the trust from the users?


texts: Is Raiden viable for one way micro payments?

texts:
As an example if we wanted to increase participation on the Ethereum stackexchange, we could set up a contract to make micro payments out to stack members based on reputation/badges.

This would only make sense in a no-fee or extremely low fee scenario. Is Raiden the correct way to approach such a solution or are there other viable existing alternatives on ethereum?