texts: How to track a missing transaction on private testnet?

texts:
I'm having trouble getting a couple test transactions to show up in the destination account balance. Code is below. Appreciate someone pointing out whatever move I've made...

Running geth as:

geth --rpc --networkid=34534 --maxpeers=0 --datadir=~/.ethereum/DevChain/ --mine --minerthreads 1 --genesis development_genesis.json console

Console session:

> var receiver = eth.accounts[1];
undefined
> var amount = web3.toWei(1, "ether")
undefined
> var amount = web3.toWei(2, "ether")
undefined
> personal.unlockAccount(eth.accounts[0], “passwd”, 9000)
true
> eth.sendTransaction({from:sender, to:receiver, value: amount})
I0401 19:49:03.928354 eth/api.go:1072] Tx(0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40) to: 0x9a22b931b03768958141afa40d66fa587c7bfd3a
"0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40"
> eth.pendingTransactions
[{
    blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
    blockNumber: null,
    from: "0x87fa50f10eda0ee47376427d4623deae9577c048",
    gas: "0x15f90",
    gasPrice: "0x4a817c800",
    hash: "0x8c3c85c225c76bd558cba37c7336d73aec9825e668da3b241d80119bde3a6d40",
    input: "0x",
    nonce: "0x0",
    to: "0x9a22b931b03768958141afa40d66fa587c7bfd3a",
    transactionIndex: null,
    value: "0x1bc16d674ec80000"
}]
>
> miner.start(1)
I0401 19:49:13.013921 miner/miner.go:119] Starting mining operation (CPU=1 TOT=2)
true
> I0401 19:49:13.044968 miner/worker.go:564] commit new work on block 28 with 1 txs & 0 uncles. Took 31.004161ms
> checkAllBalances()
  eth.accounts[0]: 0x87fa50f10eda0ee47376427d4623deae9577c048   balance: 135 ether
  eth.accounts[1]: 0x9a22b931b03768958141afa40d66fa587c7bfd3a   balance: 0 ether

I wanted to see 2 ether in that second account. (Actually 3 ether since a prior transaction also never seems to have gone through.)

checkAllBalances() is:

function checkAllBalances() {
var i =0;
eth.accounts.forEach( function(e){
     console.log("  eth.accounts["+i+"]: " +  e + " \tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether");
i++;
})
};

The transferred 2 ether just finally showed up, after about 5 blocks were mined. Is that expected behavior?

But then I sent another 3 ether and it showed in other account balance much more quickly. Now I have 0.5 ether pending, with mining output recognizing 1 txn but eth.pendingTransactions still showing it pending.

Is there a private testnet block explorer?

Would love a way to plug in a transaction and get a picture of what's happening.

Appreciate your tips as I learn the basics!


texts: Only 1 .SOL contract file is compiled in truffle project

texts:
I am having a very annoying problem but hopefully very simple to solve! I have a truffle project. In my contracts directory I have 2 files:

>     1_Migrations.sol
>     2_Factoring.SOL

When I type compile --all from the command line, the compiler only compiles 1_Migrations.sol. I deleted all the .JSONs to see what would happen and the result is nothing happens - no compile and no JSONs created apart from Migrations.JSON.

Does anyone have any idea what I might be doing wrong?

Thanks!


texts:
I have a contract deployed on the blockchain that returns multiple values.

contract Test{
   function getAandB( uint x )returns ( uint a, uint b ){

       uint y = x * 2 ;
       return ( x , y )
   }
   }

The question is how do I access both returning values when calling the contract externally from web3?

    var  ( a , b ) = myContractInstance.getAandB( x );

gives me an error

   var   value  = myContractInstance.getAandB( x );
   console.log ( value.a )

comes back as undefined


texts: How can I make a database and smart contract interact?

texts:
I started to code a smart contract which was supposed to store some datas from corporations. These datas (mostly names and dates) were organized like that :

├── Client1(Contract)
│   ├── Year2018 (Struct containing string,uint and struct)
│   │   ├── Case 1 (Struct containing string)
│   │   └── Case 2 (Struct containing string)
│   └── Year2017
│       └── Case 1 (Struct containing string)
├── Client 2
│   └── Year2018
│          ├──Case1 (Struct containing string)
│          └──Case2 (You got it)

I managed to make a contract to fill these structs. Therefore , I realized that this process was way too heavy and costly. It won't be a problem if my project interact with a centralized database , the blockchain is used for verifications purpose only.

Few people on this forum suggested me to "hash the datas and store them on a DB". I think that would be a great solution but I can't get how to setup this ...

How would I store the above structure of data on a DB ? How would I upload the datas first (Is it from DB to smart contract or the contrary ? ) ?  Would it be possible to visualize the datas on a block eplorer ?

Please ask if you didn't get something in what I said :)
Thank you very much and have a good day


texts:
I have set up drizzle to be able to connect to my smart contract from my react-application. After some fiddling, I decided to make this function in my smart contract:

/*** test ***/
uint numberFive = 5;

function getNumber() public view returns (uint) {
    return numberFive;
}

Then I tried to output the number on my page.

class Logged extends Component {
  constructor(props, context) {
    super(props);
    this.contracts = context.drizzle.contracts;
    this.methods = this.contracts.ItemOwnership.methods;
    this.numberKey = this.contracts.ItemOwnership.methods.getNumber.cacheCall();

  }

  render() {
    // If the data isn't here yet, show loading
    if(!(this.numberKey in this.props.ItemOwnership.getNumber )) {
      return (

Not retrieved yet

      )
    }
    console.log(this.props.ItemOwnership);
    let number = this.props.ItemOwnership.getNumber[this.numberKey].value;
    return (

        <Container className="logged-in">
          <Row>
            <Col className="center">

You are logged in to:

{this.props.account}

!{number}!

              {console.log(number)}
            </Col>
          </Row>
        </Container>

    )
  }
}

const mapStateToProps = state => {
  return {
    account: state.accounts[0],
    ItemOwnership: state.contracts.ItemOwnership,
  };
};

Logged.contextTypes = {
  drizzle: PropTypes.object,
};
export default drizzleConnect(Logged, mapStateToProps);

The test above returns null.
However, cacheCall does update the value, as seen in this image of the drizzle store:


texts: Does Geth provide a private or public network?

texts:
I'm new to the Blockchain world, lacking experience and I'm looking for some assistance.
I'm just syncing with ethereum network by using Geth and rinkeby network.
by using this command:

geth --rinkeby --rpc --rpcapi="personal,eth,network,web3,net" --ipcpath "\\\\.\\pipe\\'\\\\.\\pipe\\geth.ipc"

but I cannot know what type of network I was syncing with? Is it private or public?
and what are the differences between both, as we can see for all transactions detail for both?


texts: Is it possible to stake ETH and automatically send the rewards to another wallet?

texts: I'm wondering if there is an established way for me to stake ETH from one address and have a different address earn the staking rewards?


texts:
i am new to the blockchain, ethereum. I am trying to include metamask in my nodejs application. How to do that?

Any help would be appreciated.


texts: UI integration with Smart Contract in case of using JavaScript VM

texts: Is it possible to integrate an UI with a smart sontract in case of using java script vm in remix ? or we have to use web3 provider ?


texts:
I am currently trying to build a simple Process in Solidity, but somehow I get :

  Error: Member "length" not found or not visible after
  argument-dependent lookup in string memory for the function post.

I'd be very thankful if anyone could help!

pragma solidity ^0.4.18;
contract billboard {
    struct Contributor{
        string name;
        string email;
        string message;
        address addr;
    }
    address public owner;
    string public name;
    string public default_name;
    string public email;
    string public message;
    address public addr;
    uint public numPosts;
    uint public limit_posts;
    mapping( uint => Contributor ) public contributors;
    uint public timestamp;
    address public winnerAddress;
    uint public winnerInd;
    bool public stopped;

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

    function billboard(string _title) public {
        owner = msg.sender;
        numPosts = 0;
        stopped = false;
        limit_posts = 1002;
    }
    function post(string _name, string _email, string _message) public payable isStopped {
        name = _name;
        email = _email;
        message = _message;
        require(_message.length != 0);
        require(limit_posts > numPosts + 1);
        if(_name.length == 0) {
            _name = default_name;
        }
    }
    function hold() public onlyOwner {
        require(numPosts >= 3);
        timestamp = block.timestamp;
        winnerInd = timestamp % 3;
        winnerAddress = contributors[winnerInd];
        if(!winnerAddress.send(this.balance)) {
                require( false ) ;
        }
    }
    function kill() public onlyOwner {
        selfdestruct(owner);
    }
}


texts: Unable to assign genesis balance in Ethereum private network

texts: Cant able to assign the balance through the custom genesis.json file.here is my screenshots.


texts: How to check balance of a smart contract in Remix IDE Javascript VM?

texts:
I'm working on a smart contract that can hold some ETH.

Currently, I'm unable to see what is its balance in the Remix IDE.

I'm trying to use the console:

I have access to web3 but how to check the balance? Or maybe it's somewhere in the UI, that would be even better.

Sample contract that can receive Ether via fallback function:

pragma solidity ^0.4.25;

contract Payable {
    function() external payable { }
}


texts: On Mist, can I create a .json file wallet protected by a password (or not) just like ethereumwallet?

texts: Wll basically tht is the question on the latest Mist version, can I create a .json file wallet protected by a password (or not) just like I did using ethereumwallet.com?


texts: How to test chain reorganization with testrpc?

texts: I am working on blockchain synchronization script. I need a way to make reorganization programmatically for testing purposes. Is there such functionality in some testrpc?


texts: Difference between "specific" and "generic" proxy functions and how/when to use them

texts:
Hello I am trying to build a proxy contract and I've seen two approaches:

1- "Specific" proxy function, where the proxy function can only call a specific function of the other contract.

Ex: (taken from this post)

contract Proxy is mortal {

address watch_addr  = 0xEB1e2c19bd833b7f33F9bd0325B74802DF187935;
address user_addr   = msg.sender;

function register(string _text){
    Name name = Name(watch_addr);
    name.register(_text);
}}

2- "Generic" proxy function, where the function can be used to call any other function of any other contracts:

contract Proxy is Owned {
event Forwarded (
    address indexed destination,
    uint value,
    bytes data
);

function () payable{}

function forward(address destination, uint value, bytes data) onlyOwner {
    if (!destination.call.value(value)(data)) {
        throw;
    }
    Forwarded(destination, value, data);
}}

I have two questions:

1 - What are the advantages/disadvantages of the two techniques?

2 - How does one uses "Generic" proxy functions? I'm not sure how I construct the parameters value and data required to run the transaction. I'm also not sure if I need to fund the contract before (my guess is yes)


texts: How to get all the historical data from chainlink price feeds?

texts:
I wanted to pull the historical data stored by the reference data contracts by chainlink oracles. Since all the data is on-chain, I should be able to view it all? But currently, my contract can only see the latest answer. Any thoughts?
pragma solidity ^0.6.0;

import "@chainlink/contracts/src/v0.6/dev/AggregatorInterface.sol";

contract ReferenceConsumer {
  AggregatorInterface internal ref;

  constructor(address _aggregator) public {
    ref = AggregatorInterface(_aggregator);
  }

  function getLatestAnswer() public returns (int256) {
    return ref.latestAnswer();
  }
}


texts: What is the difference between Remix and Remix IDE?


texts: solidity declarationerror identifier not found or not unique for voting

texts:
I have this code for a voting system but when I compile it give me error in here ( boolean if_voted; )
can any one help me please.
thank you

this is the code :

pragma solidity >=0.4.22 <0.7.0;

contract Ballot {
    struct Voter {
        uint weight;
        boolean if_voted;
        address delegated_to;
        uint vote;
    }
    struct Proposal {
        bytes32 name;
        uint voteCount;
    }

    address public chairperson;
    mapping(address => Voter) public voters;
    Proposal[] public proposals;
    constructor(bytes32[] memory proposalNames) public {
        chairperson = msg.sender;
        voters[chairperson].weight = 1;

        for (uint i = 0; i < proposalNames.length; i++) {
            proposals.push(Proposal({
                name: proposalNames[i],
                voteCount: 0
            }));
        }
    }
    function giveRightToVote(address voter) public {
        require(
            msg.sender == chairperson,
            "Only the chairperson can assign voting rights."
        );
        require(
            !voters[voter].voted,
            "The voter has used their ballot."
        );
        require(voters[voter].weight == 0);
        voters[voter].weight = 1;
    }
    function delegate(address to) public {
        Voter storage sender = voters[msg.sender];
        require(!sender.voted, "You have already voted.");

        require(to != msg.sender, "You can’t delegate to yourself.");

        while (voters[to].delegate != address(0)) {
            to = voters[to].delegate;
            require(to != msg.sender, "Found loop in delegation!");
        }
        sender.voted = true;
        sender.delegate = to;
        Voter storage delegate_ = voters[to];
        if (delegate_.voted) {
            proposals[delegate_.vote].voteCount += sender.weight;
        } else {
            delegate_.weight += sender.weight;
        }
    }
    function vote(uint proposal) public {
        Voter storage sender = voters[msg.sender];
        require(sender.weight != 0, "Cannot vote");
        require(!sender.voted, "Has voted.");
        sender.voted = true;
        sender.vote = proposal;
        proposals[proposal].voteCount += sender.weight;
    }
    function winningProposal() public view
            returns (uint winningProposal_)
    {
        uint winningVoteCount = 0;
        for (uint p = 0; p < proposals.length; p++) {
            if (proposals[p].voteCount > winningVoteCount) {
                winningVoteCount = proposals[p].voteCount;
                winningProposal_ = p;
            }
        }
    }

    function winnerName() public view
            returns (bytes32 winnerName_)
    {
        winnerName_ = proposals[winningProposal()].name;
    }
}


texts: Error creating contracts on Ethereum wallet. Need help

texts:
I am trying to create an ERC20 token off of ethereum, but when I put the code in the editor in the ethereum wallet, I get a weird error. It says:

 "throw" is deprecated in favour of "revert()", "require()" and "assert()".
    if (balanceOf[msg.sender] < _value) throw;
                                        ^---^

(from Ethereum Blog)
(Source Code)
Can someone please help me with this?


texts:
I am experimenting with the MyAdvancedToken code at:  https://www.ethereum.org/token

    function setPrices(uint256 newSellPrice, uint256 newBuyPrice) onlyOwner public {
        sellPrice = newSellPrice;
        buyPrice = newBuyPrice;
    }

    function buy() payable public {
        uint amount = msg.value / buyPrice;               // calculates the amount
        _transfer(this, msg.sender, amount);              // makes the transfers
    }

If the amount purchased = msg.value/buyPrice, how is it ever possible to buy a token that is worth less than 1ETH?  buyPrice cannot be a decimal less than 1. In other words, I want it so a person can send 1 ETH and receive 10 tokens.  This math does not allow that (buyPrice cannot be 0.1).

Some of the documentation says that value and buyPrice should be in wei, not ETH.  In that case, I could make the math work.  However, in testing using MyEtherWallet and the Ethereum Wallet application, I am seeing msg.value come over as ETH.  If I send 1 ETH, with buyPrice = 10, the user ends up buying 0.1 tokens.

Is there a trick to getting the msg.value to be wei instead of ETH?

Thanks.


texts: Web3 Cannot read property 'apply' of undefined

texts:
I'm new to dapp and trying to follow iwaldman to build an ipfs-image-dapp. Here is the repo: https://github.com/iwaldman/ipfs-image-dapp.

But running yarn start gives the error Cannot read property 'apply' of undefined.
I have tried the method given by the net such as

    if (typeof contract.currentProvider.sendAsync !== "function") {
       contract.currentProvider.sendAsync = function() {
         return contract.currentProvider.send.apply(
            contract.currentProvider,
            arguments
    );
  };
}

But it gives another error that Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'Window'.

I must have done something wrong. I'm using the latest metamask and ganache v2.0.1. I have turned off metamask's privacy mode. Could anyone give me some advice? Thank you.

Please forgive my poor English.


texts: Trying to call a method in a contract, invalid address error/Type Error

texts:
Hi I have a deployed contract

pragma solidity ^0.4.0;
contract adderr {
    int total;
    function adder() public {
        total = 0;
    }
    function getTotal() constant returns (int){
        return total;
    }
   function addToTotal(int add) returns (int) {
       total = total + add;
       return total;
   }
   function calculateProof(string document) constant returns (bytes32) {
       return sha256(document);
   }

}

I am trying to call the method addToTotal, so I do:

var address = Contract address (This is 100% correct i've triple checked)
var abi = contract abi interface from remix, then taking line breaks out
var contract = eth.contract(abi).at(address)
Then I call with contract.addToTotal(5)
and get the error

Error: invalid address
at web3.js:3930:15
    at web3.js:3756:20
    at web3.js:5025:28
    at map (<native code>)
    at web3.js:5024:12
    at web3.js:5050:18
    at web3.js:5075:23
    at web3.js:4137:16
    at apply (<native code>)
    at web3.js:4223:16

NOTE: When i try the getTotal method there is no problem the returns the correct value

I have also tried to do:
var contract = new web3.eth.contract(abi,address)
To instantiate my contract, however this time when i try to call I get the error

TypeError: 'getTotal' is not a function
    at <anonymous>:1:1

I have tried called methods with both contract.addToTotal and contract.methods.addToTotal(5)

Would appreciate any help in this matter!


texts:
I have a token, let's call it TokenA, that inherits from Open Zeppelin Whitelist.sol. TokenB and TokenC both inherit from TokenA and they each have some additional functions.

I want all three Tokens to share the same whitlist, meaning:
- if I call addAddressToWhitelist in TokenA, whitelist(address), which is a function that returns true if the address is whitelisted and false if not, should return true if called from contract B or C.

How do I do that (or is it even possible)?

My current solution is to call addAddressToWhitelist in all 3 Tokens which doesn't seem very elegant.


texts: Is there any other way to implement the blockchain synchronization less time consuming?

texts: If we implement another way of synchronizing the blockchain, for example distribute it on several nodes and make groups of nodes handle the whole copy of blockchain instead of single nodes, (in order to reduce the time needed to synchronize the chain), does it make any harm to the integrity of the blockchain?


texts: When I tap buy button in market how does wallet check my allowance instantly?

texts: On CrytpoKitties, when I tap the buy button in a market, MetaMask comes up and shows if I can buy or not based on allowance instantly. How is this possible? Is it making query? Is it included in kitty's contract?


texts:
I see on ethstats that some node are connected to 100, or even 500+ peers.
I figured I'd try to increase my peer counts, e.g., in the hope of getting blocks and transactions broadcasted more widely faster.

I use geth --maxpeers=70 , but then, when I go to the geth console (e.g., geth attach), it seems I'm only connected to 35 peers. Where does the limitation come from? How does the node stop accepting peers?

Should I manually call admin.addPeer to add another bunch of peers?


texts: Can't send transaction using NODE-RED platform - "Warning! Error encountered during contract execution [Bad instruction]"

texts:
I'm trying to use NODE-RED (https://nodered.org/) on my RPi using web3 and geth to send simple transactions.

The code is the following:

//variables
var Web3 = global.get('web3');
var upc_abi = //contract abi
var upc_address = "0x15fC1a048C29C95605cbf906cC1f259573e49f4D";
var rpi_coinbase = "0x915c9fd51313cee6c94ae4f30d86edf2e79c8fe8";//accounts[0];
var rpi_1 = "0x0405468b70803989b7318d45d1a9c0bddffa6feb";

//web3.js, checking if node is running
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

if (!web3.isConnected()) {
    node.status({fill:"red",shape:"ring",text:"node not connected"});

} else {
    node.status({fill:"green",shape:"ring",text:"node connected"});
}

//fetching smart contract UPC
const Contract_upc = web3.eth.contract(upc_abi);
const Upc = Contract_upc.at(upc_address);

//function
node.send({payload:"Sending payment..."});

Upc.transferFrom(rpi_coinbase, rpi_1, 110, {
    from: rpi_coinbase,
    gas: 300000
});

return;

The function transferFrom that I use is taken from a token contract copied and pasted from the Ethereum website.

I tested the code using node.js and everything works fine, the tokens are correctly sent from one address to the other. However when I do it on NODE-RED the transaction is confirmed but the following error is returned:

  Warning! Error encountered during contract execution [Bad instruction].

My guess is that is somehow related to how I unlock the account. I use:

> personal.unlockAccount('0x915c9fd51313cee6c94ae4f30d86edf2e79c8fe8',"password", 99999)

Do you think the issue is related to this? If yes, how to solve it? If not, what then?


texts:
Hi everyone hope I will be clear enough with the explanation because I couldn't find a proper solution.
I am just trying to checkout an item with my buy function but it seems like I am stuck.Here is my code.

Here is my contract:

pragma solidity ^0.5.0;

contract Buy {
    address[] public buyers;
    uint256 public minAmount;

    struct Buyer {
    uint256 amountPayed;
    uint256 itemSelected;
    }
    mapping(address => Buyer) public buyerInfo;

    function buy(uint256 itemSelected) public payable returns (uint amount){
    require(itemSelected >= 1 && itemSelected <= 10);
    require(msg.value >= minAmount);

    buyerInfo[msg.sender].amountPayed = msg.value;
    buyerInfo[msg.sender].itemSelected = itemSelected;

    buyers.push(msg.sender);

        return amount;
  }
}

And here is my handleBuy function in React

handleBuy(e){
        e.preventDefault();
        this.state.simpleBuy.setProvider(this.state.web3.currentProvider);
        const account = this.state.account;
        var simpleBuyInstance;

        this.state.simpleBuy.deployed().then((instance) => {
            simpleBuyInstance = instance;

            this.setState(prevState => ({
                ...prevState,
                account,
                simpleBuyInstance
            }));

              return simpleBuyInstance.buy(2, {
                 from: account,
                 gas: 300000,
                 value: this.state.web3.utils.toWei(this.state.value.toString(), 'ether')
             })
        }).then((result) => {
            console.log(result);
        })
    }

this function above was working fine before implementing a payable.
I am having an error after the transaction saying :
inpage.js:1 MetaMask - RPC Error: Error: Error: [ethjs-rpc] rpc error with payload.
Any help would be appreciated.


texts: Smart contract not working in truffle console but working in Remix IDE

texts:
pragma solidity ^0.4.21;

    contract TransManager {
        uint transCounter;

        struct MetaData{
            uint id;
            address owner;
            string docType;
            string fileHash;
        }

        mapping (address => MetaData[])  fileLogs;

        function regTransaction(string _docType, string _fileHash) public {
            transCounter++;
            MetaData memory fileLog = MetaData(transCounter, msg.sender, _docType, _fileHash );

            fileLogs[msg.sender].push(fileLog);
        }

        function getTransactions() public view returns (uint[]) {
            MetaData[] storage temp = fileLogs[msg.sender];

            uint[] memory ids = new uint[](transCounter);

            for (uint i = 0; i < transCounter; i++){
                ids[i]=temp[i].id;
            }

            return ids;
        }
    }

truffle console --network ganache
truffle(ganache)> TransManager.deployed().then(function(instance){app=instance;})
undefined
truffle(ganache)> app.regTransaction("EDI","Hash",{from: web3.eth.accounts[1]})
{ tx: '0x46785333bce5f682c586ccf995682203a78d26bfba54957bb0bd5593d6cc4542',
  receipt:
   { transactionHash: '0x46785333bce5f682c586ccf995682203a78d26bfba54957bb0bd5593d6cc4542',
     transactionIndex: 0,
     blockHash: '0x26bf163083f35bade4aca17c2d05706846b4dd8f555efa7117cdea0b64da51ca',
     blockNumber: 5,
     gasUsed: 146345,
     cumulativeGasUsed: 146345,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }
truffle(ganache)> app.getTransactions()
Error: VM Exception while processing transaction: invalid opcode
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
truffle(ganache)>


texts: How is the txpool synced between nodes in a web3 JSON RPC provider?

texts:
From my understanding, there is a bit of state which is held on a node when interacting with it over JSON RPC. One of these states local to the node is the txpool. The txpool is exposed with the web3.eth.getTransaction(txHash) method. It returns a transaction where transaction.blockHash == null if the transaction is in the txPool and returns transaction == null when the transaction is unknown.

If a sendTransaction call is made to one node followed by a getTransaction call to another node, with the transaction hash returned from sendTransaction, a null transaction will be returned because the transaction is only in the first node's txpool and the second node knows nothing about it.

What do services like myetherwallet do to ensure that sessions are maintained across requests so things like this don't happen? Is there a way to synchronize the transaction pools?


texts: How can a smart contract payable based function returns value against any purchase

texts:
I am trying to get a return value from the payable function, the idea is a user must pay the fees and in return, he will get his special code.
My JS test code is as follow

it('get special code which was stored by the admin',async()=> {

        const user = accounts[4];

        // get the deployed contract instance
        contractInstance = await MyContract.deployed()

        const expectedCode = "Wolvorine";

        const fees = "1";

        let result1 = await contractInstance.getCode(user,{from:user,value:fees}) ;

    assert.equal(result1,expectedCode, " Code which was stored by the admin must be equal to the expected value")

My contract which returns the value is as below

 function getCode(address _identityaddress) payable
public returns (string memory)
{
    require((identity_details[_identityaddress].identityaddress==msg.sender));

    require(msg.value >= attestationFee);

    Transaction memory p = identity_details[_identityaddress];

    return (p.code);
}

Here Transaction is a structure data type that has code as a string variable inside. If I make this function without payable and don't take any money from the caller then return value accurately returns me the code. But since I am using payable and receiving ethers, therefore, it is returning me a big transaction object instead of my returned value.

What is the best way to tackle this issue since I want the user to use MetaMask only one time where he will just pay and then get this value in one shot?


texts: Having trouble sending eth from Metamask

texts:
I'm trying to withdraw some eth from Metamask into my GDAX account.

I select the amount and add my GDAX eth address. I've tried using up to 25 gas.

After that nothing happens - it just shows the following:

Am I doing something wrong with the gas? Should I try using more?

Does the gas come from eth? I think I'm burning gas with all these attempts but I'm not sure.

Thanks!


texts:
I've successfully installed Enthereum Geth in the 'Building without a Go workflow' section, using Ubuntu server. I am able to run with
./build/bin/geth
This give me a running console output. I'm looking for an entry in which i can entry one command at a time like the following commands. Any idea on how to do this?

Create new Accounts: geth account new --datadir ~/Node_1 and geth account new --datadir ~/Node_2 2. Initialize Genesis File: geth init customGenesis.json --datadir ~/Node_1 and geth init customGenesis.json --datadir ~/Node_2

Start Geth: NODE_1: geth --datadir ~/Node_1 --maxpeers 95 --networkid 13 --nodiscover --rpc --rpccorsdomain "" --port 30301 --rpcport 8544 --rpcapi="txpool,db,eth,net,web3,personal,admin,miner" NODE_2: geth --datadir ~/Node_2 --maxpeers 95 --networkid 13 --nodiscover --rpc --rpccorsdomain "" --port 30302 --rpcport 8545 --rpcapi="txpool,db,eth,net,web3,personal,admin,miner"

Connect Peers: admin.addPeer();

Peer Count: net.peerCount


texts: How to fetch ETH/USD price from the coinmarketcap api

texts: I want to fetch the current ETH-USD price from this api (https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=USD). How do I fetch just the price into a variable in PHP for reuse on my application?


texts: Oraclize callback is not called with more data in it

texts:
I have very strange experience with Oracle. When I try to add functionality inside of callback, callback is not called, but when I delete functionality callback works without problem.

I tried to increase gas amount using oraclize_setCustomGasPrice, use mapping, arrays and anything I know in functionality, nothing works.

Here are example of callback which is never called:

function __callback(bytes32 myid, string result) {
  if (msg.sender != oraclize_cbAddress()) revert();
  emit LogPriceUpdated(result);
 for (uint i=0; i < betId + 1; i++) {
    if (compareStrings("up", result)) {
        gameInfo[currentPrizePeriodTime][i].choice = result;
  }
 }
}

And here is example of code which is called all the time:

function __callback(bytes32 myid, string result) {
  if (msg.sender != oraclize_cbAddress()) revert();
    emit LogPriceUpdated(result);
  }
}

Does any of you why this happens, is it solvable or I should look for workarounds?


texts:
I have a transaction pending from 4 days.
I have tried to unlock following this answer:
MyEtherWallet is pending and dropping. It looks like it is stuck in a loop for 2 days?

Now the current nonce is 34, but the pending tx has nonce 27.

If I try to resend the tx with Higher GAS, the new tx fails with the error "nonce too low"

How can I unlock/resend tx?


texts: Ethereum client supporting websocket for development

texts:
Is there any ethereum client for development and testing that supports websocket connection. I want to use the subscribe API in web3.
testrpc does not support socket connection.


texts:
Truffle v5.0.5 (core: 5.0.5)
Solidity v0.5.0 (solc-js)
Node v10.15.1

  ReferenceError: address is not defined.

const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); // Pulls in my smart contract // the accounts are the 10 dummie ones
// the require pulls in the smart contract // the artifacts pulls in our code

contract ('ApprovalContracts', function (accounts) { // These are the accounts stored locally in the server the address
    //tests in javascript part of the contract //setup a contract and getting back the approver //takes a deposit im going to look and see what the balance is
    it('initiates contract', async function() {
        const contract = await ApprovalContracts.deployed();
        const approver = await contract.approver.call();
        assert.equal(approver, 0xc7780C9521C2C2abED69f0D65BEbF9794C55ae94, "approvers don't match");
    });

    it('takes a deposit', async function() {
        const balance = await web3.eth.getBalance(address.contract);  -----> ReferenceError: address is not defined
        const expected = web3.utils.toBN(1e+18);
        assert.equal(balance.toString(), expected.toString(), "amount did not match");
    });
});

Any advice I would be much appreciated.

const balance = await web3.eth.getBalance(address.contract);


texts: getting error while complining DeclarationError: Identifier not found or not unique. unit storedData;

texts:
I am getting the following error while complining DeclarationError:

Identifier not found or not unique. unit storedData;

   pragma solidity ^0.4.0;
//pragma solidity >=0.7.0 <0.9.0;
contract SimpleStorage {
    unit storedData;

    function set(unit x) public {
         storedData = x;
    }

    function get() constant public returns (unit) {
         return storedData;
    }

    function increment (unit n) public {
        storedData = storedData + n;
        return;
    }


texts: How to use a transfer function from an EOA holding a token to a contract address?

texts:
I am using an ERC20 token which is used by a smart contact, EOAs also holds tokens

How can I use the transfer function for transferring tokens from the EOA to a different Smart Contract address .

when I use the function transfer within the contract which is to be funded from an account which calls the parent function,

can it be done like this ?
tokenContractInstance.transfer(address(this), _bidValue);

will the tokens be debited from the msg.sender of the parent function ?

Thank You


texts: Dynamic arrays VS mappings when it comes to gas usage?

texts:
I'm puzzled what is more efficient to use, from the point of gas consumption (storage and execution), dynamic array or the mapping and element counter.

To be more clear, I'm not asking the basic data structure usage paradigms that we all should know, nor about pros and cons that each have, rather I want to know what is more gas efficient.

Let me give you an example in a sort of pseudo code:

contract DataStorage {

    //mapping and data counter
    mapping (uint256 => uint256) sequentialData1;
    uint256 sequentialData1Counter;

    //dynamic array
    uint256[] sequentialData2;

    function addDataToMapping(uint256 _newData) {
        sequentialData1[sequentialData1Counter++] = _newData;
    }

    function addDataToDynamicArray(uint256 _newData) {
        sequintialData2.push(_newData);
    }
}

Don't think about deleting elements and so on, let's say I just want to add new data to array and be able to access them by index.


texts: ZeppelinOS: zos push --network mainnet returns nonce too low

texts:
Im trying to deploy a set of contracts.
These are the steps I've followed (the same steps work fine in infura v3 ropsten):

zos add

Result:

{
  "name": "0.1.0",
  "version": "0.1.3",
  "contracts": {
    "MyContract": "MyContract"
  }
}

zos push --network mainnet_infura

truffle-config.js

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

const Web3 = require("web3");
const web3 = new Web3();
const gasPrice = web3.utils.toWei('7.5', 'gwei');

module.exports = {
    networks: {
        mainnet_infura: {
          network_id: 1,
          // gas: 7996144, // not needed, set by default
          gasPrice: gasPrice,
          provider: function () {
            return new HDWalletProvider(process.env.WALLET_MNEMONIC, `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`)
          }
        },
    }
}

Results in:

Compiling contracts...
//...
Writing artifacts to ./build/contracts

Deploying new UpgradeabilityProxyFactory...
Deployed UpgradeabilityProxyFactory 0x60abacaab5b33ba081749553d810944e3eb85dc4
Deploying new Package...
Deployed Package 0xb304cdf3ad373c47255b3042fd1a918b30d9984f
Deploying new AppDirectory...
Deployed AppDirectory 0x4d17e7b4390622c63b5a7722c5aad80948078983
Adding new version...
Successfully written zos.mainnet_infura.json
nonce too low

What's been written in zos.mainnet_infura.json:

{
    "contracts": {},
    "proxies": {}
}

Expected results:

Being able to call the zos create MyContract --init --network mainnet_infura command to create the proxy.

The resulting zos.mainnet_infura.json file should look like this:

{
  "contracts": {
    "MyContract": {
      "address": "0x22ccbe6e992e0c88ff9c909b1e6d9319e643d578",
      "constructorCode": "608060405234801561001057600080fd5b50611af4806100206000396000f300",
      "bodyBytecodeHash": "0a1379e7467296dc98fbc697956354b5d90442cb6585d638e5cdd356c8f1d7f9",
      "bytecodeHash": "bc1e9ac6c4bc4186477ee7da52a3c9494f2d4381dfd647ba4bb51d5fee49bf32"
    }
  },
  "proxies": {
    "MyContract": [
      {
        "address": "0xa5452fe698cd4fee0760627d34e1597b84c4a016",
        "version": "0.1.3",
        "implementation": "0x22ccbe6e992e0c88ff9c909b1e6d9319e643d578"
      }
    ]
  },
  "app": {
    "address": "0xe86ecda2102ba0ef8bacc00afe14e3f90f29fbac"
  },
  "version": "0.1.3",
  "package": {
    "address": "0xc54f206f5b96dca2877cf99fd3952cb9f98cf4e8"
  },
  "provider": {
    "address": "0xd5f61f90248c53a783b4027ac14d8a05fbe79ad1"
  }
}

Ideas:

Is there a way to delay the time between each transaction so the nonce gets synced?
I noticed that there are additional txs in etherscan associated to my address that are not Contract creations . What are these? Can I do them manually?
Where is the code of the contracts being created behind the scenes? UpgradeabilityProxyFactory..., Package..., AppDirectory...

I've tried these solutions with no success:
https://ethereum.stackexchange.com/a/50038/31101


texts:
Guys I want to build a mining pool for ethereum which is based on GPU mining.

I've searched alot but I couldn't find anything except genoil(cpp-ethereum) which supports GPU mining but the creation of pool or anything like that is not specified in it.

There is huge amount of mining pool available like dwarfpool, ethminer, nanopool e.t.c. I want to create the same pooling service as they are providing. Just let me know the basic start, i will get into deep my own.


texts: Error: missing trie node 60c376cdb14aec... (path)

texts:
I'm trying to start a geth node to connect to the Rinkeby test network by running

geth --networkid=4 --datadir=$HOME/.rinkeby --verbosity 0 --syncmode=light
--bootnodes=enode://a24ac7c5484ef4ed0c5eb2d36620ba4ea13b8c84684e1b4aab0cebea2ae45cb4d375b77eab56516d34bfbd3c1a833fc51296ff084b770b94fb9028c4d25ccf@52.169.42.101:30303?discport=30304 --rpc
--rpccorsdomain "*" --rpcapi=eth,web3,net,personal,ssh,db,debug --unlock="0xf905463ebd62121b16e0076cadc19a7b0e706c77" console

which has always worked fine (btw I'm aware of security concerns with the command but I don't really care about that for now). However, despite starting still, if I run

eth.getBalance(eth.accounts[0])

I get back an error

Error: missing trie node 60c376cdb14aec29386df043d081afcfa38a97da22e25d344c4104fd91cf6cc1 (path )
    at web3.js:3104:20
    at web3.js:6191:15
    at web3.js:5004:36
    at <anonymous>:1:1

This answer suggests removing the blockchain for a similar issue, but I'd like to avoid that since it took a while to download it the first time around. Any ideas how to solve this and why this started happening?


texts: How to reduce Ethereum DAG size in private network?

texts: I am using Go Ethereum and I am trying to use it for a private network, but the blockchain DAG takes up a lot of disk space on a light weight system. What things can be done to make it more light weight?


texts: Why can't MyEtherWallet automatically detect new tokens and their decimals, just like EtherScan?

texts: I'm just wondering whether it's practically not possible? Because on EtherScan, all my tokens are automatically listed, and when I choose one, I see the contract address and the number of decimals. Why do I have to add these manually on MyEtherWallet?


texts:
Oracle is a trusted third party API from which smart contract will fetch the data.

Zap is a way to monetize the data which smart contract is getting using a token called zap token.

Is there any tutorial/Github repository/Project/case study with appropriate technical explanation using all of the above tools?


texts: When launching a GETH node to Ropsten do I have to define the --bootnodes flag?

texts:
These commands work for me I was just wondering if there is a way not to hardcode the enode addresses into the shell script. Here is what I am using and its working:

geth --testnet --syncmode "fast" --ipcpath /home/ubuntu/.ethereum/geth.ipc --rpc --rpcapi db,eth,net,web3,personal --cache=2048 --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "db,eth,net,web3,personal" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:30303" --verbosity=6 --port "30303" --networkid 3

Is there a flag that will enable dynamic handling of enode admin peers?


texts: Array of Struct always returns 0x0 at index 0

texts:
Here's my sample contract code.

contract SimpleStore {

  uint public BetRound;
  uint public SelectedUser;

  struct Struct {
    uint _round;
    address _owner;
    uint _index;
    bool _active;
  }

  mapping(uint => Struct) public userIndexStruct;
  uint[] public userArray;

  function add(address _address) public {
    Struct storage accounts = userIndexStruct[userArray.length];
    accounts._round = BetRound+ 1;
    accounts._owner = _address;
    accounts._active = true;
    accounts._index = userArray.length;

    userArray.push(accounts._index);
  }

  function update(uint _index) public {
    userIndexStruct[_index]._round++;
  }

  function SetUsers() public returns (uint) {
      // If we reached the end of our array
      // it should mean we looped all users already
      // We need to increment the BetRound
      if(SelectedUser >= userArray.length ) {
          BetRound++;
          SelectedUser = 0;
      }

        for (uint i = SelectedUser; i < userArray.length; i++) {

          if (userIndexStruct[i]._round < BetRound) {
            if (userIndexStruct[i]._active) {
                // This is the user who is next to receive a reward.
                // Send rewards to the user, and then update his round.
                update(i);
                SelectedUser = i;
                // Return what user was selected
                return i;
            }
          }
        }

        // Our loop finished without result, we should move to the next round.
        BetRound++;
  }

}

Whenever i add a user to my struct, the first account index is 0.

If i verify this by entering index 0 in my userIndexStruct and the userArray, it returns the correct address.

However, every time my SetUsers loop hits 0, it returns address 0x0, and the next loop it returns the actual stored index[0] address.

Could someone please explain what's happening, and why it Always returns the 0x0 address when my loop begins with 0, instead of giving the correct address for my users stored in the struct with index 0?

Thank you!

Solved!

I simply forgotten to check array.length -1. Facepalm.

Thank you all for the time and effort!


texts:
So I already run geth. And I quit. I don't remember how I quit, maybe I typed with exit or ctrl+c.

Anyway, now I can see geth running when I type [ top ] command in console terminal of ubuntu 16.04 server.

Now how can I go to inside of geth console?
Thanks.

[ geth console ]
command just spit out errors says,
Fatal: Error starting protocol stack: datadir already used by another process


texts: What are the growth projections for the size of the Ethereum blockchain? Is it too early to start talking about the need for side chains? Will economics naturally pressure DAPPS to either choose the main chain or side chain depending on the cost of gas versus the perceived value that the DAPPs transactions provide?


texts: how to wrap data for transferAndCall to invoke another contract?

texts:
I have a token, and a service contract. I implemented the token based on ERC677, and tried to use transferAndCall to call my service contract.

In my service contract, there will be several methods can be called, like buyA(uint count, string comment), rewardBB(uint amount, string comment).

In my understanding, in the client side, I need to wrap the method name and params as a bytes with web3 api, then in the service contract, unwrap this data, get method name, and call corresponding method with the params data.

But I got some trouble in these 2 places:
 1. how to wrap/unwrap the data
 2. for some reason, I need to use the param type of string, which is dynamic, when I tested the following code, but the passed string param is alway empty. When I tried with type like bytes30, it can work.

  bytes4 methodId = bytes4(keccak256("rewardBB(uint5,string)"));
  require(_service.call(methodId, 100, "some string of params."));

Any advice would be very appreciated. Thanks.


texts: Geth monitor graphics character encoding

texts:
I have a local network in which I start each node with both the --metrics flag and the debug api enabled. So I can attach a console and retrieve the metrics by running, for instance

geth attach --exec "debug.metrics(false)" http://127.0.0.1:8545

and it works like a charm.

In the documentation it is stated, that one can use geth monitor to have a real-time view of the metrics graphics. Therefore I tried to follow the documentation with this command:

geth monitor --attach http://127.0.0.1:8545 "system/memory/allocs"

But I get unfortunately incomprehensible results as proved by this screenshot:

I think that this is probably due to the encoding used by the graphics. Therefore I tried with the majority of the encoding provided by my shell (KDE Konsole) but the result, remain always incomprehensible. (The Picture show the result with UTF-8).

Do one of you had the same problem, which is the right encoding to show the graph as in the documentation?

Additional Info:

geth version 1.8.8-stable

go version  go1.10.2

os Linux 4.9

shell kde-konsole

UPDATE I did try with Ubuntu and it works fine. Is it possible that I miss some packages?


texts: What is meant by locking of ether in proof of stake?

texts: In PoS, forgers stake their ether on a block. These ether are locked and can't be used. What does it mean by locking of ether and how does it work?


texts: Timeout error on deploying to private network

texts:
I am currently attempting to deploy a smart contract to a private ethereum testnet that I set up using Geth. I have Geth running in a separate terminal, set to my local ip and port 30303.
From a separate terminal, when I make an effort to run truffle migrate, I receive the following error:
Error: There was a timeout while attempting to connect to the network.
Check to see that your provider is valid.
If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
I did not set the provider in the config file due to the fact that I explicitly set the ip and port.
Is this wrong? what else am I missing?


texts: Using transfer() method but don't see payment in Ganache or Metamask?

texts:
I'm using the .transfer() method in my smart contract to pay a particular address.  I've checked the Ganache logs and the transaction does not revert and is auto-mined successfully.  But I don't see a VALUE transaction in the Ganache transaction logs reflecting the transfer and I don't see the amount paid in Metamask for the Eth address that was supposed to receive the payment.

Why don't I see a VALUE transaction in the Ganache transaction list or see the payment in Metamask?

function claimPayment(uint256 _gameId, bytes32 _videoId, address _payeeAddr)
        public
        onlyOwner
        onlyIfValidGameIdAndGameOverState(_gameId)
        whenNotPaused
        {
    require(_payeeAddr != address(0), "(claimPayment) The payee address is not set.");
    require(_videoId != "", "(claimPayment) The video ID is not set.");

    // Create a payment details structure from the input parameters so we can generate
    //  a mapping key.
    structPendingPaymentDetails memory pendingPaymentDetails =
        structPendingPaymentDetails(
            0,
            _gameId,
            _videoId,
            _payeeAddr,
            0,
            EnumPaymentType.NOTSET);

    // Build the mapping key from the pending payment details.
    bytes32 mapKey = hashPendingPaymentDetails(pendingPaymentDetails);

    // Make sure they have funds waiting for them.
    pendingPaymentDetails.paymentAmountGwei = s_mapPendingPaymentsByGame[mapKey].paymentAmountGwei;
    require(pendingPaymentDetails.paymentAmountGwei > 0, "(claimPayment) In the context of the given game and resource ID, the payee does not have any funds waiting for them.");

    // Make sure this contract has enough funds to cover the payment.
    require(address(this).balance >= pendingPaymentDetails.paymentAmountGwei, "(claimPayment) The contract does not have enough funds to cover the payment at this time.");

    // Remove the payment from our claim amount storage.
    delete s_mapPendingPaymentsByGame[mapKey];

    // Remove the payment from the pending payments list.
    removePaidAddressFromPendingPaymentsList(mapKey);

    // Make the payment.
    _payeeAddr.transfer(pendingPaymentDetails.paymentAmountGwei);
}


texts: On Ethereum 2.0 PoS, how/when are new coins minted?

texts:
In Ethereum "1.0", new coins are minted as reward for the miners. I understand from multiple sources (eg: academy.binance.com) that this won't be the case with Ethereum 2.0:

When a node gets chosen to forge the next block, it will check if the transactions in the block are valid, signs the block and adds it to the blockchain. As a reward, the node receives the transaction fees that are associated with the transactions in the block.

So... I understand that the validators will forge new block, write the transactions on them and add the new blocks to the blockchain. They will get the fees as a reward. So far so good.
What I'm missing here is: how/when will the new ETHs come into existence? Who will mint/get them?


texts: analysis of the opcodes used in smart contract execution on ropsten, geth

texts:
I've deployed the following verified smart-contract to ropsten:

contract Incrementer {
    uint iteration;

    function Incrementer() {
            iteration = 0;
    }

    function increment(uint count) {
        iteration += count;
    }

    function getIteration() constant returns (uint) {
        return iteration;
    }

}

What I'd like to do is call it, such that it will execute, and then I want to observe the resulting series of operations that take place in the EVM, i.e. what are the opcodes that are executed, and in what sequence. What is the best way to achieve that?


texts:
I have hundreds, or even thousands of arrays of integers that I'd like to return from a function.

I can't return one at a time, because the overhead of making a call to Etherum is too slow in javascript.

function getTimestampsFromArray(address[] contentProviders) public view returns (uint[][]) {
        uint[][] storage returnTimestamps;
        for(uint i = 0; i < contentProviders.length; i++) {
            returnTimestamps.push(addressToTimestamps[contentProviders[i]]);
        }
        return returnTimestamps;
    }

This is my current attempt. It compiles, but it seems that web3 doesn't recognize this type of function?

Does anyone have a way to do this efficiently?

Thanks!


texts:
On local ganache testnet, all functions of my contract are already working fine under JS web3.

While under Python web3 (4.1.0), calling view function and sending ether to the contract work (so signTransaction and sendRawTransaction are working), but calling a payable function always fails with --

ValueError: {'message': 'VM Exception while processing transaction: revert',
             'code': -32000, ...

For Python web3, I've been following the standard pattern --

from web3 import Web3, HTTPProvider
from pprint import pprint

w3 = Web3(HTTPProvider('http://localhost:8545'))

# define accounts and their corresponding pkeys...

tx_dict = contract.functions.myMethod(128, '').buildTransaction({
    'from': accounts[1],
    'value': amount_in_wei,
    'gas': 200000,
    'gasPrice': w3.toWei('21', 'gwei'),
    'nonce': nonce,
    'chainId': 1
})
pprint(tx_dict)
signed_tx = w3.eth.account.signTransaction(tx_dict, pkeys[1])
tx_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)

The line pprint(tx_dict) prints --

{'chainId': 1,
 'data': '0x69cd4a5c0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
 'from': '0x7Ca6bE2658d13c9c2089819ccb31EEF3C37f3522',
 'gas': 200000,
 'gasPrice': 21000000000,
 'nonce': 6,
 'to': '0x5a88143DC6B2E9eA79300d02A121F6eA1f518678',
 'value': 200000000000000}

I suspect something wrong with the tx_dict Python web3 builds.

My question is: Is there a way in JS web3 to show the pre-signed transaction object that I can compare with that built by Python web3?

Edit: I can't use debugging from Truffle to debug the reverted transaction ( http://truffleframework.com/tutorials/debugging-a-smart-contract ) because Python web3 can not connect to 'truffle develop' via localhost:9545 (which might be worth its own question...)


texts: I have installed the ethereum wallet on widows. But my account ether balance is 0.00 ether.  Then I started mining from developer network(Test only). But it shows nothing, I could not get any ether mined and waited for whole day too.  I've tried some possibilities on free mining from other faucet mining sites to claim some free there, it doesn't reflect on my account. Could you please help me on this to get some ether for my account?


texts:
Preface: The question relates to the relationship between the content of the Ethereum's receipts and the hash of the block header.

Problem description: I wonder, in Ethereum, blockid is based on the block's hash. The header contains the hash of the root of the receipts Trie. The receipt contains the block's ID.

But before putting the block's id into the receipt one needs to know the hash of the block itself (which contains a hash of the Receipts Trie) - in other words we've got a circular dependency.

Now, I see 4 possibilities:

1) The block contains receipts of transactions which are contained within the block; if not then this would be easy; receipts would be stored in consecutive blocks; but this would complicate things; as there would need to be an incentive for other nodes to include external receipts etc.

2) The hash of the Receipt's Trie does not take into account the blockID field within receipts. This would result in some of the data being malleable (not protected by the PoW).

3) The blockID is not based on the hash value of the entire header. Thus not taking into account the hash of the Receipts Trie.

4) Theres' no blockID inside of a receipt; but then I've seen these are included on some of the JSON print-outs available here. are these values appended by the command'processing interface implicitly?

Which one, or maybe another possibility, is it?


texts:
Suppose my friend has a 'Mona lisa', perhaps a simpler painting worth about 1 million.
He decides to create an NFT for it, and after authentication someone buys it for 100k.
Now he sells the painting to someone else.
Now what happens to the NFT? Especially as the new owner may or may not want to create their own NFT, and may not even know an NFT was created for the painting earlier.
Presumably both NFTs would be valid, but are they both holding full value?


texts: Bytecode: Does it Reveal What Language it Was Programmed In?

texts: Does EVM bytecode have some indication to what high-level language it was programmed in?


texts: Can I rely on certain oracle to know the precise and reliable timestamp?

texts:
I am learning the security impact of smart contract on system properties like block.timestamp and block.number. I understood that block.timestamp can be controlled by the miner to certain degree and therefore may be able to "beat the crowd" in some gambling games. Also, since the mining time of each block may vary, strictly speaking, the following code fragment may also cause certain confusions to users who are waiting for refund (e.g., a user is waiting until 99 minutes to ask for refund; however, since mining time becomes faster, the timing window has passed then):

    // user can get refund with 100 minutes.
    if (block.number < refund_window_end_block) {
     // however, since block mining time may change from time to time
     // the "refund_window_end_block" may not precisely depict "100 minutes".
         refund();
    }

I understood that there are some third-party oracle such that I can safely get some random numbers from. Similarly, can I leverage certain oracle to get a precise and reliable "timestamp" or duration time? Thank you.


texts:
The Ethereum network works very slowly.

I often am connected to 0 peers.

So what are (GMT) hours when it works the best, for accomplishing a transaction?

Also, which week days it work the best?

Also, will it help to make transactions if I use https://www.myetherwallet.com instead of Ethereum Wallet for Linux?


texts:
I'm testing AMM, so I have steps like

add liquidity,
try to swap
remove liquidity

etc
I can just add it in one it block like this answer suggests
contract('amm', (accounts) => {
    it ("test all three steps", async () => {
        // await step 1
        // await step 2
        // await step 3
    })
})

however the test output would in one block together, which isn't very informative. I can't use several It blocks because one steps depends on previous one.
Mocha has steps for that purpose, what's the truffle analog, if any?


texts: Is there a way to get the deployed contract from a contract ABI?

texts:
Found an implementation of a dapp that uses a solidity contract but what's only available is the contract ABI from their project and not the solidity file.

Just wanna ask if this is possible.


texts: Solidity - Smart Contract - Send eth from external account to smart contract

texts:
I read this example http://solidity.readthedocs.io/en/latest/solidity-by-example.html#simple-open-auction
to learn how to let my smart contract recieve eth from external account. It seems that I need a simple payable function.
So I wrote a contract with a simple payable function on Remix and test it with MetaMask (Ropsten Network), sending 1 eth from my external account to my contract. Failure, MetaMask tells me the contract throw an exception.
So, I added to the contract a fallback function and tried again to send eth.
It worked! But the example linked above doesn't tell me I need a fallback function, and I can't performe data storage (like store msg.value and msg.sender into variables) in a fallback function, cause it requires more gas that it can have!

Please, help me. I know it's a noob question but I can't figure out.

The very few contract's row:

THE ERROR:

Thanks to everyone!


texts: Transaction Error. Exception thrown in contract code. REVERT opcode when sending ETH to crowdsale

texts:
I wanted to follow the tutorial - https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 - but there was a new release - https://github.com/OpenZeppelin/zeppelin-solidity/releases/tag/v1.7.0 - so I'm trying to figure it out...

Actual code is verified on Etherscan.

Crowdsale: https://ropsten.etherscan.io/address/0x018ea8f3fef7bd14c7bff98e898842925f05e6ea#code

Coin: https://ropsten.etherscan.io/address/0x37ca578d3d847d27741b2ffc033419a7d11b7bef#code

My account sending ETH to crowdsale: https://ropsten.etherscan.io/address/0x85a363699c6864248a6ffca66e4a1a5ccf9f5567

Transaction hash: https://ropsten.etherscan.io/tx/0x7f99bca20b767073eb48ed2e6d01186c55bcc97ee8316523977e15c4286f6c5a

Here is a short video of me explaining what I'm doing: https://youtu.be/oKP9ea5PNho

Looking at the code: https://github.com/OpenZeppelin/zeppelin-solidity/blob/3c489127306d09dc08c6a22263134fb5413d2f80/contracts/crowdsale/Crowdsale.sol#L48

function Crowdsale(uint256 _rate, address _wallet, ERC20 _token) public

I instantiate coin and crowdsale in the following way:

contract MailHustleCrowdsale is Crowdsale {

  uint256 _rate = 1000;
  address _wallet = 0x315f80c7caacbe7fb1c14e65a634db89a33a9637;
  ERC20 _token = new MailHustleCoin();

  function MailHustleCrowdsale() Crowdsale(_rate, _wallet, _token) {
  }
}

My guess is that the error is somewhere here but cannot figure the working syntax...

Alternative approach:

How to reference coin contract already onchain?

  If including the original source code isn't practical, an easy way to work around it is just to make a stub contract above your own contract containing the function signature of the function you want to call.

For simplicity I've decided to include everything in a single file.


texts: How to save/reload the fake blockchain in Mix

texts: I'd like to save the state of the fake blockchain and to reload it on Mix startup. Any hints?


texts: Is there p2pool mining available for ethereum?

texts:
Are there any decentralized mining pools available for ethereum? Something like p2pool which fully decentralizes the mining process and reward distribution?

Is this possible?


texts:
I would like to create multiple transaction from the same address at the same time. Since every transaction needs nonce (tx count of the sender address) I can ask geth for the current count and create first tx, then increment nonce and create the next one and so on.
Problems as I see them are:

if one transaction does not get mined, none of the following will get mined (since nonce will be incorrect).
what happens if some tx gets included in one block and some in the other block, order might become wrong.
Is this reasoning correct?

If it is not, I'm wondering is there any better approach for this case.


texts: What's this problem with installing parity?

texts:
==> Checking out branch stable

  error: no such remote ref 403ff2e4759577d9e2b75b1389787a9c29670736
  Fetched in submodule path 'ethcore/res/ethereum/tests', but it did not contain 403ff2e4759577d9e2b75b1389787a9c29670736. Direct fetching of that commit failed.

  Error: Failed to download resource "parity"
  Failure while executing: git submodule -q update --init --recursive

  Error: No such keg: /usr/local/Cellar/parity

==> Parity is missing

==> Installation failed


texts: Error when verifying signed message on Etherscan

texts:
Why is it that my message on etherscan can not be verified correctly? I always get this message:

  I'm sorry! Signature message verification failed


texts: How do I send a Hello, world! message to an ETH address through DATA? That is would be visible on Etherscan

texts:
How do I send a "Hello, world!" message to an ETH address through DATA? That is would be visible on Etherscan
That's the whole question

Is that possible in any way?


texts: I am learning the inline assembly in solidity, i ve found the function mload(0x40) i am confused whith what this function does? did it reserve 4 Slot/word in memory or did it load the data stored in the address 0X40 or what?


texts: Mining ETH on HD 6950 DAG allocation problem

texts:
I have 2 HD6950's which I wanted to use for ETH mining - but I have the well known DAG allocation problem.

I can't find a solution for this problem - that's why I'm asking here. And please don't tell me to just buy new cards...

The card has 2 Gb of ram which should usually be enough. I tried to set GPU allocation to 95 and 100% but without success.

I use Windows 7 64 bit. If it is 1,4 GB and my card has 2 GB it should work easy?


texts: Truffle Test: Checking for Tx Failure: tx.receipt.status vs. throw/revert

texts:
Post Byzantium, when I am testing contract functions, some either (1) return a transaction object/receipt with a status field, while others (2) fail and revert.

Checking for 1) transaction object returned

assert(txReceipt.receipt.status === 0)

Checking for 2) error thrown

contract.someMethodThatWillFail(params)
  .then(
    () => assert.throw('should not have reached here'),
    e => assert.isAtLeast(e.message.indexOf('revert'), 0)
)

What determines if method will behave as (1) vs. (2)? (other than trial and error)

I've tried violating require()'s and modifiers on functions, and I don't see a pattern of whether or not that function will result in 1 vs 2.


texts:
What would be the optimal way to accept order payments from users who have Ether on an exchange? I can't figure out how to link the orderID with the transaction, without creating a new contract for each order, since they won't be able to add parameters/call functions.
Also will the exchange run into gas issues sending ether to a contract account?


texts: How mining happen in private and permissioned blockchain?

texts:
In public blockchain a miner gets rewarded for mining a block.

But in a private or permissioned blockchain, if there are no rewarding facilities available, how does the mining happen?

Also, is it require to have mining in private and permissioned blockchain?


texts: What is the difference between a pending transaction and a queued transaction in the geth mempool?

texts:
I see the following on the wiki but I dont understand the difference

pending: all processable transactions

queued: all non-processable transactions


texts: How to assign event output to variable when testing?

texts:
I'm using Truffle test(chai/mocha) and openzeppelin-test-helpers.
Can anyone help me about how to assign values from event to variables in the above testing environment?


texts: Account management in Ethereum or Quorum

texts:
We have two types of account in Ethereum one is EOA and other is a Contract account. While going through some code i found that u need to have a EOA account to create a new contract in ethereum.

var greeter = greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.code, gas: 300000}

So my question is we always need a EOA account to publish a smart contract in ethereum, if not the case how can it be done without a EOA.


texts: Getting a Parser error for one of my contracts

texts:
I'm getting the error:

"ParserError: Function, variable, struct or modifier declaration
expected. --> CurrentERC721.sol:1393:1: | 1393 | contract
ERC721Pausable is ERC721, Pausable { | ^^^^^^^^"

The code I have here:
contract ERC721Pausable is ERC721, Pausable {

   function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
      super._beforeTokenTransfer(from, to, tokenId);

      require(!paused(), "ERC721Pausable: token transfer while paused");
   }
}

I'm a bit confused because the formatting seems good, along with the semicolons. Could it be a placement of this contract issue?


texts: Reading out single elements from a struct of an other contract

texts:
here a shortcut from my both contracts. Is it possible to read out and change single elements(from contract B) of the struct (Contract A) ? e.g. from contract B like p.submission(_id).studentaddress ? Or is it still the case that a struct is an internal element. What could be a way to read out and change elemtens from contract A from an other contract ?
Contract A:
  uint public SubCount = 0;
struct Submission {
    uint id;
    address studentsaddress;
    Student student;
    Examiner examiner;
    Thesis thesis;
    // examniner accepts allocation
    bool accepted;
    // examiner finished correction
    bool corrected;
    // examiner marks submission as verified
    bool verified;
}

 // save submission in mapping with id as key
mapping(uint => Submission) public submissions;
   function createSubmission(address _studentsaddress,Student memory _student, Examiner memory _examiner, Thesis memory _thesis) public{
    SubCount ++;
    submissions[SubCount] = Submission(SubCount,_studentsaddress, _student, _examiner, _thesis, false, false, false);
    emit SubmissionCreated(SubCount, _studentsaddress, _student, _examiner, _thesis, false, false, false);

Contract B:
Submission p;
function setp(address _addr) external {
    p = Submission(_addr);
}

function readSubmission(uint _u) public returns(uint id, address studentsaddress, Student memory student, Examiner memory examiner, Thesis memory thesis, bool accepted, bool corrected, bool verified){
        return(p.submissions(_u));
           }


texts: Two machines' gasPrice values are different. Why?

texts:
I read many pages and decided to run two machines.
Machine A: full node, mine
Geth --mine --miner.threads 8 --syncmode full --http --http.port 8945 --http.addr 192.168.1.166 --miner.etherbase "0x...." --cache 8192 console  2>>\temp\mining.log

Machine B: archive mode
geth --syncmode full --gcmode archive --txlookuplimit=0 --cache.preimages --port 30304 --http --http.port 8845 --http.addr 192.168.1.138  2>>\temp\mining.log

While playing with eth in console on each machine, I found the gasPrice values were different.
Machine A: 27000000000
Machine B: 1000000000
From the log files, chain configuration is same as:

Initialised chain configuration          config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 2463000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Constantinople: 7280000 Petersburg: 7280000 Istanbul: 9069000, Muir Glacier: 9200000, Berlin: 12244000, YOLO v3: , Engine: ethash}"
Can you please explain why this happened?
Thank you.


texts:
How to obtain list of transactions/activity on metamask ?
I'm building an app that interact with metamask, I want to access all of the transactions that is written on metamask from the connected address, but I couldn't find how to do it on metamask documentation. Is it possible to do that ?


texts: Can someone explain in short how the peering system works?

texts:
Can someone explain in short how the peering system works:

How peers are initially found in a new installation?
How peers are added and removed?
If/how peers are subject to quality controls?


texts: Hi there I made a transaction offline then published transaction for a ico. My full deposit is still showing in my wallet. Should the wallet show less the transaction?, Or does it have to be on the block before showing less transaction ammount in my wallet?


texts: Has random number generation in blockchain been solved?

texts:
I've compared the 2 versions of the Ethereum wiki page about the hard problems of cryptoeconomics:

https://github.com/ethereum/wiki/wiki/HPOC_2015
https://github.com/ethereum/wiki/wiki/Problems

and found that the version from 2015 has a section titled Random Number Generation:

  The open-ended challenge is to come up with a mechanism inside of a cryptoeconomic context which provides random numbers as output with maximally relaxed security assumptions and maximal robustness and resilience to attackers - ideally, a mechanism with the same properties as proof of work but without (or with only a negligible fraction of) its cost.

It also mentions the "N-of-N commit-reveal, as exemplified in Tomlion's RANDAO protocol" and its limitations.

This section is missing in the latest revision of the document. Does it mean that random number generation has been solved?


texts: I am creating a dapp using web3-1.0. I have a contract that stores personal data for a particular user(account). I want to implement a functionality so that a user can share his data (stored in the smart contract) with another user for a particular time period. After that, the data should not be visible to the other user. Can we achieve this using solidity and web3-1.0 ? I am very new to this, please help me out !!


texts: ETH internal transaction means i received money and it became part of my wallet balance?

texts:
When someone send a money and it is shown within internal transactions like here, then does it mean this money was added to my wallet balance and available for withdrawal same as "normal" transactions money?
You can see that transaction having value of "0.08147364 Ether", but when you click the transaction for details, you can see "Value: 0 Ether ($0.00) "

I want to be sure this transaction topped up my wallet money balance and i will be able to spend this internal transaction money same as normal transaction money.


texts: Do I need to manually enable the upnp at the router when running my node?

texts:
I used the upnp lib for my app. It required manually enable the upnp at the router. My PC is inside the company's network. All connections are controlled by NATs.
So, I wonder whether GETH's nodes can connect the others by automatically enable the upnp way
Sorry for my bad grammar. Any answers will be appreciated!


texts: I'm trying to exchange NMR (Ethereum token) to ETH, but Uniswap & 1inch only suggest I sign a transaction for 0 ETH

texts:
I tried to exchange NMR (Ethereum token) to ETH, but both Uniswap and 1inch only suggest I sign a transaction for 0 ETH value. I signed this transaction, and here's the result:

What's this "Success"? Because they have taken the transaction fee, but no exchange took place. What is it for? What did I pay for?
Btw, my wallet app shows "Call Contract succeeded" instead of "Success". I haven't found anything useful on it. The best I've found is "call" is performed without a fee. But in my case, I had to pay. Apparently, there are several terms "call" in Ethereum.
Why does this happen? How can I exchange NMR to ETH?

UPD:
I've tried to swap on Uniswap 2 times, and both times, apparently, I've just paid for this approval. Both these 0 ETH transactions refer to the same Contract ID. I've connected with WalletConnect to etherscan.io and tried to perform approve on this Contract with _spender (address) to be official Uniswap address 0x7a250d5630b4cf539739df2c5dacb4c659f2488d. It fails with an error: estimateGas: execution reverted.
Do you have any ideas about what happened? How do I use this contract that I've paid for 2 times? How do I swap? Thanks


texts: Vote example from Solidity Docs doesn't work

texts: I can't deploy the voting example from docs and get error saying that 'No data is deployed on the contract address!'. I have no idea what goes wrong.


texts: Understanding the Address and its members

texts: I am new to ethereum blockchain and solidity. I am trying to understand "Address" and its member from the link . In the below example The "transfer" will transfer from which address to which address ?


texts:
I found this weird gist online for generating random numbers. Please remember that, despite the code's comments, generating random numbers on-chain is insecure for values more than 2.5 ETH.

// this labyrinth contract as a public utility can be used as an "entropy crawler",
// using the state itself as a source of entropy (generated entirely from human social coordination
// that is highly random. )

contract Labyrinth {

  uint entropy;

  function getRandomNumber() public returns (uint) {
    entropy ^= uint(blockhash(entropy % block.number));
    return entropy;
  }

}

What is the "^=" operator and what does it do? I tried searching in javascript, solidity, and other languages through Google but nothing is coming up.

Source: https://gist.github.com/resilience-me/8e877bc39a9f8d86f17f08bc62d71d70


texts: Where to check value returnd by function in wallet?

texts:
where do I check the value returned by a function in
Ethereum wallet (I'm using v. 0.8.3)?

I have set a test net and it works fine.
So, after I call a function of my deployed contract , I mine on it and the transaction is executed. I see fron an event that the value returned s correct.

ex.:

 function getMyvalue()  returns (uint256 valueInWeis)  {

    print(value); // event is printed correctly

    return value;

}

Here is a screenshot

Where can I see the value returned (without having to check the events) ?


texts: Function inside constructor is called from which address?

texts:
interface token {
       function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);}

contract CampaignFactory{    token public token_instance;
    constructor() public payable{
         token_instance = token(token_address);}

    function createCampaign() public payable{
        address newCampaign = address((new Campaign).value(msg.value)(deposit, ll, token_address, 1, your));
}

contract Campaign{
    token public tokenReward;

    constructor (uint depositInWei, address ll, address addressOfTokenUsed, uint weiCostOfEachToken, address your) public payable{
        tokenReward.transferFrom(0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, your, msg.value/price);
}

I've just provided the format of my code. I want to know from which address the function 'tokenReward.transferFrom()' of 'Campaign' constructor is called? You don't need to go in depth of the code that's why I've just provided the structure.


texts: Solidity's Keccak256 function requires mining?

texts: I have used keccak256 and passed 3 parameters. Does keccak256 require mining?


texts: Create contract for creating accounts in ethereum

texts:
I want create accounts in ethererum server using

curl command and geth.

just like this

curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["restart"],"id":74}' http://0.0.0.xxx:8545

can i create contract for creating the accounts throught api?


texts: which wallet is usable with ganache test-rpc?

texts:
I tried metamask, but unable to send ether between accounts because metamask is trying to estimate gas and gets stuck :(
myetherwallet doesn't save my seed so I need to enter it all the time


texts:
I am struggling to enforce privacy using Quorum's privateFor option.

I have provisioned a consortium in Azure blockchian service with 3 nodes. I deploy a smart contract from node2 privateFor node1 using the below code, but node3 can see the contract and execute functions as well(in remix for example). I can't figure out what i am doing wrong.

const Web3 = require('web3')
const rpcURL = "https://node2.blockchain.azure.com:3200/<AccessKey>"
const web3 = new Web3(rpcURL)
const EthereumTx = require('ethereumjs-tx').Transaction
const account = '<myAccountAddress>'
const privateKey = Buffer.from('<myPrivateKey>', 'hex')

const contractByteCode = '<contractbByteCode>'

const Common = require('ethereumjs-common').default

const customCommon = Common.forCustomChain(
    'mainnet',
    {
        name: 'my-network',
        chainId: <myChainId>, //from genesis
    },
    'constantinople',
);

web3.eth.getTransactionCount(account, (err, txCount) => {
    if (err!=null) {console.log('error executing web3.eth.getTransactionCount: ', err)}
    else{
        console.log('txCount: ',txCount)

        const txObject = {
            nonce: web3.utils.toHex(txCount),
            gasLimit: web3.utils.toHex(3000000),
            gasPrice: web3.utils.toHex(web3.utils.toWei('0', 'gWei')),
            data: contractByteCode,
            privateFor: ['<node1publickey>']
        }

        const tx = new EthereumTx(txObject,{common: customCommon})

        tx.sign(privateKey)

        const serializedTransaction = tx.serialize()
        const raw = '0x' + serializedTransaction.toString('hex')

        web3.eth.sendSignedTransaction(raw)
        .on('transactionHash',(hash) => {
            console.log('txHash:', hash)
        })
        .on('receipt',(receipt) => {
            console.log('receipt', receipt)
        })
        .on('error', console.error)
    }

})

The Azure Blockchain service overview page looks like below. I do not see any mention of transaction member or constellation or Tessera :


texts: what happends to my coins if the LP is empty?

texts:
This is a general question about a liquidity pools. I wasn't sure if this question should be addressed to this forum.

As I understand, each decentrlized exchange provide a LP to each coin. the LP coins are provided by multiple wallet addresses.
if I have a decentrilized wallet of eth (for example), and one of the exchnages's LP of eth is empty.
Why is this situation is dangurous to me? What do I care? Why can't I trade elsewhere? Why the emptiness of a LP will influence the value of eth/USD?
Is this question may have different answer for different coins?
I'm confused and I probably used some terminolegy which I'm not sure I fully understand.
Thanks in advance!


texts: Can a contract do something on the condition that there's enough gas?

texts:
Can a contract have a method that, does something, and if there is gas left over, performs an extra task?

Something like:

function doSomething() {
  performCheapTask();
  if(thereIsGasLeftOver) {
    performExtraTask();
  }
}


texts: Given just an Etheruem address, is there any way to tell if it's an ERC20 and/or an ERC721

texts: If I have only an Ethereum address and only a locally running node (using a third party such as EtherScan or Alethio is cheating), is there any way to tell if that address is an ERC20 or an ERC721 token? I thought of querying the 'name' and/or 'symbol' function, and that works (non-tokens never return a name or symbol), but it doesn't work perfectly. Some ERC20 or ERC721 tokens don't return a name or a symbol, but they are (albeit noncompliant) tokens. Thanks.


texts:
Is there a particular reason why Solidity prevents you from returning structs, lists and other data structures? I understand that it needs to be secure and allowing array/list access may mess with the data, but why not even structs? I'm trying to make a contract which return a list of accidents which have occurred to a particular license plate (which is one of the fields in a struct) from a blockchain of accident records, but I've only managed to get it to return one record, that too by it's individual fields. It just seems very inefficient to me..

Note that I first tried to return string[] but had to change it to bytes[] as Solidity doesn't allow that either.

/*
To get a list of incidents from a startID
*/
function listIncidents(uint _startID, uint _count) constant returns(uint[10] _incIDs, bytes[10] _names, bytes[10] _descriptions, bytes[10] _places, bytes[10] _times, bytes[10] _dates) {

  uint maxIters = _count;
  if((_startID + _count) > getIncidentCount()) {
  maxIters = getIncidentCount() - _startID;
  }

  _incIDs = new uint[](maxIters);
  _names = new bytes[](maxIters);
  _descriptions = new bytes[](maxIters);
  _places = new bytes[](maxIters);
  _times = new bytes[](maxIters);
  _dates = new bytes[](maxIters);

  for(uint i=0;i<maxIters;i++) {
    uint _incidentID = _startID + i;

    PoliceRecord memory r = incidents[_incidentID];
    _incIDs[i] = _incidentID;
    _names[i] = bytes(r.incName);
    _descriptions[i] = bytes(r.incDescription);
    _places[i] = bytes(r.incPlace);
    _times[i] = bytes(r.incTime);
    _dates[i] = bytes(r.incDate);
   }
}


texts:
should I put the prefix ethereum: before the address when creating a QR-Code ?

When I read a QR-Code generated by https://www.myetherwallet.com, the prefix is missing.

But I found conflicting informations like https://jibrelnetwork.github.io/ethereum-qr-code/demo-simple.html

If I can omit it, what is it purpose on bitcoin or litecoin addresses per example ?


texts:
I have read the EIP abount ERC165 that is enable us to detect which interface is implemented in a contract.

However, I found that some ERC721 tokens are a little bit diffrent from others, like cryptokitties and cryptohorse.

Are these different ERC721 tokens are both detected as erc721 token by wallet application.

And how does erc721 support wallet detect the type of tokens.


texts: How many people were involved in auditing the DAO code? And how many Eth code auditors are there we can goto?

texts:
How many were responsible for auditing the DAO code? It's understandable that bugs arise from any type of code, but having that the DAO was a big project and that once its created it shouldn't be changed type of deal. I'd imagine the auditing would be top notch an done by veteran Ethereum contract coders.

I'm curious to how many actually went over the code before all this drama. The DAO team paid 250k for a 3 page audit report, but I'd imagine that amount would  be able to hire some very top developers to do code auditing.

My point I want to find out is, how many top Ethereum smart contract devs are there as of 2016-06 that can audit code for other smart contract devs like me? I don't want to create a contract and later find out there was a bug in it that can steal all my funds.


texts: Remix IDE - transact to ___ errored: VM Exception while processing transaction: out of gas

texts:
pragma solidity ^0.4.18;

contract Testing {

  address public owner;

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

  function() public payable {
  }

  function withdrawAll() public  {
    uint256 balance = address(this).balance;
    owner.transfer(balance);
  }

}

47s video: https://youtu.be/HpDUE3_NGBw

  transact to Testing.withdrawAll errored: VM Exception while processing transaction: out of gas


texts: How to debug solidity contracts with truffle?

texts:
I've been having a very hard time with Solidity development due to not being able to easily console log as well as the truffle debugger causing problems.

How do you console log in Solidity?

Truffle debug doesn't seem to work very well when you've used inheritance.
When a function throws an exception the event logs don't help correct?
What is the easiest way to listen for event logs using a tool like Ganache or Truffle?


texts: Deploying Contract with Quorum Web3j response: Non-200 status code

texts:
SCENARIO:

I have the following code:

final String hostUrl = this.deployerProperties.getProperty("quorum.host.url");
final String hostPort = this.deployerProperties.getProperty("quorum.host.port");
final String host = hostUrl + ":" + hostPort;
final HttpService httpService = new HttpService(host);

this.admin = Admin.build(httpService);
this.quorum = Quorum.build(httpService);

final EthAccounts ethAccounts = this.quorum.ethAccounts().send();
final String ethFirstAccount = ethAccounts.getAccounts().get(0);
final PersonalUnlockAccount personalUnlockAccount = this.admin.personalUnlockAccount(ethFirstAccount, "").send();
if (!personalUnlockAccount.accountUnlocked()) {
        throw new IllegalStateException("Account " + ethFirstAccount + " can not be unlocked!");
}

final List<String> privateFor = new ArrayList<>();
final ClientTransactionManager clientTransactionManager = new ClientTransactionManager(this.quorum, ethFirstAccount, ethFirstAccount, privateFor);

final ContractGasProvider contractGasProvider = new DefaultGasProvider();
//final ContractGasProvider contractGasProvider = new DeployGasProvider();

final Tokens tokens = Tokens.deploy(this.quorum, clientTransactionManager, contractGasProvider).send();

When I execute the code. I get the following error:

  Caused by: java.lang.RuntimeException: Error processing transaction request: Non-200 status code: &{Status:400 Bad Request StatusCode:400 Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Content-Type:[text/plain] Content-Length:[96] Connection:[keep-alive]] Body:0xc423004080 ContentLength:96 TransferEncoding:[] Close:false Uncompressed:false Trailer:map[] Request:0xc4200ea500 TLS:}

The line that make the Token deploy breaks the execution. Googleing I found similar issue in this site: LINK So I decided to create my own GasProvider.

import org.web3j.tx.gas.StaticGasProvider;
import java.math.BigInteger;
import org.web3j.tx.ManagedTransaction;

@SuppressWarnings("deprecation")
public class DeployGasProvider extends StaticGasProvider{

public static final BigInteger GAS_LIMIT = BigInteger.valueOf(22_000_000_000L);

public static final BigInteger GAS_PRICE = ManagedTransaction.GAS_PRICE;

    public DeployGasProvider() {
        super(GAS_PRICE, GAS_LIMIT);
    }
}

But the error persists. The environment is the following:

Web3jQuorum v4.0.6
Quorum v2.2.21
Solcjs v0.4.24

I try fixing with this post answer. But still returning the same


texts:
How can I run multiple parity instances on one machine? With geth it's easy. I just have to set different --port numbers. What's the equivalent for parity?

I want to recreate Afris scenario.


texts: Is it possible for a smart contract to relay raw signed transaction

texts:
I am rethinking the flow for token transfer and confirmation on the network (ERC20,ERC721...).

I am unaware of a way presently to:

1- transfer tokens and
2- trigger a call in different contract,

all in one transaction, with the call to the different contract still originating from the msg.sender(owner of the tokens).
i am aware, that it can be achieved n two transactions.

While investigating, I thought about the possibility of smart contracts relaying raw signed transactions, the same way it could be sent to a rpc endpoint.

Flow (modifier style):

User signs transaction to send tokens to an address
User sends the transaction to the smart contract as bytes
contract relays the signed transaction, which should maintain the msg.sender of the owner of the tokens.
contract confirms the transaction was successful, then calls next function

This is based on the assumption, that you do not have control over token smart contract, so you can not design the function to support it. SO, basically should work for any token already deployed on the network.


texts: How can I log an event with indexed fields in Remix?

texts:
As you can see below, the indexed field is ignored, and the last field is set to zero:

contract MyContract {
    event MyWorkingEvent(
        address thing4,
        address thing5,
        address thing6);

    event MyBrokenEvent(
        address indexed thing1,
        address thing2,
        address thing3);

    function logAllTheThings(){
        MyWorkingEvent(0x12, 0x34, 0x56); // works :)
        //output => MyWorkingEvent["0x12","0x34","0x56","0x78"]

        MyBrokenEvent(0x12, 0x34, 0x56); // doesnt work :(
        //output  => MyBrokenEvent["0x34","0x56","0x78","0x0"]
    }
}

I'm testing all this from browser-solidity


texts: Degree verification process using blockchain

texts:
This question is specifically related to blockchain use case. I want to implement degree verification process using blockchain . I just need to know whether I am approaching my objective in a right direction or not or any advice to better this approach.
I am considering three main entities in this process.

Students
University
Central authentication party(For example in Pakistan there is Higher education commission which authenticate every degree from every university).

Below down is the workflow.

Student will login using his enrollment number or something else. He will be given his public-private keys.
Student will fill degree template on his portal with necessary information like GPA etc.
Student will sign this template using private key for authentication purposes.
Now university will assess this template and if everything is correct will add its digital signature using its private key.
Now template will go to third party which authenticate university digital signature and if university is recognized then it will add its signature . and push this certificate to blockchain (public repository) so that anyone can verify.

One of my main concern is this approach still leads me to centralized approach.

Any suggestions please regarding this.


texts: Unable to compile copy-pasted code from ethereum.org/crowdsale in OSX ethereum wallet

texts:
while copy-pasting the code from ethereum.org/crowdsale in mx OSX ethereum wallet (on test network Rinkeby), I get the following compiler error report:

 No visibility specified. Defaulting to "public".
    function transfer(address receiver, uint amount);

If I replace ; with Public{}`, the error moves to function Crowdsale( with compiler error report:

function Crowdsale(
    ^
Spanning multiple lines.

I believe this is the same issue asked in "similar Questions" facing issue in creating crowdsale... (on hold)

Thanx...


texts: Solidity: Is there any way to calculate the elapsed time for smart contract?

texts:
I wanted to calculate the execution time for smart contract as below.
I tried to get the elapsed time from simple code, but the result is zero.
Does the program length size increased to calculate the elapsed time?

pragma solidity ^0.5.0;

function {

    uint startTime = now;
    uint endTime = 0;
    unit elapsedTime = 0;

    ....

    endTime = now;
    elapsedTime = endTime - startTime;

}


texts: Storage trie - are trie nodes reused for two contract instances with the same storage content?

texts:
Reading geth code and various posts here, I think I have now a good understanding of how the data is stored in Ethereum (please correct me if I am wrong at some point).

At the lowest level we have a key-value database

At the next level we have a generic datastructure called trie

And at the Ethereum Blockchain level we have something like (only relevant parts named):

block -> state trie -> account* -> storage trie

[Q1]: For state trie the paths represent the account addresses. What are the paths in the storage trie? Storage indices?

[Q2]: If we have a simple contract of the form:

contract C {
    uint256 public x = 100;
}

When we instantiate two instances of this contract. Will they have the same storage root hash? If yes, will they share exactly the same key/value pair in the database (at the lowest level), respectively the same trie node in the storage trie?


texts: nodejs continues to watch an Event, even geth is killed on the background

texts:
I am running a script to watch my events as follows:

run.js:

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

address="0x..."
abi=[...]
var myContractInstance  = web3.eth.contract(abi).at(address);

blkNum = 1000;
var event = myContractInstance.LogJob({}, { fromBlock: blkNum, toBlock: 'latest' });
event.watch( function (error, result) {
    fs.appendFile( "/tmp/test.txt", JSON.stringify(result) + '\n', function(err) {
       process.exit();
    });
});

After running node run.js or nohup run.js &, we could find the output as follows:

cat /tmp/test.txt

Please note that when a new Event feed in running watch() terminates itself after reading the fed Events.

But when I do: sudo killall geth even geth is not working on the background, watch() continues to watch any event would come or not. It does not return any error or anything.

[Q] Is there any way to trigger watch() function to terminate itself when running geth or Parity on the background is killed? We could do cntl-c but I want watch() to kill itself automatically.


texts: "callback contain no result Error: Error: base fee exceeds gas limit" when call selfdestruct function (using Remix IDE)

texts:
I'm testing this simple contract. All the functions works well, but when I call the kill() function I'm getting this error:

  callback contain no result Error: Error: base fee exceeds gas limit

I'm using Metamask (and testrpc).

Thanks in advance.

EDIT

I tried also with  the greeter example , but I'm getting the same error.


texts: Can I recover an account with just the Private key (no json file)

texts:
I have read a few things lately That in order to securely store an account, one should save the json file and private key. I'm wondering If the json file is really needed though. Say I were to lose all traces to my account, and all I could find is the private key:

Could I access my Ether with just the private key?