texts: Who pays gas when a contract function that creates/calls another contract is called?

texts:
If I call a function of Contract1, that creates/calls another Contract2.
Who pays the gas used to call Contract2 ?

I think it's Contract1 - the second msg.sender. In that case, how can I make the original msg.senderpay?


texts:
I am planning to do a course project on block chain compression so that network transfer time is optimized. I read somewhere that the EVM bytecode component of the blockchain can be compressed. Is that the only low hanging fruit? Other suggestions are also welcome.

I read about Merkelized Abstract syntax Trees...I am wondering if Ethereum can benefit from those.

Just to add, I am also aware of state tree pruning. But I am looking for compressing blockchain so that network transfer time is saved (not necessarily the disk space, since it has to be decompressed on disk for space efficiency)


texts: How do I get all logs for all time for a given contract using web3?

texts: This answer worked when filter.get was not deprecated, but now I am not sure how to do the same thing with subscribe - web3.eth.subscribe hears new events and acts on them after I create the subscription, but I am not sure how to get old events.


texts: Why do I always get 'private key length is invalid' when launching testrpc from java with predefined accounts?

texts:
Im trying to deploy testrpc from java with two accounts starting with funds,  and I keep getting an error saying "private key length is invalid" from testrpc. Below is my code:

private static final String TESTNETRPC_CMD = "/usr/bin/testrpc";
private static final String TESTNETRPC_ARGS = "--account=\"0x%s, 10000000000000000000\"";

private static final String EXCHANGE_WALLET_PRIVATE_KEY = "9cfc2211b75dceb15d5ae9d2d7c8c5f5f480d40d1451ff296cd15fe9b7bec422";
private static final String USER_WALLET_PRIVATE_KEY     = "41a7ade556eb832ac96bc401f35ff678234643e4d3ecced00e875b66188b1bb4";

ProcessBuilder testnetRpcBuilder = new ProcessBuilder(TESTNETRPC_CMD, String.format(TESTNETRPC_ARGS, EXCHANGE_WALLET_PRIVATE_KEY),
            String.format(TESTNETRPC_ARGS, USER_WALLET_PRIVATE_KEY));
System.out.println(testnetRpcBuilder.command().toString());
testnetRpcBuilder.redirectErrorStream(true);
testnetRpc = testnetRpcBuilder.start();

Any thoughts?


texts: Why Oraclize / Provable can call URLs, although it's forbidden in Ethereum?

texts:
So the library Oraclize if I understand correctly, allows you on solidity to get a result from a URL inside a callback.

But I also read that you can't communicate with the external world in Ethereum (because it's non-deterministic), so I don't understand how Oraclize manages to call URLs although Oraclize is itself a smart-contract.


texts: Tether USDT signup not avaible and its erc20 no transaction

texts:
I checked usdt, the company tether tether.to disabled its signup function, and I cannot signup for API. and I also checked the ERC20 usdt token, it looks like almost one year no transaction.
Do you think tether API and USDT normal now?


texts: Is there a way for a function to perform some code to a point and then revert without conditions (more details below...)?

texts:
I want to create a payable function that acts similarly to onlyowner modifier, or:

function owner() public payable{
if(msg.sender != owner)
{
   balances[owner] += msg.value;
   revert();
}

}

What I want to accomplish:
1. when called by anyone except owner function will add funds to owner...
2. and after that it reverts, returning 'unsuccessful' or so.

what REALLY happens though:

function is immediately stopped and nothing gets added to owner or anywhere, this of course happens if anyone but the owner calls it

Motivation: looking for a way to create modifier that when gets called stops hacker but adds funds to owner if hacker is dumb enough to send a value with ether to a function called "admin_transfer" which will only contain the owner() function above ...hope this is morally OK from my perspective :). Unless a well intentional user calls 'admin_transfer' on accident which I think is very unusual unless someone looks deeply in the code and tries to exploit it.


texts:
it("should throw an exception if you try to buy an article that does not exist", function() {
    return ChainList.deployed().then(function(instance) {
        chainListInstance = instance;
        return chainListInstance.sellArticle(articleName, articleDescription, web3.toWei(articlePrice, "ether"), {
          from: seller
        });
      }).then(function(receipt) {
        return chainListInstance.buyArticle(2, {
          from: buyer,
          value: web3.toWei(articlePrice, "ether")
        });
      }).then(assert.fail)
      .catch(function(error) {
        assert(error.message.indexOf('invalid opcode') >= 0, "error message must contain invalid opcode");
      }).then(function() {
        return chainListInstance.articles(articleId);
      }).then(function(data) {
        assert.equal(data[0].toNumber(), articleId, "article id must be " + articleId);
        assert.equal(data[1], seller, "seller must be " + seller);
        assert.equal(data[2], 0x0, "buyer must be empty");
        assert.equal(data[3], articleName, "article name must be " + articleName);
        assert.equal(data[4], articleDescription, "article description must be " + articleDescription);
        assert.equal(data[5].toNumber(), web3.toWei(articlePrice, "ether"), "article price must be " + web3.toWei(articlePrice, "ether"));
      });
  });

1) These is the one of the test file i have seen for my code for SellArticle function i have worked

2) According to my knowledge promise chain excutes by the output given by the first promise to the next

3) And it wait for the promise to complete until then  it stays at that point

4) .then(assert.fail)  how can it move to the next step if there is no error   and can promise chain skip

plese correct me if i am wrong


texts: Why does OpenZeppelin implement increaseAllowance and decreaseAllowance functions differently in their ERC20 contract?

texts:
This is copied from their ERC20 contract from github (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol):
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
    _approve(_msgSender(), spender, _allowances[_msgSender()] + addedValue);
    return true;
}

function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
    uint256 currentAllowance = _allowances[_msgSender()][spender];
    require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
    unchecked {
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);
    }
return true;
}

Why would they not be implemented the same way?


texts:
I believe it's possible to create a two-dimensional array according to this answer.

I am trying to create a two-dimensional array to store the address and ether of each incoming transaction.

Are two-dimensional arrays the best solution in this case?
Do we have to set a length limit or can we make it infinitely long? How can we prevent malicious users from flooding the array?


texts: Using Ethereum public and private keys to encrypt and decrypt message (metamask client)

texts: I am trying to use Ethereum private and public keys for message encryption like PGP and I found out this npm module on github, https://github.com/pubkey/eth-crypto#encryptwithpublickey, which it lets you get public key from private key, encrypt message with public key, and decrypt message with private key. I am using MetaMask as the web3 interface for my dapp and I am trying make the message encryption works seamlessly. However, I cannot find a way to automatically pass in MetaMask default account's private key to the npm modules rather than manually clicking export private key from MetaMask's extension UI.


texts: Is the value of the privateFor param accesible in the contract?

texts:
Transaction params for quorum can contain a privateFor param
{
    "jsonrpc":"2.0",
    "method":"eth_sendTransaction",
    "params":[
        {
            "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
            "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
            "gas": "0x76c0", // 30400
            "gasPrice": "0x9184e72a000", // 10000000000000
            "value": "0x9184e72a", // 2441406250
            "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
            "privateFor": ["$PUBKEY1, $PUBKEY2"]
        }
    ],
    "id":1
}

How can the privateFor param be accessed from the solidity contract code ?


texts: Where can I find a string to bytes32 converter online?

texts:
So far I am using this solidity code

pragma solidity 0.4.24;

contract Converter{
    function Converter(){

    }

    function stringToBytes32(string memory source) returns (bytes32 result) {
        bytes memory tempEmptyStringTest = bytes(source);
        if (tempEmptyStringTest.length == 0) {
            return 0x0;
        }

        assembly {
            result := mload(add(source, 32))
        }
    }
}

Is there a website or online tool to easily convert strings to bytes32?


texts: When I open Ethereum, I get an 'Ethereum node connection error. I'm using 0-8-10. Any ideas?


texts: Triggering contract fallback function by sending ether from another contract

texts:
contract A {

uint public u;
event abc(address);

constructor() payable{
    u=100;
}

function () payable{
    emit abc(msg.sender);
    u = 25;
}

function setu(uint i) {
    u = i;
}

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

}

contract B {

uint public a;
A ac;

function(){
    a= 20;
}
constructor() payable {
    a=10;
}

function send(A b){
    b.call.gas(210000).value(100 wei)();
}

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

}

I have updated the code.
Now, I am passing gas along with the call to avoid gas estimation failure.

I am trying to trigger contract A's fallback function by sending some ether by calling send function from contract Attacker.

This works fine in Remix using javascript VM but getting failed in Rinkeby.


texts: Should i move my erc20 token to main network?

texts:
i recently created a token in ropsten test network and was successful. Now i am going to create a real time token in one of my private network.

My question is, can i go ahead creating the same in private network itself or should i create only in main network?

Because in future i want to issue the tokens as loyalty points to my users which they can exchange for real ethers and monetize. Can i achieve this in private network itself? I am not sure of the differences


texts: Is there a good erc20 source using web3js?

texts:
I'm looking for some source codes using web3js for interaction with erc20 tokens and contracts.
Does anyone know good source codes using web3js?

Thanks in advance!


texts: Why can't I catch solidity errors testing with truffle?

texts:
I'm testing the ERC20 standard. I try to send a transaction from an account with balance=0, which should throw an error. I'm trying to catch it.

In my test function, I'm using the following:

contract('erc20 deployed', function(accounts) {
    it("should not transfer 1 token from address[0] to address[1]", function(done) {
        try{
            return erc20Instance.transfer(accounts[1], 1);
            should.fail("No error was thrown trying to cheat balance");
        }
        catch(error){
            done();
        }
    });
});

When I execute it with truffle test I get the following error:

  1) Contract: erc20 deployed
       should not transfer 1 token from address[0] to address[1]:
     Uncaught Error: VM Exception while processing transaction: revert

How can I catch it?
My goal is to test the the transfer function, testing that address[0] can not effectively make the transaction.


texts:
I need to listen ethereum transactions for current count of addresses using web3j. I know that I can use subscribe to get transactions, but how can I add some filter to listen a certain number of accounts?

Subscription subscription = web3j.transactionFlowable().subscribe(tx -> {// some code});


texts:
I am new to ethereum smart contracts, I was going through minted crowdsale code for learning but couldn't figured out its use case or what is its purpose, precisely what does it mean?

Any answer will be appreciated. Thanks !


texts:
I have a few questions to ask about setting up a mining pool

1) Will there be an issue if I set up two geth instances with the same coin base?
Here it is not about private nodes, I am trying to do a fail over for geth, have at least two nodes running at the same time. I want to give them the same coin base, so I am a bit worried it will have some issue. like conflicts.

2)Do I need to connect as peers for the two geth instances?
Do I need to manually connect these two instances as peers?

3)Is it same if I keep mining with 2 geth instances or just one?
If I have two regional services, e.g. one at US, and one at Russia. Is it same if I have own regional geth instances to mine separately, or I have to point one regional pool to another region geth instance to force them mining on the same geth instance.


texts: Best way to avoid transactions that create a new smart contract before submitting it

texts:
We are creating a permissioned network (using Besu) where anyone can create and submit transactions.  In this context, the writer nodes need to verify that these transactions are not creating new smart contracts.

To solve this problem, I think I can create a web server that receives transactions from anyone. This web server will check the "to" field (0x0) and submit it to the blockchain network or not. Is it the better way to deal with it?


texts: How can I use "eth_sendTransaction" to invoke a contract and get logs?

texts:
I have deployed：
contract test {
      function multiply(uint a) returns(uint d) {
               return a * 7;
      }
}

I can call the contract with "eth_call" :
mpsp@ubuntu-slave2:~$ curl http://10.10.67.217:8545 --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"to": "0x8e6f99f04148b1fb918cde7e44a94375f94dc745","data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000007"},"latest"],"id":1}'

the output is:
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000031"}

But when I used "eth_sendTransaction" to invoke the contract and after mining, I used "eth_getTransactionReceipt" to get the result, and contract seemed not to be invoked.  Here are my steps:
eth_sendTransaction
run:       mpsp@ubuntu-slave2:~$ curl http://10.10.67.217:8545 --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0xc60ec7c68d47814288bdfdaa71b88ff922d735a7","to":"0x8e6f99f04148b1fb918cde7e44a94375f94dc745","gas":"0xC350","gasPrice":"0x1388","data":"0xc6888fa10000000000000000000000000000000000000000000000000000000000000003"}],"id":1}'
outputs:   {"jsonrpc":"2.0","id":1,"result":"0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd"}

eth_getTransactionReceipt
run:        curl http://10.10.67.217:8545 --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd"],"id":1}'
outputs:    {"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x26e23d45caf0c57159e88d9835c573a79f59a4fad0e7a7d70ea7a49780d14448","blockNumber":"0xc3a1","contractAddress":null,"cumulativeGasUsed":"0x5449","from":"0xc60ec7c68d47814288bdfdaa71b88ff922d735a7","gasUsed":"0x5449","logs":[],"root":"c42b14419677df59e3f593fccf03ea28f65bbd8927dcc9239dad6e77eb85f1a3","to":"0x8e6f99f04148b1fb918cde7e44a94375f94dc745","transactionHash":"0xcff6d91d1693abe876c25ba03a58bc6ca693078b3a90e836f656e0dddb08a4cd","transactionIndex":"0x0"}}

logs was empty in eth_getTransactionReceipt outputs.

Do you have some suggestions ?

Thank you!


texts: How to make web3Modal dapp compatible to coinbase browser?

texts:
I have made my dapp compatible with web3Modal.  The dapp is using simple Html/css/js. It is working fine with metamask desktop, metamask mobile and wallet connect but when I try to browse it from coinbase wallet in built browser it doesn't work.
Here is web3Modal example that I followed: https://github.com/Web3Modal/web3modal-vanilla-js-example
Here is my web3Modal settings (js):
function init() {

    console.log("Initializing example");
    console.log("WalletConnectProvider is", WalletConnectProvider);
    console.log("window.web3 is", window.web3, "window.ethereum is", window.ethereum);

    // Tell Web3modal what providers we have available.
    // Built-in web browser provider (only one can exist as a time)
    // like MetaMask, Brave or Opera is added automatically by Web3modal
    const providerOptions = {
        walletconnect: {
            package: WalletConnectProvider,
            options: {
                // Mikko's test key - don't copy as your mileage may vary
                infuraId: "8043bb2cf99347b1bfadfb233c5325c0",
            }
        }
    };

    web3Modal = new Web3Modal({
        cacheProvider: false, // optional
        providerOptions, // required
        disableInjectedProvider: false, // optional. For MetaMask / Brave / Opera.
    });

    console.log("Web3Modal instance is", web3Modal);
}

/**
 * Kick in the UI action after Web3modal dialog has chosen a provider
 */
async function fetchAccountData() {

    // Get a Web3 instance for the wallet
    web3 = new Web3(provider);

    console.log("Web3 instance is", web3);
    metaMask = true;

    // Get list of accounts of the connected wallet
    accounts = await web3.eth.getAccounts();

    getNetwork();
    stats();
    // METAMASK
    if (!metaMask) {
        $('#connectionModal').modal('show');
        $('#networkStatus').html('Install Metamask');
    } else {
        // success case
        $('#connectWalletModal').modal('hide');
        $('#content').slideDown();
        $('#connectWallet').removeClass('d-inline-block').addClass('d-none');
        $('#afterConnect').removeClass('d-none').addClass('d-inline-block');
        updatePageVals();
        $('#viewEtherscan').attr('href', 'https://etherscan.io/address/' + accounts[0]);
    }

    setInterval(function() {
        stats();
    }, 20000);
}

/**
 * Fetch account data for UI when
 * - User switches accounts in wallet
 * - User switches networks in wallet
 * - User connects wallet initially
 */
async function refreshAccountData() {

    await fetchAccountData(provider);
}

/**
 * Connect wallet button pressed.
 */
async function onConnect() {
    console.log("Opening a dialog", web3Modal);
    try {
        provider = await web3Modal.connect();
    } catch (e) {
        console.log("Could not get a wallet connection", e);
        return;
    }

    // Subscribe to accounts change
    provider.on("accountsChanged", (accounts) => {
        fetchAccountData();
    });

    // Subscribe to chainId change
    provider.on("chainChanged", (chainId) => {
        fetchAccountData();
    });

    // Subscribe to networkId change
    provider.on("networkChanged", (networkId) => {
        fetchAccountData();
    });

    await refreshAccountData();
}

Here are some of the bundles Im loading in html:
<script type="text/javascript" src="https://unpkg.com/web3modal@1.9.0/dist/index.js"></script>
<script type="text/javascript" src="https://unpkg.com/evm-chains/lib/index.js"></script>
<script type="text/javascript" src="https://unpkg.com/@walletconnect/web3-provider@1.2.1/dist/umd/index.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/fortmatic@2.0.6/dist/fortmatic.js"></script>

Can anyone help that what needs to be changed/added to make it compatible with web3 injected by coinbase wallet's browser?


texts: Difference between full node,light node and miner

texts: I am in confusion of the terms full node, light node ,miner and non-mining/non-miner. Please help me differentiate


texts: How to create a wallet file for existing account&

texts:
I found this way of creating a new ethereum account with web3j. But what if I want to create a wallet file for an already registered account? I need this because most of the web3j functions require a wallet file.

Generate a key-pair Keys.createEcKeyPair()
Create the wallet Wallet.createStandard(seed, keyPair)


texts:
I want to create an ERC721 smart-contract.
The token will be associated to a png file.
The users will see there tokens in metamask and i want to display there png files in metamask (this is very important).
Here is what i've tried:
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract MyToken is ERC721
{
   using Counters for Counters.Counter;
   Counters.Counter private _tokenIds;

   constructor() public ERC721("My Token", "MY2")
   {
      awardItem(msg.sender,'https://mywebsite/metadata1.json');
   }

   function awardItem(address recipient, string memory metadata) public returns (uint256)
   {
       _tokenIds.increment();
       uint256 newItemId = _tokenIds.current();
       _mint(recipient, newItemId);
       _setTokenURI(newItemId, metadata);
       return newItemId;
   }
}

Here is the content of metadata1.json :
{
  "name": "My Token1",
  "hash": "https://mywebsite/myimage1.png"
}

Everything works fine. I can see the png file of the first token in the owner wallet after smartcontract's deployment.

I had to configure my collectible in metamask app: I had to set contract's address but also token id. Metamask can not scan all tokens i own in this contract ?
Is there a way to put metadata on chain (in a storage variable) instead of an external json file ?
I have tried to put png file on ipfs. I have tried pinata and i have tried to put an url like: ipfs//<image_hash>. It does not work. The picture is not displayed in metamask in this case. Any idea ?

Thanks a lot


texts: Are transactions with zero data included within a block guaranteed to be successful?

texts:
I know there are transaction receipts to verify that a transaction included in a block was executed successfully and funds were actually transferred.

But can receipt verification be skipped if I'm dealing with a transaction that has no data in its body (i.e. a non-smart contract transaction)? Isn't the fact that the transaction was included within a block already a sufficient condition for successfulness in this specific case?


texts: Example of embedding arbitrary data / text into a contract to be sent to another account?

texts: Since users can create smart contracts, can't someone just embed plain text into the smart contract and then have that sent to another user in effect making it a messaging system? and how much would each message cost per byte?


texts: Ok, I am pretty new to developing contracts, and I did so by using dAPP and truffle. But when adding it to the chain, it says there is no balance to the contract. How can I add tokens to be bought? https://etherscan.io/address/0x8f8a3c51b1eaaefe9052fc86cff57971b11dde45


texts: Cannot read property length of undefined in Remix / tried to increase gas not working

texts:
My contract was working just fine, but I don't know what happened, now when I try to interact with a new instance of my contract from Remix I get this error 'cannot read property "length" of undefined'. So I've checked everywhere on the forum, and people say it's about gas in deployment, I tried to increase, not working, I tried to reduce the code line in my smart contract, not working. Here is my deployment code:

const Web3 = require('web3');
const HDWalletProvider = require('truffle-hdwallet-provider');
const compiledStoreFactory = require('./Contracts/build/StoreFactory.json');
const fs = require('fs');

const provider = new HDWalletProvider(
  'captain kitten phrase unique return pilot camp fly list wreck rate ill',
  'https://ropsten.infura.io/v3/d4d36e8586154352beaabcb9df651ec1'
);

const web3 = new Web3(provider);

const deploy = async() => {
  const accounts =  await web3.eth.getAccounts();

  console.log('Attempting to deploy from account ', accounts[0])

  const result = await new web3.eth.Contract(JSON.parse(compiledStoreFactory.interface))
    .deploy({data:'0x'+compiledStoreFactory.bytecode})
    .send({from:accounts[0], gas:'6000000'})

    fs.writeFile('address.txt', result.options.address, function(err) {
        if(err) {
            return console.log('pute');
        }
    console.log(result.options.address)
})};

deploy();

Note that if I copy/paste the code in Remix, and deploy the contract from there its working just fine.

Here is the solidity code :

pragma solidity ^0.4.24;

import './Crud.sol';

contract Store{
  address private owner;
  mapping(string=>Product) productDetails;
  mapping(string=>Order) orderDetail;
  struct Product{
      string description;
      uint price;
  }
  struct Order{
      string deliveryAddress;
      uint phone;
  }

  constructor(address creator) public {
    owner = creator;
  }

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

   using HitchensUnorderedKeySetLib for HitchensUnorderedKeySetLib.Set;
    HitchensUnorderedKeySetLib.Set products;
    HitchensUnorderedKeySetLib.Set orders;

    event StoreUpdate(address sender, string action, bytes32 key);
    event OrderUpdate(address sender, string action, bytes32 key);

    function addProductToStore(bytes32 product) public restricted {
        products.insert(product);
        emit StoreUpdate(msg.sender, "insert", product);
    }

    function addOrders(bytes32 order) public {
        orders.insert(order);
        emit OrderUpdate(msg.sender, "insert", order);
    }

    function removeProductToTheStore(bytes32 product) public restricted {
        products.remove(product);
        emit StoreUpdate(msg.sender, "remove", product);
    }

      function removeOrder(bytes32 order) public restricted {
        orders.remove(order);
        emit OrderUpdate(msg.sender, "remove", order);
    }

    function countProducts() public view returns(uint) {
         return products.count();
    }

    function countOrders() public restricted view returns(uint) {
         return orders.count();
    }

    function getProducts(uint index) public view returns(bytes32 ) {
        return products.keyList[index];
    }

    function getOrders (uint index) public view returns(bytes32 ) {
    return orders.keyList[index];
    }

}

contract StoreFactory {
  address[] private deployedStores;

  function createStore() public {
    deployedStores.push(new Store(msg.sender));
  }

  function getDeployedStores() public view returns (address[]){
    return deployedStores;
  }
}

Here is the address of the deployed contract : 0xA6552d9A49091Aa8D89518b93b6A7B81a93de847


texts: How to identify why my transaction goes to pool, and how to process them?

texts:
I'm working with POA blockchain with three nodes. When I send transaction using geth console, sometimes my transaction goes to txpool and never clear from there.
Is there any way using that we can see the reason why the transaction is stuck in txpool?
How I send a transaction
eth.sendTransaction({from:eth.coinbase, to:"0x0ddb39f11611057fec9670a9ba73315e0a634c28", value: web3.toWei(1, "ether")})

txpool Inspect
> txpool.inspect
{
  pending: {
    0x79b69CD3c0b551c6082482B7Ec9CBB1D0aC5834f: {
      254: "0x0dDb39f11611057fEc9670A9ba73315E0A634c28: 1000000000000000000 wei + 90000 gas × 100000000000 wei"
    }
  },
  queued: {}
}

I thought it might be because of my other nodes are not running, hence I have run others nodes and did miner.start(), however this transaction doesn't get clear.


texts: How can I execute code locally at given address?

texts:
What's the simplest way of executing piece of code at specific address of the main blockchain locally using the command-line interface?

In here it's demonstrated how to play mp3 file based on the input data using geth command, but how can you execute the actual code with its logic on your local machine for own testing purposes?


texts: Ethereum wallet/Geth incredibly slow to sync, help?

texts:
So I've noticed some people having the issue similar to mine, entitling their post as "very VERY slow to sync" and other variations of that, however they're complaining at around 100 blocks every minute.

I have the issue where Geth is telling me that it's getting 1 block every 1 to 6 minutes.

I only have 48,806 blocks left to go (I had it fully synced a few months ago), and they don't exactly seem to be "problem" blocks like back in the 200,000 range.

I did have the issue last year of where it stopped syncing for some reason, so I've tried all the fixes that may help with that such as deleting all my chain data and trying a different hard drive, nothing making any real difference...

I'm on;
Windows 10
Geth 1.7.3
Ethereum Wallet 0.9.3

Any help with this matter would be much appreciated.


texts: I'm here to run the official Go-Ethereum repo. How can i do that?

texts: I want to run  go-ethereum in my own PC. Is there any instruction about this? How they deployed it?


texts: Why does my parity sync get stuck all the time?

texts:
I have a server set up with a node to read from the blockchain, so I don't have to run my node on my computer all the time. Sometimes the node gets stuck and I reset the blockchain with

./parity/target/release/parity -light db kill

now It gets stuck all the time and I have to delete the blockchain over and over again because the node gets stuck at block 2.4M-2.6M and stops syncing.

web3.eth.syncing
{
    currentBlock: 2681433,
    highestBlock: 4801999,
    startingBlock: 0,
    warpChunksAmount: null,
    warpChunksProcessed: null
}

what can I do to resync the blockchain (with warp this should not take longer than a few hours...)


texts:
I'm calculating the gas costs of the following contract: 0x6001600190016007026005016002900460049060016021900560150160030260059007600303600960110a60005260086000f3.

Disassembled versions:

contract Contract {
    function main() {
        var var0 = 0x04;
        var var1 = (0x05 + 0x07 * (0x01 + 0x01)) / 0x02;
        var var2 = 0x03 - (0x03 * 0x15) i% 0x05;
        memory[0x00:0x20] = 0x11 ** 0x09;
        return memory[0x00:0x08];
    }
}

label_0000:
    // Inputs[1] { @0032  memory[0x00:0x08] }
    0000    60  PUSH1 0x01
    0002    60  PUSH1 0x01
    0004    90  SWAP1
    0005    01  ADD
    0006    60  PUSH1 0x07
    0008    02  MUL
    0009    60  PUSH1 0x05
    000B    01  ADD
    000C    60  PUSH1 0x02
    000E    90  SWAP1
    000F    04  DIV
    0010    60  PUSH1 0x04
    0012    90  SWAP1
    0013    60  PUSH1 0x01
    0015    60  PUSH1 0x21
    0017    90  SWAP1
    0018    05  SDIV
    0019    60  PUSH1 0x15
    001B    01  ADD
    001C    60  PUSH1 0x03
    001E    02  MUL
    001F    60  PUSH1 0x05
    0021    90  SWAP1
    0022    07  SMOD
    0023    60  PUSH1 0x03
    0025    03  SUB
    0026    60  PUSH1 0x09
    0028    60  PUSH1 0x11
    002A    0A  EXP
    002B    60  PUSH1 0x00
    002D    52  MSTORE
    002E    60  PUSH1 0x08
    0030    60  PUSH1 0x00
    0032    F3  *RETURN

My estimation was (based on the recent fee schedule: https://docs.google.com/spreadsheets/d/1n6mRqkBz3iWcOlRem_mO09GtSKEKrAsfO7Frgx18pNU/edit#gid=0)

3 x ADD + 2 x MUL + SUB + DIV + SDIV + SMOD + EXP + MSTORE + 17 x PUSH + 5 x SWAP =
3 x 3   + 2 x 5   + 3   + 5   + 5    + 5    + 60  + 6      + 17 x 3    + 5 x 3    =
169

Unfortunately, the corresponding VM test in the official go-ethereum repository (https://github.com/ethereum/tests/blob/ad2184adca367c0b68c65b44519dba16e1d0b9e2/VMTests/vmArithmeticTest/arith1.json) estimates this as 129.

Where have I over-counted 40 gas in this execution?

(please note transaction and call costs are not applicable for VM tests)


texts: How does gas price / deployment cost scale with network size?

texts:
Holding ether/usd price constant, how does the amount of gas for a transaction scale as more ethereum nodes are added? Does it become more expensive to execute the same transaction, since there are many more miners trying to do the same thing -- or is it constant, since only one can include it?

If it's the former, isn't that an extremely large barrier to entry? If I make a gambling dapp that only my community of 100 people would ever care about, would using it cost something on the scale of n=world_population (variable) rather than n=100 (fixed)?


texts: is it possible to send eth(Multiple eth values) to multiples addresses with single Transaction?

texts:
I just want to distribute a "eth" values to multiple public addresses. Is it possible with current version of "web3.js"? So that metamask will ask only a single time to approve a transaction.

Edit:-

initContract: function() {
    $.getJSON('PayContract.json', function(data) {
    var payContract = data;
    App.contracts.PayContract = TruffleContract(payContract);
    App.contracts.PayContract.setProvider(App.web3Provider);
      });
  },

refundButtonOnClick : function (event) {
            console.log('refund button pressed');
            var mmPayToClients;
            var payees = [0x****BEf57,0x***a8BEf57,0x**7];
            var values = [0.5,1.0,0.5];
        App.contracts.PayContract.deployed().then(function(instance)
            {
                mmPayToClients = instance;
                return mmPayToClients.pay(payees,values);
            }).then(function(result) {
                console.log(result.message);

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


texts: Storing and retrieving data from a transaction

texts:
I have a private blockchain using PoA and would like to store data in the data field of a transaction. To my understanding, the data field has a 32-byte limit and needs to be hex encoded. Is this assumption correct?

If so, what functions could I use from ethersjs to hash a file of arbitrary size into a 32-byte hex string? Thanks.


texts: By default, the Geth client appears to listen to both IPv6 and IPv4. There doesn't appears to be a command line option to disable one of them. Is there a way to do it?


texts:
I want to store data on chain that is not needed within a smart contract but should be retrieved easily and particularly quickly from outside. I know that storing the data within an indexed event is much cheaper than within a mapping inside a contract in terms of cost and storage but does the access also stay fast if the chain and data is growing and there are millions of events I have to filter that one out I want to read?

We are talking about a geth based private poa network.


texts: Erc20 token minting based on api variable

texts: Can I have a erc20 coin contract that watches an API and mints coins and distributes them evenly to the network based on a changing variable in said API?


texts: As a CS student, where should I start to learn Ethereum development?

texts:
I'm a cs student looking to learn ethereum development. I'm very confused about all the things I need to learn.
Smart contracts are programmed in solidity but if I want to build any kind of app I will need a frontend right?
So learning solidity alone is completely useless ?
Do I have to start with a full web dev course? And learn HTML, CSS, js ?
What would be the fastest way to learn eth dev and be able to make a portfolio to someday get a job?
I already have coding knowledge mainly in c++  and also know some computer science
But never did web dev
Can anyone help me with a roadmap?
I alredy know some Algorithms/Data Structures and coding in c++ from college


texts:
Hey guys, this is a piece of code from Solidity documentation.

These two interfaces Config and NameReg have never been implemented, how could contract named called it? Do I miss something here?

Thx!


texts: Why does proof of non-inclusion is useful in Ethereum?

texts: Currently Ethereum uses modified Merkle patricia trie and maybe plan to move to a sparse Merkle tree (SMT), which both support `proof of non-inclusion', i.e. allowing one to proof that some key does not stored in the data structure. Simple Merkle trees lack that feature. My question is why is this feature needed in Ethereum?


texts: Truffle test of two transactions during the same block

texts:
I'm trying to test a solidity function that only allows it to be called once per block. E.g. (my desired functionality):

Tx1 calls Fn during block #100, and when successful sets a boolean flag for block #100 to true, then:
Tx2 calls Fn during block #100, but gets reverted because the flag was true.

My problem is, as I can see from the logs, the transactions are mined in subsequent blocks.

Code example:

  contract.fn({ from: player1 }) // mined in block 100
  await contract.fn({ from: player2 }) // mined in block 101

Using ganache-cli with --blockTime=10 and ganache UI w/o automine this still happens.

How do I get the transactions out one after the other, but to be mined in the same block?


texts: Sign without “\x19Ethereum Signed Message” prefix

texts: I understood that web3.eth.sign(...) will add “\x19Ethereum Signed Message” prefix to a message and hash with keccak256. Is there anyway to remove the prefix before signing? Or any library I can use to do a simple signing without prefix?


texts: Is gas ultimately *only* sent to miners while the computation defined in a smart contract is performed by each node of the network?

texts:
To my understanding, the execution of the code inside a smart contract is done by all nodes in the network. However the miners are the only ones who receive the paid gas. Also, when setting up the mining client, the miner (person) can specify the gas price (or cost?) range to accept the job of executing a smart contract.

I am confused. If the smart contract is to be executed on every node of the network, why some miners can refuse to accept the job, and why is it fair that only the miners are rewarded, given that everyone is involved in the computation?


texts: In simple ether transfer type transaction, does the balance of the sending address gets debited instantly?

texts: As per What’s the role of the EVM in a plain ether transfer between Externally Owned Accounts?, one would expect that the sending account will get debited right after the transfer call. Yet, that does not happen. Am I missing something obvious?


texts: Cant find sushiswap router address for Kovan testnet

texts: Can anyone get me a routerV2 address for sushiswap on Kovan? The address given on sushi page is incorrect.Thanks


texts: How to filter MyEvent({ },{ }) to retrieve only the latest transaction in the array?

texts:
My code:

 instance.MyEvent({}, {fromBlock: 0, toBlock: 'latest'}).watch(function(error, event) {
 if (!error) {
   console.log(event);
$('#events').html(event.transactionHash);

 } else {
   console.error(error);
 }
}).get(function(error, events) {
 if (!error) {
    console.log(events);
  } else {
    console.error(error);
  }
})

With that, I can retrieve all events with get() in a array, and watch() all of them as well:

The Array (app.js:219) represents get() and each event (app.js:180) has been watched all over again, so there is 269 of them. Once the latest event is the latest watched (obviously), it is retrieved with #events successfully.

But, with so much events, it gets messy. I was wondering if i could filter with some parameter to reduce the number of events returned.

I appreciate the attention!


texts: Ethereum Wallet, No TX Confirms, How to adjust gas price

texts: I run a full node on the ethereum wallet 9.3, have attempted to tx's in the past 3 days with no confirmations and Gas limit used 151,458, but how can I adjust the gas price manually, currently at 14.


texts: How to obtain the msg.sender in truffle console?

texts:
Here is my code snippet to return the msg.sender:

function showSender() public view returns (address)
{
    return (msg.sender);
}

But when I try to call this function using this:

Coin.deployed().then(function(instance) { return instance.showSender.call();});

Then there is an error showing:

Error: Invalid number of parameters for "showSender". Got 0 expected 2!
at Promise (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/lib/execute.js:128:1)
at Object._createTxObject (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/src/index.js:699:1)
at Object.InvalidNumberOfParams (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3-eth-contract/~/web3-core-helpers/src/errors.js:32:1)

The function showSender does not have any parameter, then why is the error showing up. Someone please give a solution.


texts: Can't manage to send transactions on following block

texts:
I have a web socket subscription to binance smart chain, which triggers an event every time a new block is issued. Once a new block number n is issued, I send a transaction and expect it to be mined at block n + 1. Unfortunately, on average, the transaction gets mined on block n+3. I know that binance smart chain has very high block issuing speed (1 block every 3 seconds), but I was wondering if there was a way to increase the transaction placement speed. I tried increasing the gas price from the standard 5 Gwei price floor to 30 Gwei and the results were identical. I increased my node peer count from 300 to 600 and nothing has changed.
I know that such transaction can indeed be mined at block n+1, considering I have seen other smart contracts which execute transactions at block n+1 relying on data which is available on block n. This indicates that the other contracts simply can't place the transaction at block i.e n-1, as it relies on data which yet hasn't been mined. This leads me to think that the people running transactions on the other contracts receive the new block information before, being able to execute the transaction in 1 block time compared to my program that takes 3 blocks.
Can this be the case? If it is, how can I improve the speed?
Thanks.


texts:
I'm working on extracting all token holders and I've faced up with following issue: my assumption was that since token holders a stored in the state of token smart contract, the only way to obtain or transfer them it's to call a function of smart contract, i.e. send a transaction to the smart contract. But I've found such transaction: https://etherscan.io/tx/0x61a0b16eeef9de8eac1b7279d11de20b987445f67707aed27bbd3e6aa3d76114

There is a transfer of the Tron tokens but 'To' field of the transaction is not a Tron smart contract address. How can it be possible?

May the second smart contract call function of the Tron smart contract?

Thanks for any help.


texts:
Is it possible to get account Balance in fast node with Geth ?
and what is the size of fast node currently?


texts: How can I get 43 MH/s using AMD HD 7990?

texts:
I read from this post that it is possible to get 43 MH/s using AMD Radeon HD 7990. Does anyone know how can I achieve this? I am getting right now 30MH/s per card using EthOS.

Any help would be greatly appreciated.


texts: Explain the multi-sig wallet loss by deletion of "code"?

texts:
In recent news about the potential loss of 300M USD.

Could someone please explain how it is possible to "kill" a number multi-sig wallets by removing code?

As a programmer I fail to understand how fixing buggy code or even deleting code can affect peoples cryptocurrency wallets? This is particularly cumbersome to understand as the Ethereum is supposed to be a decentralized platform. Isn't that the whole point, that it should protect the system from simple hacks (or programmer "errors")?

EDIT-1:

Realizing I am not familiar with the jargon in the context of cryptocurrency development programming, I suppose the question may be simplified by instead explaining how the programming code is kept separate from the wallet contents (the addresses affected). How can a program change, affect some random account address? (Are you not testing development code on a non-production system?)

EDIT-2:

In trying to better grasp whats going on, I read the following that may prove more helpful to others.

"What is the ethereum virtual machine?":

  With Ethereum, every time a program is used, a network of thousands of
  computers processes it. Contracts written in a smart contract-specific
  programming languages are compiled into 'bytecode', which a feature
  called the ethereum virtual machine (EVM) can read and execute. All
  the nodes  execute this contract using their EVMs.

  Bitcoin miners validate the shift of ownership of bitcoins from one
  person to another. The EVM  executes a contract with whatever rules
  the developer initially programmed. Actual computation  on the EVM is
  achieved through a stack-based bytecode language (the ones and zeroes
  that a machine  can read), but developers can write smart contracts in
  high-level languages such as Solidity and  Serpent that are
  easier for humans to read and write.

This is also explained fairly well here:

  From a practical standpoint, the EVM can be thought of as a large
  decentralized computer containing millions of objects, called
  "accounts", which have the ability to maintain an internal database,
  execute code and talk to each other.

There are two types of accounts:

Externally Owned Account (EOA): an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send ether and messages from it.
Contract: an account that has its own code, and is controlled by code.

  By default, the Ethereum execution environment is lifeless; nothing
  happens and the state of every account remains the same. However, any
  user can trigger an action by sending a transaction from an externally
  owned account, setting Ethereum's wheels in motion. If the destination
  of the transaction is another EOA, then the transaction may transfer
  some ether but otherwise does nothing. However, if the destination is
  a contract, then the contract in turn activates, and automatically
  runs its code.


texts: How can i increase the block number in testrpc?

texts:
I have the contract which has the dependencies on the block.number so in my javascript test cases I want block number jump. I know about the eth_mine but it will mine only the current block or work for one block. It doesn't take any parameter to increase a large number of blocks.

Can anybody have any possible ways to achieve this task?


texts: In building an IONIC app, I am attempting to retrieve the historical balance of a single Ethereum address. I am currently not sure how far back I will need to go. I know that Etherscan.IO offers a web tool to get balance from a certain date at https://etherscan.io/balancecheck-tool , however I cant find any API's that allow me to do this programmatically. I am also unable to get web3 to install in my current project. Any advise would be appreciated.


texts:
A few days ago, several attempts at creating a contract failed with out of gas errors (confirmed by etherscan/ethercamp and getBalance API), however it is not clear to me what failed exactly, and how it can be diagnosed.

  Not enough gas for 'No gas to return just created contract' cause
  spending

One such transaction is 0x47bf53491a14e64bc8938afa97d4b012677f465bddd7c3c0bbfb5df2baa99127

If you check it in Etherscan and ether.camp, it is listed with an error, but when looking at the vmtrace in both explorers, or when looking at the output of  debug.traceTransaction, no error is reported.

The transaction receipt also shows no error and indicates a contract address as if everything worked.

What exactly went wrong?

(I tentatively declared an Issue for geth, but I am unsure of how it should be qualified)

edit AFAICT there four transactions with the same behavior, listed below, (they are not mine, nor my attempts, I am only interested in them because of the out of gas behavior)

0x0b157cbbcca6079664e1f61e5f5e33241999c1cc1a7dbc1adad347b904c0fb65
0xc712e39a316745d1c0154941bcd9c60eacaf6287596dd3e356249e69509d20c1
0xaf071ce2147cc61d951a07c4e123c99f84b50e3656ceb07bba2c78796875626c
0x47bf53491a14e64bc8938afa97d4b012677f465bddd7c3c0bbfb5df2baa99127


texts: How to get the cost (in gas) of the non-constant function call?

texts:
In my understanding, there are some situations, where the compiler can't calculate, how much Gas it takes to complete the function call. The most obvious example - when your function is calling some function from the another contract. The compiler doesn't have the source of the another contract so it can't tell you, how much Gas is necessary, to complete the call.

But even when the function doesn't call any external function, the compiler also can't tell you the cost. A small example is listed bellow:

pragma solidity ^0.4.16;

contract Test {
    address[] owners;

    function addOwner(address newOwner) external {
        owners.push(newOwner);
    }
}

The warning message is:

  Gas requirement of function browser/ballot.sol:Test.addOwner(address)
  unknown or not constant. If the gas requirement of a function is
  higher than the block gas limit, it cannot be executed. Please avoid
  loops in your functions or actions that modify large areas of storage
  (this includes clearing or copying arrays in storage)

What is the reason of this warning? I think maybe it's because of changing the state, but I'm not sure.

Thank in advance!


texts:
What is the lowest possible difficulty that can be set in genesis file so the first block starts with minimal difficulty and then grows slowly to reach the regular >100k difficulty levels ?

I have done some tests , and if I set the difficulty to 1,2, 16 or 32 the difficulty doesn't grow. It stays constant, and I have proofs of that.

This is how I do it:

[niko@localhost difeth]$ cat genesis.json
{
    "config": {
        "chainId": 444,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "0x20",
    "gasLimit": "2100000",
    "alloc": {
    }
}
[niko@localhost difeth]$
[niko@localhost difeth]$ g --datadir /home/niko/saved-niko-home/difeth init ./genesis.json
[niko@localhost difeth]$ g --datadir /home/niko/saved-niko-home/difeth --networkid 444 console
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.2-unstable-ad444752/linux-amd64/go1.8.3
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> personal.newAccount()
Passphrase:
Repeat passphrase:
"0xc2b3b2f2ce7945cd60f3c7c30a4b02565c4786cf"
> miner.start(1)
INFO [10-16|17:17:52] Updated mining threads                   threads=1
INFO [10-16|17:17:52] Transaction pool price threshold updated price=18000000000
INFO [10-16|17:17:52] Starting mining operation
null
> INFO [10-16|17:17:52] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=332.1µs
INFO [10-16|17:17:52] Successfully sealed new block            number=1 hash=5bdbe9…387386
INFO [10-16|17:17:52]  mined potential block                  number=1 hash=5bdbe9…387386
INFO [10-16|17:17:52] Commit new mining work                   number=2 txs=0 uncles=0 elapsed=243.157µs
INFO [10-16|17:17:52] Successfully sealed new block            number=2 hash=52b61f…66617b
INFO [10-16|17:17:52]  mined potential block                  number=2 hash=52b61f…66617b
.....

On another console I do:

[niko@localhost difeth]$ g --datadir /home/niko/saved-niko-home/difeth attach ipc:/home/niko/saved-niko-home/difeth/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.2-unstable-ad444752/linux-amd64/go1.8.3
coinbase: 0xc2b3b2f2ce7945cd60f3c7c30a4b02565c4786cf
at block: 8 (Mon, 16 Oct 2017 17:17:59 CDT)
 datadir: /home/niko/saved-niko-home/difeth
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> loadScript("/home/niko/saved-niko-home/myeth/snippets/dumpdiff.js");
true
> dumpDiff()
32  0   0
32  1508192272  1508192272
32  1508192273  1
32  1508192274  1
32  1508192275  1
32  1508192276  1
32  1508192277  1
32  1508192278  1
32  1508192279  1
32  1508192280  1
32  1508192281  1
32  1508192282  1
32  1508192283  1
32  1508192284  1
32  1508192285  1
32  1508192286  1
32  1508192287  1
32  1508192288  1
32  1508192289  1
32  1508192290  1
32  1508192291  1
32  1508192292  1
32  1508192293  1
undefined
> exit

Here the first column is the difficulty, the second is the timestamp, and the third is the time to create a block, in seconds. What I was expecting is that the first column had the difficulty like 32,40,54,67,89,122... and so on, but not constant 32.

This is how dumpdiff() is defined:

[niko@localhost snippets]$ cat dumpdiff.js
function dumpDiff() {
    var i,end;
    var block;

    end=web3.eth.blockNumber;
    var prev_ts=0;
    var seconds;
    for (i=0;i<end;i++) {
        block=web3.eth.getBlock(i,true);
        seconds=block.timestamp-prev_ts
        console.log(block.difficulty+"\t"+block.timestamp+"\t"+seconds);
        prev_ts=block.timestamp;
    }
}
[niko@localhost snippets]$

Now, I had to modify params/protocol_params.go to set MinimumDifficulty to 2 because it didn't work with lower difficulties than 131072, but I am not sure if this is still relevant with latest sources.


texts:
Let's cook up a scenario to ease understanding:
We have a group of 5 people (addresses) who must vote on a question.
The people can only vote True or False i.e. a boolean.
The result of the vote will be decided by majority consensus within the group.

Now my question arises - How can I ensure that the group don't cheat by cartelling? Note: they must vote in a blindfolded fashion.  Would a viable solution be to use a commit-reveal sequence where their individual address is hashed with their boolean commitment during an initial phase, and then revealed later in final phase? if not, how should I go about tackling this particular problem?


texts: How to propose future gas prices of OPCODES?

texts: I'm concerned as to how are we going to reach consensus if new opcodes are to be included on the EVM or if we would like to update the cost of some opcodes. The gas price has been chosen arbitrarily at v1. Is there any approach to build on-chain a consensus process for gas cost?


texts:
I have these 2 functions in my contract with help of which I want to recover the address of the signer:
function formSigningData(address NFTAddress, uint NFTId, uint amount, address tokenAddress, uint price, uint deadline, address privateAddress, uint nonce, bytes memory data)
                public
                pure
                returns(bytes32) {

                return keccak256(
                        abi.encodePacked(
                                NFTAddress,
                                NFTId,
                                amount,
                                tokenAddress,
                                price,
                                deadline,
                                privateAddress,
                                nonce,
                                data
                                )
                        );
    }

function recoverSigner(address NFTAddress, uint NFTId, uint amount, address tokenAddress, uint price, uint deadline, address privateAddress, uint nonce, bytes memory data,  bytes memory signature)

                public
                pure
                returns(address) {

                bytes32 dataHash = formSigningData(
                                NFTAddress,
                                NFTId,
                                amount,
                                tokenAddress,
                                price,
                                deadline,
                                privateAddress,
                                nonce,
                                data
                                );

                return ECDSA.recover(ECDSA.toEthSignedMessageHash(dataHash), signature);
        }

And when I actually try to run them, they do not work properly(Meaning that the logged addresses of the recovered signer and the wallet are different, instead of being the same)
it('BuyNFT: Gets executed properly if sufficient price is approved for the contract', async () => {
        let marketPlace = await MarketPlace.deployed();
        let testToken = await TestToken.deployed();
        let testNFT = await TestNFT.deployed();

        await testNFT.mint(seller, 1, 10000, '0x01');
        await testToken.approve(marketPlace.address, 1000);

        let wallet = ethers.Wallet.createRandom();

        let bytesData = await marketPlace.formSigningData(testNFT.address, 1, 100, testToken.address, 1000, 0, emptyAddress, 1, '0x01', {from: wallet.address});
        let signature = await wallet.signMessage(bytesData, {from: wallet.address});
        let recoverAddress = await marketPlace.recoverSigner(testNFT.address, 1, 100, testToken.address, 1000, 0, emptyAddress, 1, '0x01',  signature)

        console.log(wallet.privateKey);
        console.log(recoverAddress);
        // console.log(accounts[0]);

    })

Could you see what part am I missing here? Would appreciate the help a lot. Thank you)


texts:
I want to display information about Geth, specifically eth.getBlock("latest").number, in a Node.Js GUI. However, I'm not sure how to keep it updated. One solution is to request the information from the browser once every 5 seconds or so, but it doesn't look very elegant. Does web3 provide an event or something like that so that socket.io calls the clients with the updated information whenever a new block is downloaded?

Thanks,


texts: Is it possible to prevent nodes from mining on a private blockchain?

texts:
Is it possible to prevent mining on a closed block chain, in a sense that only a set of addresses are allowed to perform transactions but are not allowed to mine?

Mining should always be done by a preselected number of nodes with known addresses.

The solution would be preferable to use pyethapp or pyethereum.


texts:
Few years back, when the Ethereum started, I downloaded "geth" for Windows and started mining. I had it running 24/7 for several months with my (then) top of the line VGA.
After noticing that the Electricity bill was very high, and I realized that I cannot compete in a country with that expensive electricity, I stopped it. However, I kept all the generated files locally.
Now I have a folder structure of:
/Ethererum
/chaindata
/ethash
/geth
/chaindata
/ethash
/nodes
/nodes
First it looks like I have a copy of folders, so I had it running in /Ethereum and at some point I had another instance running in /Ethereum/geth
Under both "chaindata" folders there are ~60K files of "dddddd.ibd" files and some others like CURRENT, LOCK, LOG, LOG.old, MANIFEST-xxxxxxx.
I do not remember having an  account, or wallet. Just had it mining.
Now I am on Linux, installed geth and tried to run it with "geth --datadir "/Ethereum"
When I did that, I am getting tons of logs like this:
INFO [02-22|11:02:52.835] Deep froze chain segment                 blocks=30001 elapsed=4.158s number=1650054 hash="c17d88…0914ff"
INFO [02-22|11:02:56.469] Deep froze chain segment                 blocks=30001 elapsed=3.634s number=1680055 hash="1df192…6de3b8"
INFO [02-22|11:03:00.164] Deep froze chain segment                 blocks=30001 elapsed=3.694s number=1710056 hash="ae6ee9…b31182"
INFO [02-22|11:03:04.061] Deep froze chain segment                 blocks=30001 elapsed=3.896s number=1740057 hash="436215…cce7f0"
INFO [02-22|11:03:07.951] Deep froze chain segment                 blocks=30001 elapsed=3.889s number=1770058 hash="22fcfc…a0c7ac"
INFO [02-22|11:03:11.908] Deep froze chain segment                 blocks=30001 elapsed=3.957s number=1800059 hash="dfa290…c3ed60"
WARN [02-22|11:03:12.476] Checkpoint challenge timed out, dropping id=e1b541d10cc201ab conn=dyndial addr=18.162.109.156:30304 type=Geth/v1.9.19-stable-...

Is there any way to retrieve and resume my work?
What can I do from this point on?


texts: Private chain: Run out of gas even with a high balance

texts:
Context

geth: Geth/v1.4.18-stable/linux/go1.5.1
solc: 0.4.6

I am writing a contract testing it on a private network with a large amount of pre-allocated gas.
The following works perfectly fine:

pragma solidity ^0.4.0;

contract accountList {

    address[] allowedClient;

    function add(address client) returns (bool) {
        allowedClient.push(client);
        return true;
    }

    function get() constant returns (address[]) {
        return allowedClient;
    }

}

Addresses are well added when I call the add method. I can retrieve them calling the get method.
This cost me nothing since I use the same account to call the contract and to mine the transaction (I earn more gas mining the transaction than I use to call the contract).

Issue

I run out of gas when I add a second array with the same behaviour:

pragma solidity ^0.4.0;

contract accountList {

    address[] allowedClient;
    address[] test;

    function add(address client) returns (bool) {
        allowedClient.push(client);
        test.push(client);
        return true;
    }

    function get() constant returns (address[]) {
        return allowedClient;
    }

}

Calling the add method make me run out of gas

 contractInstance.add(coinbase, {from: coinbase}, function(error, result) {
    ...
 }

Debug in the geth console:

> eth.getBalance(eth.accounts[0])
1.245e+21
> var t = web3.debug.traceTransaction('0x456...')
> t.structLogs[t.structLogs.length-1].error
"Out of gas"

A balance of 1.245e+21 should be enough isn't it?
Which configuration can I use to avoid gas limitation on my private network?


texts:
I'm starting to mine ETH using my new sapphire rx5500xt 8GB with NiceHash. I'm trying to google the best settings for overclocking / undervolting but can't find anything that seems to work, most make it crash.
I'm currently doing about 25.3 MH/s @100W with stock settings, tried to raise the memory speed to max and it went to 26.8 MH/s with the same power draw, but crashed after a few minutes.
Any clue where I could find some info / how to approach the problem?


texts: I want to understand deeply how ether transfer processed and how 21000 of gas determined. Is this a simple constant fee of the transfer transaction or ether transfer transaction is the some predefined contract function call and instructions of this function require 21000 of gas for execution?


texts: I am learning solidity. I came across the concept of function modifiers. I am unable to understand it.


texts: What's the least amount of ether that can be sent in a transaction? Can you send 0 ether?

texts: What's the least amount of ether that can be sent in a transaction? Would it be 0.000000000000000001? Or can you send 0 ether? How would you do that?


texts:
Compatibility of ERC20 Token ICO with Parity Client-how exactly does it work?

i am struggling, how do I get the erc20 token after a contribution with Parity? Do I have to go to the "contracts" menu, or the "token registry" menu within Parity to add manually the custom erc20 tokens, or does everything happen automatically, and after the ICO I will see directly my new erc20 token?
How does Parity allow me to "Possess" the tokens , so that I can for example transact them to an exchange for trading , or to another wallet?

Anybody who did an actual erc20 ICO with Parity, here who can help?

Thanks a lot!


texts: Infinite gas estimate for almost all the functions. Is it normal?

texts:
When I deploy contract test net, it shows an error that gas limit exceeds: 3000000 What's the solution?

Github Link to the smart contract.

And is it normal to have the infinite gas estimate of almost all the functions?


texts: De-Centralized Data Analytics in Ethereum?

texts:
I am interested in analyzing Ethereum transactions and/or the state of accounts (storage) with analytical methods (descriptive statistics, risk/fraud scoring, cluster analysis, forecasting, ...), basic data analytics stuff.

I have understood, that I can export the blockchain level-db storage to an analytical database (SAS, Hadoop, ...) and process it than with SQL or even analytical languages like R, SPSS, SAS.

But my question is: Can I do it in a de-centralized way? Can I write a smart contract for doing that? Do smart contracts have that capabilities and access the blockchain state? Does it cost me gas as these are read-only transactions?

And going further: Can I spread a query over all nodes in the Ethereum network (Massive paralell processing of queries)? I understand that every transaction is processed by every node, but can i split the analytical work to be done to a kind of federated query?

This capabilities would be basically a way of de-centralized data analytics and I wonder if and how this can be done in Ethereum?


texts: TypeError: balance.toNumber is not a function

texts:
I need check that token has no balance when selfDestruct was called, but shows an error that balance.toNumber is not a function in the test file.

DappTokenSale.sol

function endSale() public {
  //Require Admin (Only Admin can end the Sale)
  require(msg.sender == admin);

  //Transfer remaining dapp tokens to admin
  require(tokenContract.transfer(admin, tokenContract.balanceOf((address(this)))));

  // Destroy contract at the end - transfer remaining token to the admin
  admin.transfer(address(this).balance);

DapptokenSale.js

(This test code is only for admin.transfer(address(this).balance); )

balance = web3.eth.getBalance(tokenSaleInstance.address);
assert.equal(balance.toNumber(), 0);


texts: How can Remix Ethereum decode output address of smart contract is created from another smart contract

texts:
I have seen that when I create a new smart contract from another smart contract Remix Ethereum return to me the address of smart contract.
But When I do it with web3js the callback function just return to me a transactionHash and no more information.
When I try to get eth.getTransactionReceipt("transactionHash") I saw contractAddress is null.

I can work arround by use event but my question is that How can Remix Ethereum can do that?

pragma solidity ^0.4.24;

contract Project {
    address public founder;
    constructor () public {
        founder = msg.sender;
    }
    function createRequest(string _title) public returns (address) {
        address addrRequest = new Request(_title);
        return addrRequest;
    }
}

contract Request {
    string public title;
    constructor(string _title) public {
        title = _title;
    }
}

Result from remix ethereum tool


texts:
I want to calculate string length in bytes. Here is the sample code I used.

function mine(string s  ) public view returns (bytes) {
        return bytes(s).length;
}

But throws this error-

TypeError: Return argument type uint256 is not implicitly convertible to expected type (type of first return variable) bytes memory.
         return bytes(s).length;
                ^-------------^


texts: The send transactions "from" field must be defined using Infura web3

texts:
when I try to send my transaction using infura I get this error
      "The send transactions "from" field must be defined"

My problem is my web3 object. When I used Metamask and my app from a  Google Chrome page I did't have problem
  App.web3Provider = web3.currentProvider
  web3 = new Web3(web3.currentProvider)

Now, using Truffle, I need to interact with my smart contract without metamask.
I get my web3 from infura.
    App.web3Provider = new Web3.providers.HttpProvider("https://ropsten.infura.io/v3/2a8xxxxxxxxxxxxxxx")
    web3 = new Web3(App.web3Provider)

(UPDATE) Iteraction with my Smart Contract
    const partecipazioneContest = await $.getJSON('File.json')
    App.contracts.PartecipazioneContest = TruffleContract(partecipazioneContest)
    App.contracts.PartecipazioneContest.setProvider(App.web3Provider)
    App.partecipazioneContest = await App.contracts.PartecipazioneContest.deployed()

Error when I make the transaction:
  await App.partecipazioneContest.addUser(parameters);

I think my problem is that it does't load  my account, so I create my account from my private key and i get the correct addres, but when I try to get my account with getAccount() function the accounts are empty.
    await web3.eth.accounts.privateKeyToAccount('0x33434XXXXXXXXXXX13');
    web3.eth.getAccounts().then(function(acc){
      accounts = acc
      console.log(accounts)
      alert(" getAccounts " + accounts)

    })

How to load my web3 returned from infura with my accounts and all the information that i need to interact with the smart contracts?
I would like to interact with my Smart contract with my wallet on Metamask passing by infura


texts: Ethereum C++ Contract ABI - any references?

texts:
I'm usually pretty good with  but this has me stumped. I'm a fairly hard core C++14/17 embedded programmer attempting to learn the Ethereum blockchain. I'm starting with Solidity via a Pluralsight course.

The more I learn, the more I'd like to write contracts in C++. Trouble is, I can't find any articles/questions/code/anything. My current search is: ethereum "c++" contract abi definition.

So finally here is my question: Can someone share a set of search terms and/or links to actual references to get me started?


texts: Type Error: send and transfer are only available for objects of type "address payable " not address

texts:
pragma solidity ^0.6.0;

contract Campaign {
    Request[] public requests;
    address  public  manager;
    uint public minimumConstribution;
    mapping(address => bool ) public approvers;
    uint public approversCount;

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

    struct Request {
        string description;
        uint value;
        address recipient;
        bool complete;
        uint approvalCount;
        mapping(address => bool) approvals;
    }

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

    function constribute() public payable {
        require(msg.value > minimumConstribution);

        approvers[msg.sender] = true;

        approversCount++;
    }

    function createRequest(string memory description, uint value, address recipient) public restricted {
        Request memory newRequest = Request({
            description : description,
            value : value,
            recipient : recipient,
            complete : false,
            approvalCount : 0
        });

        requests.push(newRequest);
    }

    function approveRequest(uint index) public {
        Request storage request = requests[index];

        require(approvers[msg.sender]);
        require(!request.approvals[msg.sender]);

        request.approvals[msg.sender] = true;
        request.approvalCount++;

    }

    function finalizeRequest(uint index) public restricted {
        Request storage request = requests[index];

        require(request.approvalCount > approversCount /2);

        require(!request.complete);

        request.recipient.transfer(request.value);
   //THis above line shows error   //.tranfer method not working in compiler version 0.6.0.//

        request.complete = true;

    }

}


texts:
This might be a basic question, but still dealing with conceptual stuff about ethereum and solidity.

Original question was: How does solidity send() & transfer() know about contract ether?
Editing it to: Why function that does transfer without a mapping fails?

If a contract wants to hold ether you create a payable function that receives the msg.value.
To withdraw ether you would specify a function with the intended address destination and amount.

However when I test the second statement it only seems to be true if I use a mapping. On the example below not concerned about security, so this code would not apply to real life.

If I do another function that does not a mapping, no error is returned, and although it succeds performing the transaction, no ETHER is trully withdrawn.

To me both are the same, one keeps a track of addresses and the other one does not, however the transfer is the same.

So based on this behavior is where my confusion stems on how a function to withdraw knows it is ether belonging to the contract. To deposit we have "payable" but no equivalent to withdraw.

I know one could do msg.sender.transfer(address(this).balance)  where address(this) refers to the contract.

pragma solidity >=0.5.0 <0.6.0;

contract CheckBehavior {

    mapping(address => uint256) _deposits;

    function depo() public payable{

        _deposits[msg.sender]= msg.value;

    }

//not working
    function withdrawA(uint256 _amt) public {

        msg.sender.transfer(_amt);
    }

//not working , I would expect this to work fine as withdrawWithGas()

    function withdrawB(address payable payee, uint256 _amt) public {

        payee.transfer(_amt);
}

//Works. My understanding is that the mapping is a security pattern to avoid re-entrancy, as
this keeps track of addresses and one can condition based on it
    function withdrawWithGas(address payable payee) public {
        uint256 payment = _deposits[payee];

        _deposits[payee] = 0;

        payee.transfer(payment);
    }

}

First image is the transaction of the deposit, money reflects as subtracted fine on remix.

Second image is transaction of withdrawA, which does transact but does not give me any ether. If I use instead the last one it works.


texts: Why Are My The DAO To ETH Refunds Failing?

texts:
A user on thadao.slack.com was having trouble withdrawing their refunds from The DAO Withdrawal contact.

I checked the WithdrawDAO contact and noticed that there are many other transactions failing:

Why is the user's The DAO to ETH refund failing?

In this case, the user was using the Jaxx wallet to execute the refunds.

See also:

How do I convert my The DAO tokens into ethers using the withdrawal contract after the hard fork?


texts: is there any way to save data from sensor on smart contract automatically?

texts:
I want to take the temperature value from one sensor on save it on the contract of manually , i tried to use node-red , or raspberry pi but i didn't get a good result.

the second question is it expensive to do it like this ? I mean saving data on the contact how much does it cost?


texts: I am developing a voting application using blockchain (ganache). So basically i am registering the candidates by a web form and storing the data in phpmyadmin database. Now i want to access this data in my smart contract(written using solidity) to give a drop down of the candidates contesting for the elections. I need a way to access my database tables in my smart contract written in solidity


texts: I downloaded the non-HD version of the Jaxx wallet in March.  I wrote down the backup phrase and sent some ether to it. Then my phone broke and I tried to restore my wallet but the words don't work. I'm certain that they are correct as I checked them multiple times to make certain. There are only the two transactions sent to the address and none sent out. The ether still sits there. And I can prove that I'm the one who sent the ether from my other account and was wondering how I'm going to get my ether back if Jaxx gave me a backup that doesn't even work.


texts: Withdraw balance from external contract in Solidity 0.6

texts:
Getting two errors with the following code.

abstract contract ReceiveBalanceContract is Ownable {

    receive() external payable {
        require(msg.sender == address(SendBalanceContract));
    }

    function withdrawBalance() external {

        owner.call.value(address(this).balance)();
    }
}

contract SendBalanceContract {

    constructor(address _nftAddress) public {

        ERC721 candidateContract = ERC721(_nftAddress);
        require(candidateContract.supportsInterface(InterfaceSignature_ERC721));
        nonFungibleContract = candidateContract;
    }

    function withdrawBalance() external {
        address nftAddress = address(nonFungibleContract);

        require(msg.sender == owner || msg.sender == nftAddress); // Error 1
        bool res = nftAddress.call.value(address(this).balance)(""); // Error 2
    }
}

I am getting two errors and can't manage to fix this.
Error 1:

TypeError: Operator == not compatible with types address payable and function () view returns (address)
require(msg.sender == owner || msg.sender == nftAddress);

Error 2:

TypeError: Different number of components on the left hand side (1) than on the right hand side (2).

I don't understand what s going on here


texts: ratification path for web3 beta to production

texts:
What is are the prerequisites for bringing web3js 1.0 beta to production?

The disparity between the 0.x software and the 1.x software has gone on for 1/3rd of the web3 project's lifespan now, it isn't clear to me the path to production is.


texts: Base fee exceeds gas limit on connecting to local instance of testrpc on Remix IDE

texts:
Note:
I have already visited the related links which have similar questions posted, but I didn't find any solution which I could use to solve the issue Im facing.

Im following this Coursetro tutorial, which basically guides those new to blockchain to create a simple smart contract.
The contract is defined as follows:

pragma solidity ^0.4.18;

contract Coursetro {

string fName;
uint age;

function setInstructor(string _fName, uint _age) public {
    fName = _fName;
    age = _age;
}

function getInstructor() public constant returns (string, uint) {
    return (fName, age);
}
}

However when I change the environment in the remix IDE from Javascript env to Web 3 env(To connect to the testrpc instance running locally on terminal), I get the following error:

creation of browser/Coursetro.sol:Coursetro pending...
creation of browser/Coursetro.sol:Coursetro errored: Error: base fee
exceeds gas limit
at runCall (/usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:70875:17)
at /usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:12643:24
at replenish (/usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:9736:17)
at iterateeCallback (/usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:9721:17)
at /usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:9696:16
at /usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:12648:13
at /usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:67073:16
at replenish (/usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:67020:25)
at /usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:67029:9
at eachLimit (/usr/local/lib/node_modules/ethereumjs-
testrpc/build/cli.node.js:66953:36)

I understand that the fee for executing any contract must never exceed the Gas limit set, but in this case, Im unable to deduce where to set the Gas limit. Im new to this so kindly guide me as to how to solve the above error.


texts: I sent PRL token to contract address instead of wallet address

texts:
I am wondering if i can recover the tokens. I sent PRL tokens to contract address  0x1844b21593262668B7248d0f57a220CaaBA46ab9 instead of myetherwallet address from kucoin exchange wallet. :-(
Are they lost forever ?
I feel like an idiot and it would be so kind if someone could tell me if something can be done to get my Oyster Pearl token back.
However, happy new year everyone !


texts: DocstringParsingError when using natspec with internal or private functions

texts:
Ethereum's natspec mentions:

  You are welcome to use similar comments for your internal and private functions, but those will not be parsed.

However, when documenting internal functions, I get errors like the following:

DocstringParsingError: Documented parameter "amount" not found in the parameter list of the function.

I'm using Truffle to run tests. It appears it's attempting to parse the natspec for internal functions when it should be skipping them.

Is there a way to disable this?

So far I'm getting away by using regular comments (//) for internal functions.


texts: Implementing a card game, how to keep the dealt cards secure?

texts:
Hello I am a novice with ethereum and encryption...

If i would implement a cardgame in ethereum, i jave to deal cards to users. I think this can be done by encrypting the cards by the players' public key.

But once the user reveals its card at the end of the game, how can the server know it's not a fake revealing?

I was also thinking keeping the card dealing off chain, but that implies a trust needed on the dealing system.

I am looking for any advice/strategies in how (if) this can be done.


texts: GTX 1070 Hashrate dropped from 30.8 to 28.3. Settings not changed

texts: I was running at an overclock of +600 on the memory clock and was getting about 30.8 for my hashrate. I tried overclocking to +700 but it didn't seem stable as I got some minor artifacting after about 10 minutes. I then reverted back to my old OC but my hashrate had gone down. This was about 9 hours ago now. What do I do?


texts: Potential re-entrancy vulnerability: how should I rearrange this function to avoid it?

texts:
I'm not ure why I keep getting a potential reentrancy attack vulnerability about the "publishEtherBox" function. The contract code is not complete but it should be enough to understand. Is it a bad syntax issue or maybe else?

contract {
...
  struct EtherBox {
    bytes32 label;
    address owner;
    string ownerUrl;
    uint256 expiration;
  }

  mapping (address => bytes32) public nicknames;
  mapping (address => address[]) public ownerToEtherBoxes;
  mapping (address => EtherBox) public etherBoxes;
  mapping (address => uint256) etherBoxesNonce;
...
  function publishEtherBox (bytes32 _label, string _ownerUrl, uint _lifespan) external onlyWhenRunning() payable {
      require(ownerToEtherBoxes[msg.sender].length < 10);
      assert(bytes(_ownerUrl).length <= 200);
      address etherBoxAddress = address(keccak256(msg.sender, etherBoxesNonce[msg.sender]++));
      ownerToEtherBoxes[msg.sender].push(etherBoxAddress);
      etherBoxes[etherBoxAddress] = EtherBox({
        label: _label,
        owner: msg.sender,
        ownerUrl: _ownerUrl,
        expiration: now + _lifespan
      });
      if(msg.value > 0){
        owner.transfer(msg.value);
      }
      emit EtherBoxPublished(msg.sender, nicknames[msg.sender], etherBoxAddress, _label, now);
  }
...
}


texts: How to read ethereum transaction imput data without knowing ABI?

texts:
How ot get information about transaction by reading data property and logs from recipe. https://etherscan.io/tx/0x91bfd54de4f05effe1cede58848ef87b97f334256326ce33d298149b8ce22051

const abi = requrie("./abi")
const abiDecoder = require("abi-decoder").addABI(abi)
const web3 = require("web3")

web3.eth.getTransactionReceipt("0x91bfd54de4f05effe1cede58848ef87b97f334256326ce33d298149b8ce22051").then((receipt: any) => {
console.log(abiDecoder.decodeLogs(receipt.logs)); // [undefined]

web3.eth.getTransaction("0x91bfd54de4f05effe1cede58848ef87b97f334256326ce33d298149b8ce22051").then((trans: any) => {
console.log(abiDecoder.decodeMethod(trans.input)) // undefined


texts: on a way of copying code that involves "super" keyword for supporting inheritance

texts:
I wonder the exact mechanism of copying code that involves "super" keyword for supporting inheritance in Solidity.

Below is an example code that elaborates my question.

contract C {
    function test() public {  }
}

contract B is C {
    function bbb() public {  }
    function test() public {
       bbb();
       super.test();
    }
}

contract A is B {
}

If we deploy the contract A and calls the function A.test(), then the actual (and desirable) effect is a call sequence of bbb()->C.test() (where super is replaced with C).

However, literally following the below explanation on inheritance in Solidity docs

  the code from all the base contracts is copied into the created contract.

may produce undesirable behaviors.
For clarification, let me perform the copy process for the example code above:

contract C {
    function test() public {  }
}

contract B is C {
    function bbb() public {  }
    function test() public {
       bbb();
       super.test();
    }
}

contract A is B {
    function bbb() public {  }
    function test() public {
       bbb();
       super.test();
    }
}

Again, if we deploy A and calls A.test(), then we have a call sequence of bbb() -> B.test() -> bbb() -> C.test(), where the supers in A and B are replaced by B and C, respectively.

Do I have any missing point?


texts:
So I created an time ratio crowd sale contract based on a token with a set initial supply and no mint function. I publish this contract and then send the associated tokens to the contract. I can send ether and receive it in the desired account and the new tokens are sent to the correct account.

*How to provide more tokens for the amount of ether you send in a crowd sales contract?

Thanks for any help!


texts: If a contract is deployed in one node will it be available to all the peers?

texts: Let's say peer A makes a contract and deployed it to the private network.Peer B joins the network.Will  it be available to peer B ?How the deployed contract will get reflected to peer B.It will be available automatically or we need to do something to happen it.


texts: Generate smart contract wrapper for android app

texts:
I've downloaded command line tool for generating smart contract wrapper.I put my compiled contract into out folder near web3j.bat file.However when I run this command
web3j solidity generate ./out/test_sol_TestToken.bin ./out/test_sol_TestToken.abi -o D:\android_dev\projects\eth_test\app\src\main\java -p test.user
I got this error

D:\Desktop\web3\bin>web3j solidity generate ./out/test_sol_TestToken.bin ./out/t
est_sol_TestToken.abi -o D:\android_dev\projects\eth_test\app\src\main\java -p t
est.user
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/web3j/con
sole/Runner : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

It looks like I have incorrect jdk version. I tried to add system env variable
JAVA_HOME=C:\Program Files (x86)\Java\jre7 with no luck.Can someone point me which jdk version web3j requires?


texts:
I have to develop a system which has to store lots of documents, and it will be unlikely to read them again (about 90% of all won't be read again).

I was reading IPFS specification and it looks like the insentives to keep documents copies won't work in my use case since it is unlikely to get a hit and get credit for it.

My question is: Do I need to create my own nodes to ensure that each document has at least two copies in the system or I can relay paying in some way to some nodes to keep this copy?


texts: How do I get the confirmations of a transaction programmaticallly?

texts:
Can I get the confirmations of a transaction using Solidity? If not, is there any other method I can use to get confirmations programmatically?

I hope when user submits one transaction, the web can show the result and the result won't be changed later. The users accept to wait the longer time, example 1 or 3 minutes, for making sure the transaction is finished.


texts:
I am working on translating code from Python to Solidity and everything has worked up until this last loop. Cannot figure out where the difference is in the code (besides the bytes being in decimal and hex encodings). Follows is the code in both languages and the outputs.

Python

outmasks = bytes([12, 11, 12, 14, 23, 8, 9, 9, 7, 3, 6, 5, 19, 19, 6, 6, 4, 6, 6, 0, 9, 6, 13, 14, 19, 2, 7, 4, 0, 0, 0, 12, 23, 8, 8, 10, 6, 14, 14, 9, 4, 5, 6, 5, 20, 11, 12, 11])

for cnt in range(0x30):
    outs |= outmasks[cnt] << 5*cnt

print(hex(outs))

0x5b174298a44b9c6521176000021c53734c9018c431a73298674a5177316c

Solidity

function test() public returns (bytes30 outs) {

    bytes memory outmasks = hex"0c0b0c0e1708090907030605131306060406060009060d0e130207040000000c1708080a060e0e0904050605140b0c0b";

    for (uint8 cnt = 0; cnt<48; cnt++) {
        outs |= outmasks[cnt] << 5*cnt;
    }
}

0x6c0000000000000000000000000000000000000000000000000000000000


texts: Truffle Test - Solidity: How to access value of Promise object? [object Promise] [BigNumber]

texts:
a.getB.call().then(function (f) { console.log(f[1][0]) });

outputs:

BigNumber { s: 1, e: 20, c: [ 5000000 ] }

How can I access the value in c?

How can I save object f to a javascript variable?

Since I am saving an array of arrays, can I get the length of the Promise object?


texts: Why is LH repeated in equation 35 of the yellow paper?

texts:
Excerpt from page 5 of the yellow paper, version e94ebda:

I understand that LX is the preparation function for serialising X, as follows:

LB for blocks
LH for block headers
LU for ommer block headers

And B represents the block tuple (BH, BT, BU):

BH represents the headers
BT [_] the transactions
BU [_] the ommer block headers

In the image above, shouldn't the second LH actually be LU, that is, the preparation function for the ommer block headers?

Is it because there's no need for a new preparation function because LH already has sufficient properties to compute the ommer block headers?


texts: I don't really understand how mining works, anyone can help?

texts:
I am currently studying Ethereum all by myself, and am struggling to understand how mining and Proof of work work.

I have read many posts and books about it but still hard to understand how the process goes.

Let's say I am sending 10 Ether to you who are reading this post, using Ethereum Wallet.

I will press 'Send' button there, and I will type your wallet address (hash code) and then put amount.

Then Ethereum Wallet will show me how many of confirmations this transaction is getting like the following picture:

It usually starts with 0 of 12 confirmed, not in the picture but yeah.

So what I want to ask is

Who are giving the confirmation? Miner nodes?
If so, how? How do they know if this transaction is valid?

Miner nodes those were mining will be broadcasted if I make a transaction, and how do they know if the transaction is valid?

What I am understanding so far is each node will compare the ledgers they have, but 'what they have' is the past records, isn't it?
How would they know if the transaction, which is not recorded yet, is true or valid?

And when will the transaction be recorded in a block? As soon as the transaction is confirmed by 12 miner nodes?

How is confirming transactions (by miners) related to making new blocks?

Thanks in advance.


texts: Is there any case when the only transaction in Ethercan is IN, but Balance is 0 Ether?

texts:
The address that received only a hundred orders of deposit shows in zero balance.
I understand when using wallet on the exchange, that should have one  transaction that corresponds to OUT.
But there are no OUT transactions.
Is this possible using a hardware wallet?
Otherwise, I want to know when this happens.


texts: What is the max data size which one contract can store?

texts: I'd like to store big data into a contract by sending many transactions. What is the limit data size of the contract?


texts: Testing a function which calls a non-constant function

texts:
I have a non-constant function inside a contract:

contract InnerContract {
    event Event(uint256);

    function func(uint256 val) external returns (uint256) {
        Event(val);
        return val;
    }
}

It is invoked from a function inside another contract:

import './InnerContract.sol';

contract OuterContract {
    InnerContract pInnerContract;

    function func(uint256 val) external returns (uint256) {
        return pInnerContract.func(val) + 1;
    }
}

I am trying to test it in truffle via the following script:

contract('Test', () => {
    let hInnerContract;
    let hOuterContract;

    before(async () => {
        hInnerContract = await artifacts.require("InnerContract.sol").new();
        hOuterContract = await artifacts.require("OuterContract.sol").new();
    });

    describe('test:', async () => {
        let input = 1;
        it(`expected output = ${input + 1}`, async () => {
            try {
                let hash = await hOuterContract.func(input);
                let output = Number(hash.receipt.logs[0].data);
                assert(output == input + 1, `actual output = ${output}`);
            }
            catch (error) {
                assert(false, error.message);
            }
        });
    });
});

However, the problem is with hash.receipt.logs[0].data.

It contains the value inside the event generated in the InnerContract function.

I've figured that I should generate an event also in the OuterContract function:

contract OuterContract {
    event Event(uint256);
    InnerContract pInnerContract;

    function func(uint256 val) external returns (uint256) {
        uint256 val2 = pInnerContract.func(val) + 1;
        Event(val2);
        return val2;
    }
}

But when I do this, I get the following exception in truffle:

Uncaught TypeError: Cannot read property 'constructor' of undefined
at C:\Users\...\cli.bundled.js:316118:19
at Array.forEach (<anonymous>)
at C:\Users\...\cli.bundled.js:316114:32
at Array.map (<anonymous>)
at Object.decodeLogs (C:\Users\...\cli.bundled.js:316067:19)
at Object.callback (C:\Users\...\cli.bundled.js:316195:35)
at C:\Users\...\cli.bundled.js:37985:25
at C:\Users\...\cli.bundled.js:328869:9
at C:\Users\...\cli.bundled.js:324536:9
at XMLHttpRequest.request.onreadystatechange (C:\Users\...\cli.bundled.js:327565:7)

BTW, before this exception occurs, truffle indicates that both events have indeed been emitted:

Events emitted during test:
---------------------------

Event(: 1)
Event(: 2)

---------------------------

Can you please explain what I am doing wrong here?

Thank you!!!


texts: How do I recover the address from message and signature generated with web3.personal.sign?

texts:
Is there any way to do that? To recover address in nodejs server-side from signature and message after it was signed with web3.personal.sign client-side?
I tried this: https://ethereum.stackexchange.com/a/12580/42452 with ethereumjs-util; I tried recoverTypedSignature() from eth-sig-util but in both cases recovered addresses didn't match signing addresses.

Here is the client-side code:

function authorize() {
  web3.eth.getAccounts(function (err, account) {
    let nonce = "123ABC";
    web3.personal.sign(nonce, account[0], function (err, signature) {
      //send to nodejs server
      $.post("http://localhost:8087", {signature: signature, nonce: nonce, address: account[0]}, function (data) {
        console.log(data);
      });
    })
  })
}

and server-side:

app.post('/', cors(corsOptions), function(req, res){
const msg = web3.sha3(nonce);
const sig = signature;
const {v, r, s} = util.fromRpcSig(sig);

const pubKey  = util.ecrecover(util.toBuffer(msg), v, r, s);
const addrBuf = util.pubToAddress(pubKey);
const addr    = util.bufferToHex(addrBuf);

console.log(addr);
});
app.listen(8087);


texts: How do I manipulate data in multiple contracts and output them

texts:
I am trying to manipulate data I retrieve from my contract, and then display it.
Currently, I am running into 2 problems:
1-  I am unable to manipulate the data correctly.
2-  I am unable to display the manipulated data.
My contracts are organized as follows:
VoteFactory.sol:
pragma solidity ^0.7.4;
//"SPDX-License-Identifier: UNLICENSED"

import "./Vote.sol";
   contract Factory{
   […]
   address[] public deployedVotes;
   […]
   function createVote(uint typeOf) public{
        address newVote = address(new Vote(msg.sender, typeOf));
        deployedVotes.push(newVote);
   }
}

Vote.sol
pragma solidity ^0.7.4;
//"SPDX-License-Identifier: UNLICENSED"

contract Vote{
    struct election {
        string title;
        uint startDate;
        uint endDate;
        string description;
        //think about mapping?
        uint numVotes;
        string typeOfElection;
        mapping(address => bool) voters ; //see if a voter has voted
   }
   election public currentElection;
}

In my index.js I try the following to manipulate the data once the votesAddresses from VoteFactory are received:
const [renderedAddresses, renderAddresses] = useState([]);
    // manipulated data
   useEffect(()=> {//render votes
    var displayInfo = async (address) => {
      if(votesAddresses == '') {
        return;
      }
      try {// Get the contract instance.
        const instance = new web3.eth.Contract(
          VoteContract.abi,
          address
        );
        return (await instance.methods.currentElection().call());
      } catch (error) {
        console.error(error);
      }
    };
    var renderVotes = async () => {
        if (!votesAddresses){
          return;
        }
        var temp = []
        await votesAddresses.forEach(address => {
            displayInfo(address).then(newAddress => {
              temp.push(newAddress)
          })
        })
        renderAddresses(temp);
      }
    renderVotes();
  },[votesAddresses]);

As a result, votesAddresses doesn’t display when I try to return it in my JSX. However, I put a button that console.logs voteAddresses, and it gives me the right output, although it says “this value was first evaluated upon expanding, it may have changed since then.”

My questions are therefore:

How do I output the previous data of a deployed vote along with its contract address?
How do I display this output correctly?