texts: Can I avoid manually changing code from solidity 0.4.17 to 0.5?

texts:
I'm totally newbie in blockchain programming and I have a situation:

I have to continue the project written on truffle framework with solidity version 0.4.17, the problem is that I couldn't manage to compile the project because it was showing with the following(there were many like these) warnings:

Warning: Source file does not specify required compiler version! Consider adding "pragma solidity ^0.5.0;"
SyntaxError: Functions are not allowed to have the same name as the contract. If you intend this to be a constructor, use "constructor(...) { ... }" to define it.
Warning: This declaration shadows an existing declaration.
TypeError: Data location must be "memory" for parameter in function, but none was given.

I changed all contracts version with "pragma solidity ^0.5.0;" as it was suggested. but the other warnings were showing for every contract and I have to manually correct them. Whenever I'm correcting them in one contract then another contract shows the same warnings, and they are too many.

So my question is can I avoid manually correcting them? Is there any other way? (maybe continuing development on solidity ^0.4.17 somehow)

PS. project was written one and half year ago and was compiling and working.

Any help will be apprecited


texts: Tutorial of the Chainhammer for TPS measurements of Quorum blockchain

texts:
Can anyone help me to found a detailed tutorial on how to use the Chainhammer for TPS measurements for the 7nodes example of the Quorum blockchain

I found this link https://gitlab.com/electronDLT/chainhammer/blob/master/quorum.md but I'm confused where I must run the listener (python tps.py) in the node or where..
 I need help please


texts: How to create my own wallet and own blockchain explorer?

texts:
I'm running my own private/permissioned ethereum blockchain via geth on Ubuntu. How can i interact with my blockchain to visualize accounts, blocks, transactions etc...?

I've tried a lot of tutorials but many didnt show me any information via some web. Any pointers would be appreciated!


texts: Unit testing time sensitive Provable smart contracts

texts:
I'm currently using Provable (formerly Oraclize) to make a CRON job :

constructor() public payable {
    OAR = OracleAddrResolverI(0x6F486C8BD6fc43eA212E93CCF8ce047C7f1Cb475);
    provable_query(7 days, "URL", "");
}

In order to test that (Truffle, Mocha, Chai), I'm importing the following:

const Web3 = require("web3");
const { waitForEvent } = require("./utils");
const { time } = require("@openzeppelin/test-helpers");
const web3 = new Web3(
    new Web3.providers.WebsocketProvider("ws://localhost:9545")

Except for time coming from OpenZeppelin, those come from the Provable truffle box.

(waitForEvent, in particular, can return an event name and its description when triggered from Solidity.)

In order to test that, I have the following test:

it("Should have logged a new Provable query after the contract creation + cooldown", async () => {
    console.log(await time.latest());
    await time.increase(TIME_BETWEEN_TWO_QUERIES);
    console.log(await time.latest());
    const {
        returnValues: { description },
    } = await waitForEvent(contractEvents[PROVABLE_QUERY_EVENT]);
    assert(
        description === PROVABLE_QUERY_STRING,
        "Provable query incorrectly logged!"
    );
});

The time increase seems to work, but the waitForEvent promise is still waiting for TIME_BETWEEN_TWO_QUERIES to complete, which is problematic.

Does anyone know how I can properly test those time-sensitive matters? How to "advance" time for Provable to be able to detect it?


texts: Is there a Plasma shared knowledge space?

texts:
And maybe somewhere one can follow the implementers shared knowledge space?

Thanks


texts:
How would I migrate from IPFS, let says that I got 10M files linked by IPFS, and I want to migrate all of them to Swarm, how would I do that?

The question in a different way:
I want to use a new hash function?


texts:
I am looking to create a yield farming token, and was looking through some code, and noticed that the MasterChef contract (holding the liquidity pool logic) require manual 'adding' of a LP token to the list of pools tied to the MasterChef contract. I was wondering how I can go about creating a LP token, and deploying it to the testnet? So far, I have deployed the native token to the testnet, and also deployed the MasterChef contract to the testnet, but I am not too sure how to create an LP token and add it to the list of pools.
How do I create an LP token and how does it work? Thank you all! Sorry im new to all these blockchain stuff, so if theres any resources that you guys could point me to regarding yield farms and how they work behind the scenes, that would be great too! Thank you


texts: Truffle contract migration deploying same contract on multiple address

texts:
I deployed multiple contracts of which some are linked to one another using truffle migration on the testrpc . In my web3 call for a function of one of the contract, instead of returning the current account address (according to logic implemented in the contract) it is returning 0x0. I guess something wrong with my contract or my contract not properly deployed on the testrpc network. I opened remix solidity IDE and using my local rpc network I tried to load the contract from the address (I got the address from the json file generated by truffle after migration.) But I get the same contract loaded for any addresses of any of the contracts.
I am not sure if the only a single contract is deployed multiple times due to which web3 is not able to load other contracts or can there be any other reason for the method returning 0x0.

My migration code is :

  var Category = artifacts.require("./Category.sol");
  var CategoryCatalog = artifacts.require("./CategoryCatalog.sol"); var
  ConsentDirective = artifacts.require("./ConsentDirective.sol"); var
  Patient = artifacts.require("./Patient.sol"); var PatientFactory =
  artifacts.require("./PatientFactory.sol");

  var name = "Category"; var who =
  "0xddf6d5d32547276d47fc9edcf725ed4e2008a4ef"; var what = 1;
  module.exports = function(deployer) {   deployer.deploy(Category,
  name);

  deployer.link(Category, CategoryCatalog);
  deployer.deploy(CategoryCatalog);
      deployer.deploy(ConsentDirective, who, what);
      deployer.link(Category, Patient);   deployer.link(ConsentDirective, Patient);   deployer.deploy(Patient,
  who);

  deployer.link(Patient, PatientFactory);
  deployer.deploy(PatientFactory); };

Any help will be highly appreciated. Thanks


texts: Is a truffle migration effectively the same thing as a fork?

texts:
I'm confused as to the distinction between a migration (in truffle) and a fork (project, not ethereum). After the initial migration (deploy), any future migrations create new contracts with new addresses, while all of the old contracts are still alive and clients can connect to them. That seems like a fork to me, or am I missing something?

I also wonder if there established architectural patterns for avoiding forks. For example is it considered a good practice to replace constants with ethereum variables, and expose getter/setter functions for those?


texts:
I created random HD wallet seed using eth-hd-wallet package, then imported it into Metamask and got expected addresses:

0xF011B485DF2A66A3019dEa82E1EBbf7C716443A1 (m/44'/60'/0'/0/0)
0x9590D9ca47290358eaF1Cc8482Beb2fc09D25c72 (m/44'/60'/0'/0/1)
0x3cAd996C8C9205374aECF81eE8EDd80f2489dA04 (m/44'/60'/0'/0/2)

... and so on. But when I am using the same mnenomic in truffle-hdwallet-wallet I see that zeroth address is 0x959fd7ef9089b7142b6b908dc3a8af7aa8ff0fa1, second address 0x4e90a36b45879f5bae71b57ad525e817afa54890 that already has number of transactions on etherscan in Rinkeby testnet.

From now I have 2 questions:

How it could be, I mean duplication of mnemonic phrase?
Why truffle-hdwallet-provider shows me different address then Metanask or bitcore-generated ones?


texts:
I'm trying to interact with kyberswap protocol via solidity, when attempting to compile my code(this is from kybers github) I receive the following parser error

" ParserError: Function, variable, struct or modifier declaration expected. contract MyContract { ^------^"

contract MyContract {
    IERC20 internal constant ETH_TOKEN_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
    IKyberNetworkProxy kyberProxy;
    address payable public platformWallet;
    uint256 public platformFeeBps;

    // constructor
    // _platformWallet: To receive platform fees
    // _platformFeeBps: Platform fee amount in basis points
    constructor(
        IKyberNetworkProxy _kyberProxy,
        address payable _platformWallet,
        uint256 _platformFeeBps
        ) public
    {
        kyberProxy = _kyberProxy;
        platformWallet = _platformWallet;
        platformFeeBps = _platformFeeBps;
    }

    /// @dev Get the conversion rate for exchanging srcQty of srcToken to destToken
    function getConversionRates(
        IERC20 srcToken,
        IERC20 destToken,
        uint256 srcQty
    ) public
      view
      returns (uint256)
    {
      return kyberProxy.getExpectedRateAfterFee(srcToken, destToken, srcQty, platformFeeBps, '');
    }

    /// @dev Swap from srcToken to destToken (including ether)
    function executeSwap(
        IERC20 srcToken,
        uint256 srcQty,
        IERC20 destToken,
        address payable destAddress,
        uint256 maxDestAmount
    ) external payable {
        if (srcToken != ETH_TOKEN_ADDRESS) {
            // check that the token transferFrom has succeeded
            // we recommend using OpenZeppelin's SafeERC20 contract instead
            // NOTE: msg.sender must have called srcToken.approve(thisContractAddress, srcQty)
            require(srcToken.transferFrom(msg.sender, address(this), srcQty), "transferFrom failed");

            // mitigate ERC20 Approve front-running attack, by initially setting
            // allowance to 0
            require(srcToken.approve(address(kyberProxy), 0), "approval to 0 failed");

            // set the spender's token allowance to tokenQty
            require(srcToken.approve(address(kyberProxy), srcQty), "approval to srcQty failed");
        }

        // Get the minimum conversion rate
        uint256 minConversionRate = kyberProxy.getExpectedRateAfterFee(
            srcToken,
            destToken,
            srcQty,
            platformFeeBps,
            '' // empty hint
        );

        // Execute the trade and send to destAddress
        kyberProxy.tradeWithHintAndFee{value: msg.value}(
            srcToken,
            srcQty,
            destToken,
            destAddress,
            maxDestAmount,
            minConversionRate,
            platformWallet,
            platformFeeBps,
            '' // empty hint
        );
    }
}


texts: How to call imported Contract using Solidity?

texts:
Inside my contract I want to use importkeyword to load other contracts and libraries to make my code more clean. As an example, I carried DateTime.sol contract to another file and import it inside myContract file without any problem.

myContract.sol:

import "/Users/avatar/populus/contracts/DateTime.sol"; //works.
contract myContract{
   DateTime date = new DateTime(); //does not work.
   <Some_Code>
}

But from myContract contract, when I try to call the DateTime contract as: DateTime date = new DateTime() I have faced with the following error:

/usr/local/lib/python2.7/site-packages/populus/chain.py:580: in get_contract
    if contract_name not in self.contract_factories:
/usr/local/lib/python2.7/site-packages/populus/utils/functional.py:50: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
/usr/local/lib/python2.7/site-packages/populus/chain.py:198: in contract_factories
    compiled_contracts = self.project.compiled_contracts
/usr/local/lib/python2.7/site-packages/populus/project.py:153: in compiled_contracts
    optimize=True,
/usr/local/lib/python2.7/site-packages/populus/compilation.py:42: in compile_project_contracts
    compiled_sources = compile_files(contract_source_paths, **compiler_kwargs)
/usr/local/lib/python2.7/site-packages/solc/main.py:129: in compile_files
    **kwargs
/usr/local/lib/python2.7/site-packages/solc/utils/string.py:91: in inner
    return force_obj_to_text(fn(*args, **kwargs))

E Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
E std::exception::what: std::exception
E [dev::tag_comment*] = Compiled contract not found.

But when the DateTime contract was embedded inside myContract.sol file, I was able to call DateTime date = new DateTime(); from myContract contract without having any problem. I have used following approach: How to call a Contract from an existing contract approach.

myContract.sol:

contract myContract{
   DateTime date = new DateTime(); //works now.
   <Some_Code>
}
contract DateTime{
   <Some_Code>
}

[Q] I have tried this approach on Solidity Browser and it works. How could I fix this problem on Populus?

Some information:

platform darwin -- Python 2.7.12, pytest-3.0.2, py-1.4.31,
pluggy-0.3.1
plugins: populus-1.1.0
OS: Mac OS X

solc --version: the solidity compiler commandline interface
Version: 0.4.8+commit.60cc1668.Darwin.appleclang

Thank you for your time and help.


texts:
I want to register a name in ENS, but I have only done it from MyEtherWallet because everything is built-in.

But now I want to use an address I have in Mist. It is possible to register a name in ENS (Ethereum Name Service) from Mist Wallet?


texts:
I am trying to learn and understand how ICOs and the smart contracts used in them work and I am having a hard time understanding the following:

Take for example ParagoinCoin, you can see here that it has several phases (Early Bird at Presale, Presale, Early Bird at Crowdsale and Crowdsale) which have discounts on the token's price and a minimum purchase amount, as well as dates for these phases.

Now looking at the contract source code here, I see absolutely nothing related to those phases, discounts or minimum purchase amounts.

How does this works? Where are those values controlled? Is it done with different contracts? is it controlled via some DAPP, maybe with the Ethereum Wallet?

I'm sorry if these things are obvious for some of you, I'm completely new to this and I have to say it is all quite overwhelming. Links to good resources about this are very welcome too, it's hard to find pertinent info about this at the moment.


texts: when are ethereum fees the lowest? Do they ever drop at a high rate?

texts: "Can  the prcies ever really drop ?Not a dollar but actually in terma of more then just a dollar or two ? a noticable rate? I know the less traffic the less gas but isthere any other ways to wrok-aound this ? maybe supply my own rates? i just think that the gas fees are quite crazy relative to other exchanges and currencies , why is that"?


texts:
I'm having problem with Parity wallet. I've been trying to use it for ICO's as I can set the block number before hand.

I did try to buy BAT-tokens. I accidentally sent some before the block when it started. And it didn't go through, it went to the blockchain and gave this " Warning! Error encountered during contract execution [Bad instruction] "

After that I set up the it to go through on the right block and set 3 000 000 gas. When the block came, it didn't go to the blockchain and it says "pending". All the other transfers are also "pending" and don't show up in etherscan. I'm loosing my patience with parity. What's wrong?

I was able to receive, but it wont broadcast.

Thank you in advance.

Johan


texts: Modify in-place an array received as function argument

texts:
I have a function that performs some operations on an array:
function foo(uint256[] myArray) public
I would like this function to apply operations on myArray in-place. I tried to specify storage in the argument declaration but the compiler requires it to be declared as memory or calldata.
Is it possible to modify in-place an array fed to a function?


texts:
I complied my code in remix and went to run to test some functions. The functions that populated are accessible but I cannot see all of the functions. For example, _mintTitle() did not populate and there is no button or input field in remix for this function. There are others missing as well. I would like to try to call the functions as a command by typing them at the bottom but that doesn't work either.

    function _mintTitle(string _labName) private {}


texts: Is there way to parse leveldb to get transction trie of a given block?

texts: I see a couple of example on Internet about how to parse state trie from leveldb , is it possible to parse transaction trie and transaction receipt trie.


texts:
My Contract Source
https://gist.github.com/munggo/ed25afb0aff9169a6c57f1d464d13177

Convert contract arguments to ABI-encoded format
How???


texts:
I am trying to create a client that signs its own transactions.

To keep it simple, I have stripped everything that is not absolutely required from the example code. Hence the hard coded private key and addresses and gasLimit.

this function demonstrates the transaction:

import Tx from 'ethereumjs-tx';

export const executeTx = (web3) => {
    let privateKey = "fff7b3e0508db1b9059c7542e6287c5ff8013413dd9ced1ca50dc86916c0f353";
    let nonce = web3.toHex(web3.eth.getTransactionCount('0x77454e832261aeed81422348efee52d5bd3a3684') + 10000);

    var rawTx = {
        nonce: nonce,
        gasPrice: web3.toHex(web3.eth.gasPrice),
        gasLimit: web3.toHex(22000),
        to: '0xc347f6b2613e02f5d676f0cdc3215035cca4ecb1',
        from: '0x77454e832261aeed81422348efee52d5bd3a3684',
        value: '0x12',
        data: undefined,
    };

    let tx = new Tx(rawTx);
    tx.sign(Buffer.from(privateKey, 'hex'));
    let signedTxString = tx.serialize();

    web3.eth.sendRawTransaction('0x' + signedTxString.toString('hex'), function (err, hash) {
        if (err) {
            console.log(err);
        } else {
            console.log('transaction hash is', hash);
        }
    });
}

the result of this function is a transaction hash and no error. In the log of my local geth node I can see a strange entry which explains why the transaction does not actually result in a transfer:

Tx(127f1a8ecb09f2380b54f9facd5b4102b3b9d1907065661ebc59cad6531fec22) to: &c347f6b2613e02f5d676f0cdc3215035cca4ecb1

notice the & instead of the usual 0x at the beginning of the to address and the missing 0x at the beginning of the Tx value.

This is the log entry for a successful transaction:

Tx(0xa711dfdc9c74b4de63bf9de272fb693507f4566bababfb0550aecb6f5a9c2181) to: 0x196f3a37dc3c7b378f504201545971e9d9b3d466

for completeness, here is a version of the code that uses eth-lightwallet to do the same thing and strangely enough with the same result.

import {signing} from 'eth-lightwallet';
import {keystore} from 'eth-lightwallet';
import {txutils} from 'eth-lightwallet';
import W3 from 'web3';

export const executeTxLW = () => {
    let provider = new W3.providers.HttpProvider('http://localhost:8545');
    let web3 = new W3(provider);

    let privateKey = "fff7b3e0508db1b9059c7542e6287c5ff8013413dd9ced1ca50dc86916c0f353";
    let nonce = web3.toHex(web3.eth.getTransactionCount('0x77454e832261aeed81422348efee52d5bd3a3684') + 10000);

    keystore.createVault({
        password: 'ppp',
        seedPhrase: "address wealth torch panel aspect brief edit found invite dumb build neither",
        salt: "jpOdt6rKmZuEEKWDVhdFLaudYweyck+6fZPjJSzRcgc="
    }, (err, ks) => {
        if (err) {
            console.log(err);
            return;
        }

        ks.keyFromPassword('ppp', (err, pwDerivedKey) => {
            if (err) {
                console.log(err);
                return;
            }
            ks.generateNewAddress(pwDerivedKey);
            console.log(ks.getAddresses()[0]); //should be 0x77454e832261aeed81422348efee52d5bd3a3684

            var rawTx = {
                nonce: nonce,
                gasPrice: web3.toHex(web3.eth.gasPrice),
                gasLimit: web3.toHex(22000),
                to: '0xD0362fa02fE45367fd7b5fd126ee94a42a57D779',
                from: '0x77454e832261aeed81422348efee52d5bd3a3684',
                value: web3.toHex(web3.toWei(1, "ether")),
                data: undefined,
            };

            let rawTxString = txutils.valueTx(rawTx);
            let signedTxString = signing.signTx(ks, pwDerivedKey, '0x' + rawTxString, '0x77454e832261aeed81422348efee52d5bd3a3684');

            web3.eth.sendRawTransaction('0x' + signedTxString.toString('hex'), function (err, hash) {
                if (err) {
                    console.log(err);
                } else {
                    console.log('transaction hash is', hash);
                }
            });
        });
    });
}

could this be an issue with geth?


texts: Difference between the way methods are called in smart contract

texts:
What is the difference between

 instance.totalSupply() vs instance.methods.totalSupply().call()

To my knowledge one is for truffle and the other is for web3.
But truffle also uses web3 then why can i not call the functions in a single way?


texts:
I am attempting to launch a private geth chain with the following command:

geth --datadir=./test-private-blockchain/ init genesis.json

I am receiving the following error:

Fatal: Failed to write genesis block: unsupported fork ordering: eip150Block not enabled, but eip155Block enabled at 0 genesis block

{
  "config": {
        "chainId": 4777,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "difficulty" : "0x400",
  "extraData"  : "",
  "gasLimit"   : "0x7A1200",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}


texts: How to call contract method from specific address and private key without Metamask check

texts:
Good morning,

I need to known how call contract method in javascript from specific address(and relative private key) without the check of Metamask.
I explain better.

This is an example of js code, it works but every time i call the method, Metamask ask the check and i need to iterate this function.

func: function() {

  App.contracts.Bidder.deployed().then(function(instance) {
    return instance.addBid(1, 10, 1, { from: address });

So I ask if there is a way to do this automatically inserting the private key in the code like the address.

This is for a local blockchain with truffle and ganache.

Thanks.


texts: Searching for a value in a dynamic array

texts:
I understand that for loops on dynamic arrays are a big no no in Solidity, so I am trying to find an alternative to this problem.

Goal:

From a dynamic array of numbers, I am trying to extract the index of the element that is "closest" to another number (number). In JavaScript terms, this would look like:

let number = 21;
let closest;
let array = [5, 10, 15, 20, 25]; // using fixed size as an example, but array could be 1000+ in length
for (let i = 0, i < array.length, i++) {
  let difference = Math.abs(number - array[i]); // remove integer sign for comparison
  if ( !closest || difference < closest )
    closest = i;
  }
}

Looking through Solidity docs and other questions here, it seems that this may be an extremely gas expensive task with no alternative.

Is there another way of looking at this problem with a Solidity hat on?


texts: Direct and separate funds into two different payable functions

texts:
Basically I have this code where I'm trying to divide a specific amount of ether into two different function calls within the contract.

function singleTransaction(arg1) payable {
   require(msg.value == 1 ether);
   buy.value(msg.value / 2)(buy_arg); // diff function in contract
   subscribe.value(msg.value / 2)(subscribe_arg); // diff function in contract
}

But I'm getting this error on migration:
TypeError: Member "value" not found or not visible after argument-dependent lookup in function (uint256) - did you forget the "payable" modifier?

I found a different stack exchange article suggesting the format I've posted, so not sure where to go from here.

Truffle v5
Solidity 5.0


texts: How ethereum nodes sync with each other?

texts:
Ethereum network is essentially a distributed replicated database where each node is a replica and a "master" one.

What happens when user submits a new transaction? It is submitted to some "pending transactions pool" which is synced with other nodes (since it's possible to see pending transaction on etherscan). Which protocol is used to sync this information?

Then transaction is included into a block and mined and it becomes a part of a blockchain and it's imported by a client. Which protocol is used by nodes to exchange most recent blocks?


texts: How to return the funtion value using the contract instance which was deployed previously?


texts:
Example:

address public owner;

Also, if we don't make a variable public manually, what is the default, private?


texts:
just trying my first steps in ethereum and web3. So i found this tutorial:
https://www.youtube.com/watch?v=hcTPjpPvas8
But it raise an error:
index.html:85 Uncaught TypeError: TheContract.at is not a function
at index.html:85
Here is my code:
var TheContract = new web3.eth.Contract([
    {
        "constant": false,
        "inputs": [
            {
                "name": "_fName",
                "type": "string"
            },
            {
                "name": "_age",
                "type": "uint256"
            }
        ],
        "name": "setInstructor",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "getInstructor",
        "outputs": [
            {
                "name": "",
                "type": "string"
            },
            {
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }
    ]);

    //var AdressContract =  TheContract.at("0x5fd16b1Fac5835F744061ED2B92a83864aB75688");

    var theContractAt = TheContract.at('0x5fd16b1Fac5835F744061ED2B92a83864aB75688');
    console.log(theContractAt);

I guess, because the upper case in contract is also new to the new version of web3, that the .at() function changed... but I just cant find how they changed.


texts:
Using web3 to connect to a geth's node rpc API, is there a way to detect when a block has been mined by a specific node? The only way I've found so far is to redirect the node's console output to a file and parse that file. Is there a better way?

FYI - All the nodes are mining to the same public address so I can't use the miner property of a block.


texts: difference between deploy a contract(e.g. truffle migrate) and new a Contract

texts:
Let's say now we have this:

Fatory.sol:

import "./Contract.sol";
contract Factory {
  address[] newContracts;

  function createContract (bytes32 name) {
    address newContract = new Contract(name);
    newContracts.push(newContract);
  }
}

Contract.sol:

contract Contract {
  bytes32 public Name;

  function Contract (bytes32 name) {
    Name = name;
  }
}

then we can deploy this two contracts like this:
2_deploy_contract.js:

var Factory = artifacts.require("./Factory.sol");
var Contract= artifacts.require("./Contract.sol")
module.exports = function(deployer){
  deployer.deploy(Factory);
  deployer.deploy(Contract,['Contract 1"]);
}

then we deploy this two contracts by :

truffle migrate

after that we can interact with the smart contract through web3js, for simplity:

var factory = contract(factory_artifacts);
factory.deployerd().then(function(inst){
  inst.createContract('Contract 2", {from: web3.eth.accounts[0]});
});

1). what's the difference when I call "deployer.deploy(Contract,['Contract 1"]);" through truffle migrate and " inst.createContract('Contract 2", {from: web3.eth.accounts[0]});" through web3js

2). where are they stored, I mean the bytecodes I deployed and the "instance" I created: 'Contract 1' and 'Contract 2', are they stored in the same place

3). instead of deployer.deploy(Contract,['Contract 1"]); how about if deployer.deploy(Contract); without calling the construction function, is it ok, if ok, then what's the difference again with and without calling construction when deployment?


texts: Demonstrate immutability in an Ethereum blockchain

texts:
I am currently using a private Ethereum setup with 3 nodes. As part of the demo of my project, I need to demonstrate that Ethereum is immutable.

How do I show it using geth?

The audience of my project also includes many people not involved in technical side. How do I demonstrate immutability of Blockchain to them?


texts:
I have had problems with Ethereum Wallet for a couple weeks. It started after not synching for a while due to travelling. When I got back online, it needed to sync a lot and it got really slow. After a few days I kept getting errors that it couldn't connect without anything more in the logs. I read somewhere that I had to remove the chaindata and let it sync from scratch. Have done that, but after syncing to near completion, I still couldn't see the content of my wallet (confirmed that it holds coins on etherchain.org) and it slowed down. When I restarted the wallet I got the following error:

  Unable to connect. Please start geth with the following options:

  geth --rpc --rpccorsdomain "file://"

  Optional add: --unlock .

* I have no idea how this would be done. CLI? from where?

I'm using Windows 10/Ethereum Wallet 0.8.10 and have had no significant problems before (besides the ones that disappear upon a restart).

This is all very frustrating. I have a significant amount of money in my wallet and even though I plan to keep it that way the idea that my money is inaccessible is not fun. How can I fix this? I'm completely stumped as to what I can do more. Are there any other offline wallets I could move to and how (since I'm pretty much locked out of the Ethereum Wallet software)? Thanks for your suggestions and time in advance.


texts: Head of blockchain fall back to 0 after unsafe shutdown, how to reset it to the latest?

texts:
System information

Geth version: 1.8.27
OS & Version: Linux
Docker version: 18.09.0

Background

gcmode is full, syncmode is fast. Single node in private network. datadir mount to docker volume.

Problem

I restart the docker so that geth quit unsafely

sudo service docker restart

When I restart the geth, the latest block become 0.

eth.blockNumber
> 0

it was 140000, so 140000 minded blocks are missing.
However, I still can get data of old blocks

eth.getBlock(140000);
> {data of this block}

So it looks like blocks still exist but the head of chain reset to 0.

Questions

1 Does full gcmode cause this issue?

2 Is there a way to reset the head? I tried

debug.setHead("0x222E0");

but nothing happen.


texts:
I'm attempting to copy the same concept as used in the ENS registrar contract like line 355:

    // Creates a new hash contract with the owner
    Deed newBid = (new Deed).value(msg.value)(msg.sender);

Coming from a C# background I basically don't understand anything about this statement.

The Deed contract is in the same file at line 24

(new Deed) when the Deed contract has a constructor - how does that work and why is it in brackets? I expected it to be new Deed(someAddress)
What is the .value(msg.value)?  Is this supposed to set the deed.value property?
How is .value(msg.value) a function so you can append (msg.sender)? And was is that is that doing?
An assumption is the that other properties in the deed contract are set to their default values. e.g. uint public creationDate will be 0?
Finally, it appears as though ENS is deploying each of these deeds at separate addresses - Does this line do this, or is that done somewhere else?

Sorry, I totally don't get it, but need a simple explanation about everything in this line except for the fact that in the end the variable deed is a Deed contract where I presume I could get the previousOwner property with:

address addr = deed.previousOwner;

Thanks.


texts: When sending a transaction to a contract does the sender beforehand know the ID that will be assigned to the transaction?

texts: I need some ("Proof-able fair") randomization inside a contract, I was thinking of using the Transaction ID, but can the client before sending the contract know what the Transaction ID is going to be?


texts: contract reading array from other contract

texts:
There are two contracts in my project:

admin groups
voting

Admin groups contain

mapping(uint => address[]) internal m_Admins

For example

[1][0] = admin #1 with level 1
[9][0] = admin #2 with level 9,
[9][1] = admin #3 with level 9,
etc.

Also contract contains a simple field

address[] internal m_AdminsList

which pushes on the end or removes by index a specific admin - it's just same as mapping but expressed as a list.

And voting, when it starts, I would like to send the array of admins that are allowed to process voting. The reason is when a new admin is added during active voting I would like to not allow him to give vote. I want him to be able to vote only the new voting.

How can I make a function that sends array of admins to voting contract? I can make two functions with admins count and get admin by index, but this might be gas expensive to perform a loop...


texts: Generate random address for ERC20 Token deposit and consolidation?

texts:
I'm trying to implement a mechanism to generate random addresses for users to deposit ERC20 tokens and then consolidate the deposited tokens to a cold wallet address later, somewhat like what an exchange does when users deposit tokens to exchange addresses. Right now it seems I have two options:

Generate a new address for each user (with random private keys or with an HD wallet scheme). After a user deposit tokens to the generated address, we need to first send some ether as gas to the address, then call the token method to transfer the token back to our cold wallet.
Generate a new contract address for each user with a master address. After a user deposit tokens to the generated address, we call the contract with the master owner address to withdraw the token to our cold wallet.

Both methods seem to have their own caveats, as for generating a new normal address for each user, when consolidating we need to first calculate the ether required as gas, and send ether to that address, and then call the token contract to transfer the tokens, which is quite convoluted and need two transactions meaning spending gas twice.

For generating a new contract address for each user, it means for each new user we need to spend gas to create the new contract, which could be a waste if there are many users that don't deposit tokens.

I'm wondering if anyone has any idea what's the standard procedure used by those top exchanges nowadays, how do they handle the gas fees when consolidating ERC20 tokens to cold wallet and withdrawing the ERC20 tokens?


texts: Smart Contract Design: Escrow/Controller contract

texts:
How would I go about creating follow:  Escrow/Controller contract A which is capable of accepting ERC20tokens from contract B, and ETH from party C and do a swap when certain conditions are met.

This same contract A should also be able to receive ERC20tokens from contract D and ETH from contract E and do a swap when certain conditions are met.

The catch/relevancy of the question is, how to design contract A to be able to handle ERC20token inputs of different kinds e.g. Walton(WTC) & FUSION(FSN) ERC20 tokens?


texts: Error installing cpp-ethereum in homebrew

texts:
I am getting this error when attempting to install cpp-ethereum in homebrew. Not sure where to begin...please help!

/Users/Macbook/projects/ethereum
==> brew install cpp-ethereum
==> Installing cpp-ethereum from ethereum/ethereum
==> Cloning https://github.com/ethereum/webthree-umbrella.git
Updating /Library/Caches/Homebrew/cpp-ethereum--git
==> Checking out branch develop
Synchronizing submodule url for 'evmjit'
Synchronizing submodule url for 'deps'
==> cmake -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/cpp-ethereum/1.2.5 -DCMAKE_BU
==> make
Last 15 lines from /Users/Macbook/Library/Logs/Homebrew/cpp-ethereum/02.make:
cd /tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/evmjit/libevmjit && /usr/local/Library/ENV/4.3/clang++   -DETH_EVMJIT -DETH_FATDB -DETH_FRONTIER -DETH_TRUE -DSHAREDLIB -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -Devmjit_EXPORTS -I/tmp/cpp-ethereum-20160529-9027-27dkja/libethereum -I/tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/include -I/tmp/cpp-ethereum-20160529-9027-27dkja -I/tmp/cpp-ethereum-20160529-9027-27dkja/include -I/tmp/cpp-ethereum-20160529-9027-27dkja/gen -I/usr/local/include -I/tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/gen -I/tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/evmjit/include -I/usr/local/opt/llvm37/lib/llvm-3.7/include -I/tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/evmjit/libevmjit/gen  -std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion -Wno-unknown-pragmas -std=c++11 -fpermissive -fno-rtti -fvisibility=hidden -O3 -DNDEBUG -DETH_RELEASE -fPIC   -Wall -Wextra -Werror -Wno-unknown-pragmas -fPIC -fstack-protector-strong -fstack-protector -Wno-unused-function -Wno-dangling-else -o CMakeFiles/evmjit.dir/Cache.cpp.o -c /tmp/cpp-ethereum-20160529-9027-27dkja/libethereum/evmjit/libevmjit/Cache.cpp
clang: : : : erroerrorerror: error: : error: ununknown argument: '-fstack-protector-strong': known argument: '-fstack-protector-strong'
unknown unknown argument: '-fstack-protector-strong'
: unknown argument: '-fstack-protector-strong'
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/BasicBlock.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/Cache.cpp.o] Error 1
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/Array.cpp.o] Error 1
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/JIT-c.cpp.o] Error 1
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/Arith256.cpp.o] Error 1
make[2]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/JIT.cpp.o] Error 1
make[1]: *** [libethereum/evmjit/libevmjit/CMakeFiles/evmjit.dir/all] Error 2
[  2%] Built target ethereum_BuildInfo.h
[  2%] Built target cpp-ethereum_BuildInfo.h
make: *** [all] Error 2


texts:
I have this code to get whole transacctions
public Task<TransactionModel[]> GetTransactionsAsync(bool sent = false)
{
return Task.Run(async delegate
{
var transferEvent = standardTokenService.GetTransferEvent();
            var paddedAccountAddress = DefaultAccountAddress.RemoveHexPrefix()
                                             .PadLeft(64, '0')
                                             .EnsureHexPrefix();

            var filter = transferEvent.CreateFilterInput(
                new object[] { sent ? paddedAccountAddress : null },
                new object[] { sent ? null : paddedAccountAddress },
                BlockParameter.CreateEarliest(),
                BlockParameter.CreateLatest());

            var changes = await transferEvent.GetAllChanges(filter);

            var timestampTasks = changes.Select(x => Task.Factory.StartNew(async (state) =>
            {
                var log = (EventLog<TransferEventDTO>)state;

                var block = await web3.Eth.Blocks.GetBlockWithTransactionsByNumber.SendRequestAsync(log.Log.BlockNumber);

                return new TransactionModel
                {
                    Sender = log.Event.From,
                    Receiver = log.Event.To,
                    Amount = (decimal)log.Event.Value,
                    Inward = false == sent,
                    Timestamp = (long)block.Timestamp.Value
                };
            }, x));

            return await Task.WhenAll(timestampTasks).ContinueWith(tt => {
                return tt.Result.Select(x => x.Result).ToArray();
            });
        });
    }

And it produces this Error: Nethereum.JsonRpc.Client.RpcResponseException: 'data types must start with 0x'
This exception only occure in this method, and i don't know why becasue i configured right my
const string CONTRACT_ADDRESS = "0xcfa31a040d2d389e34490b637ef116714e759329";


texts: How can I use a hash function to generate a value from an interval?

texts:
So I have a contract that will generate a hash and use that hash as a source of randomness. Now I want to generate a number in a certain interval, which should be evenly distributed.

If the hash (keccak256) that I use is 'random' enough, I could just perform a modulo operation.

I am not sure whether keccak256 is good for that purpose and I also don't know how I can perform the modulo operator on bytes32 data.

Is it good? And how can I get my number from that data?


texts: Array of items vs mapping+array of ids with web3js?

texts:
In most articles they recommend to use mapping. But mappings don't allow to iterate their items directly. And nobody says what to do if you need to get all the stored items.

In my case I need store any items and then display them in web like cryptokitties. Note: they are able to dislay all the items.

So what should be better - storing all the values as array or storing all the values as mapping and store ids for them as array? And what case is better for "paging"? Maybe are there other solutions?


texts: how to to check the expiry in the contract?

texts:
In the ethereum contract, I want to make sender to send some eth to the contract, the receiver can receive the eth in a limited time(ex, 100 seconds), after the expiry, if the eth is still not received by the receiver, the contract will return it to the sender.

The simple code is shown below, however I don't know how to implement the refund, which will automatically check and return the eth to the sender. Can the contract evm has a timer to check on a schedule?

  function create(address _sender, address _receiver)  external payable
   {
            _sender = _sender;
            _receiver = _receiver
            _expiry = block.timestamps + 100;
            number = number + 1;
            Created(0x01);
    }

  function accept(address _receiver,uint32 _value) external {
     require(_expiry > block.timestamps);
     _receiver.transfer(_value);
  }

  function refund(){

  }


texts: Web3: Sending a signed serialized transaction throws an error: rlp: expected input list for types.txdata. Please help

texts:
I am feeding a signed serialized raw transaction to sendRawTransaction of web3. The problem is that whenever I call sendRawTransaction it throws an error:

rlp: expected input list for types.txdata.

I have read stuffs about RLP but I can't seem to fully understand it. I am using web3@0.20.6 because we cannot use the beta version just yet. Help is very much appreciated thank you!!


texts: Why Ethereum can't talk to other blockchains?

texts: I've heard that Ethereum can't talk to other blockchains (if I understand it correctly). What does it mean and what is the reason behind this?


texts:
I would like to run truffle tests from IntelliJ.

I found a tutorial here: https://charterhouse.github.io/2017/05/12/running-truffle-unit-tests-in-intellij-idea.html

Unfortunately, it does not seem to work anymore.

The blog suggest using -r truffle/cli truffle test but truffle/cli does not exist in my case.

Is this something that was working before and has changed?

Can anyone suggest how to do this?


texts: What is the correct format to pass array data into a solidity function call for processing?

texts:
I have deployed this contract to answer questions on a quiz on ethereum:

https://ropsten.etherscan.io/address/0x2bf81e36060f2c4eb858e1212315f58a6f2cbc78#code

I submit my answers passing in this data

  ["1", "gas", "truffle", "ganache", "solidity", "metamask"]

and I get this error:


texts: Why is there a limit to number of validators?

texts: In Casper and consensus-by-bet, validators make bets, and converge on a block at each block height, etc. In the Casper PoCs so far, the number of validators at any given block has been limited to 250, or 4000 (in the mauve paper). What are the technical reasons there is a limit?


texts: Contract transaction couldn't be found after 50 blocks in Kovan

texts:
When deploying contracts on the ledger I faced with issue

  Error encountered, bailing. Network state unknown. Review successful
  transactions manually. Error: Contract transaction couldn't be found
  after 50 blocks

Quick research brings insight it might be caused by not synchronised state between node and the ledger.  Just waiting for right block.

Kovan console doesn't represent such data. How I can see what blocks right now processing and where is my tx in this pipeline?  Do you have any other thoughts?


texts: How to get the token-balance of an external token in my contract

texts:
I'm building a token contract with a sell and buy function. User should be able to buy my token not only for eth but also for another token, that I define. Therefore I need the balance mapping of the external token in my contract. I've tried:

contract externalToken {
   function transfer(address receiver, uint amount){  }
   mapping (address => uint256) public balanceOf; }

and in my buy function:

...

amount = externalToken.balanceOf[msg.sender] / buyPrice;

...

But it shows this error:

  Indexed expression has to be a type, mapping or array (is function (address) returns (uint256))
              if (exchangeToken.balanceOf[msg.sender] < buyPrice) throw;

How to do that right?


texts: Truffle-contract error on deployed contract

texts:
Playing around with the gnosis multisig, using truffle-contract to interact with already deployed MultiSigWallet using truffle migrate.

Contents of the file I am trying to run:

var contract = require('truffle-contract');

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

var fileData = fs.readFileSync('./build/contracts/MultiSigWallet.json');
var jsonData = JSON.parse(fileData.toString());

var myContract = contract(jsonData);
myContract.setProvider(provider);

myContract.deployed().then(function(instance) {
        var deployed = instance;
        return deployed.address;
})
.then(function(result) {
        console.log(result);
})
.catch(err => {
        console.log(err);
});

When I run using node, get error:

TypeError: Cannot read property 'apply' of undefined
    at Provider.sendAsync (/home/delphi/MultiSigWallet/node_modules/truffle-contract/contract.js:24:36)
    at RequestManager.sendAsync (/home/delphi/MultiSigWallet/node_modules/truffle-contract/node_modules/web3/lib/web3/requestmanager.js:80:19)
    at Object.get [as getNetwork] (/home/delphi/MultiSigWallet/node_modules/truffle-contract/node_modules/web3/lib/web3/property.js:116:33)
    at /home/delphi/MultiSigWallet/node_modules/truffle-contract/contract.js:512:27
    at new Promise (<anonymous>)
    at Function.detectNetwork (/home/delphi/MultiSigWallet/node_modules/truffle-contract/contract.js:503:14)
    at Function.deployed (/home/delphi/MultiSigWallet/node_modules/truffle-contract/contract.js:451:19)
    at Object.<anonymous> (/home/delphi/MultiSigWallet/test.js:14:12)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3

The undefined referred to in the error is for myContract.deployed().  I cannot figure out why this is though. Simple console output shows that myContract is not undefined.  Can anyone help me figure out what is wrong?


texts: How to send a token with Ether? (several variants)

texts:
I want to sell my token to users paying by Ether.

Is it a good idea to require the user to pass his wallet (to receive) Ether as the EVM payload?
Or is it needed to have my private key uploaded to the server which does the sales (with the receiving Wallet passed through HTTP(S)) and do the logic in server code?
Or maybe I should send tokens to the same address as the address from which I receive Ether?

Please enumerable all viable possible variants (among enumerated above or other) with their advantages and disadvantages to do it (implementing automatic selling the token with Ether).

A complete or incomplete Solidity code to do the task would be nice.


texts:
I have two ubuntu systems with ethereum installed. I started the node in each system using the following command : -

geth --datadir 'path of node folder' init 'path of genesis.json'
geth --datadir 'path of node folder' --networkid 12512 console

The systems are connected to a local network. The genesis file in both the systems are same. The time is in sync. But when I execute admin.addPeer("enode@ip:port"), I am getting net.peerCount as 0. There was no error while pinging the ip from one system to the other. Executing 'netstat -ntpl' gave the following:

machine 1: tcp6 0 0 :::30303 :::* LISTEN 3423/geth
machine 2: tcp6 0 0 :::30303 :::* LISTEN 3028/geth

Any help is appreciated.


texts: Cannot get value from calling constant function with web3js and Metamask

texts:
I have an extremely basic contract deployed on Ropsten:

pragma solidity ^0.4.16;

contract hypergrowth {
  uint256 public someNumber = 5;

  function hypergrowth() public {}

  function changeNumber(uint256 number) public {
    someNumber = number;
  }

  function getNumber() public constant returns (uint256 someNumber) {
    return someNumber;
  }
}

I use web3js and Metamask to interact with the deployed contract.

I can initialize web3. I can get the primary account from Metamask. But I always get 0 when I call getNumber(). Here are the functions that I use with web3:

function getNumberFromContract(contract) {
  contract.getNumber( (err, res) => {
    console.log(res.toNumber());
  });
}

function setNumberFromContract(contract) {
  contract.changeNumber(10, function(err,res){
    console.log("done");
  });
}

I don't get why I receive 0...I can't even see if setNumber() works.

What do I do wrong?

UPDATE:

I use this code to wait for the getNumber function to execute:

var deferred = new $.Deferred();
  setTimeout(function () {
    deferred.resolve(getNumberFromContract(hyperContract));
  }, 5000);

And still get 0.

UPDATE 2:

This is how I get the contract:

var address = '0xbabd1c95906d4ebec8977a7d0f32410ecba1103f';
var abi = [
  {
    "constant": true,
    "inputs": [],
    "name": "getNumber",
    "outputs": [
      {
        "name": "",
        "type": "uint256"
      }
    ],
    "payable": false,
    "stateMutability": "view",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      {
        "name": "number",
        "type": "uint256"
      }
    ],
    "name": "changeNumber",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "constructor"
  }
];
var hyperContract = getContract(abi, web3.eth.accounts[0], web3);

The getContract function is this:

function getContract(ABI, address, web3) {
  return web3.eth.contract(ABI).at(address);
}


texts: What does block reached canonical chain mean?

texts:
In my geth node I see sometimes on the output the message

block reached canonical chain

I tried googling for the answer but could not find one.  Does anyone know what this means.


texts: Wallet hash signing: how to recover the pair of Big Ints?

texts:
The Wallet interface in github.com/ethereum/go-ethereum/accounts/accounts.go:38 provides a method called

SignHash(account Account, hash []byte) ([]byte, error)

to sign a hash using the private key of an account. The signature is returned as an array of bytes.

However, the wallet contains an ECDSA key for that account and signing with ECDSA typically returns a pair of big.Ints (provided a rand) as implemented in https://golang.org/src/crypto/ecdsa/ecdsa.go?s=4459:4542#L141

How do I recover the two big.Ints from the bytes retuned from the SignHash method ?


texts: In my Parity status screen, it says "best block", followed by a recent block number. What doest that mean?


texts: How to run a permissioned ethereum blockchain?

texts:
As far my understanding to Ethereum, it is public chains.but how can it support permission machnism in detail, even from source code perspective. Can Ethereum be used for establishing private blockchain.

If I want to  test for establishing private chain for private company stock registration instead of mining, meanwhile administrator's permission also need. Would you advice me for doing that. what technology does Ethereum  use for doing that


texts:
1) Is it possible to build another blockchain on top of the Ethereum blockchain?

2) Is making a token on the Ethereum blockchain considered making a another blockchain on top of the Ethereum blockchain?

Thanks


texts: Listen to latest event emitted by smart contract with web3j API in JAVA

texts:
I'm having a smart contract:
pragma solidity ^0.4.21;
contract NodeServie{
    event triggerEvent(address indexed _sender, string randomStr);

    function callEventFunc(string str) public{
        emit triggerEvent(msg.sender,str);
    }
}

Besides, in my java program I subscribe to event:
node1Contract.triggerEventEventFlowable(DefaultBlockParameterName.EARLIEST,DefaultBlockParameterName.LATEST).subscribe(event ->{
            System.out.println("Receive Data from Smart Contract");
        });

these piece of code is only listen to the current latest block. For example before I trigger the callEventfunc() in smart contract, latest block is 200. So inside my java code, the subscribe is only look for block0 to block200 while the emitted Event is in new created block 201.
How can I listen to the actual latest block, without re-run my java program.
Thank you in advanced.
Regards,


texts:
What is the maximum known Ethereum fork length?

What is the maximum Ethereum fork length in theory?

Edit: please read fork length as maximum number of uncle blocks.


texts: how to calculate Ethereum's practical maximum network size?

texts:
What is the largest network size that Ethereum can achieve?
Lets say , the network latency is 50 milliseconds, how many nodes would the network allow to do not surpass the block time of 14 seconds?

If I assume that the network is connected serially then with 50ms latency i can transfer 20 messages in one second. In 14 seconds I can pass 280 messages serially. But Ethereum uses Kademlia protocol, which is like binary search.

Current Ethereum's network has about 100k nodes. With binary search they would have to use 21 time intervals of 50 milliseconds to distribute the block among the whole network.  (I divided 100k by 2 until I got to 1, result is 21) So, the latency to transmit 1 block among network should be theorically of 21*50ms=1 second.

But this is theory. In practice, what is the maximum limitations of Ethereum's network size?


texts:
If I run the command:

$> meteor add ethereum:web3

I get the following error message:

 => Errors while adding packages:

While checking for ethereum:web3@0.18.4:
error: No compatible binary build found for this package. Contact the package author and ask them to publish it for your platform.

Does anybody have an idea what is going on here?


texts: Creating ethereum account during user registration

texts: There is a site with simple registration and user login. How can I create a new ethereum account for each new user and store the keys of these accounts in my database


texts:
This is a function that returns an array of addresses that confirmed for a transactionId.

    mapping (uint => Transaction) public transactions;
    mapping (uint => mapping (address => bool)) public confirmations;
    address[] public ownersArr;

    /// @dev Returns array with owner addresses, which confirmed transaction.
    /// @param transactionId Transaction ID.
    /// @return Returns array of owner addresses.
    function getConfirmations(uint transactionId)
        public
        view
        returns (address[] _confirmations)
    {
        address[] memory confirmationsTemp = new address[](ownersArr.length);
        uint count = 0;
        uint i;
        for (i=0; i<ownersArr.length; i++)
            if (confirmations[transactionId][ownersArr[i]]) {
                confirmationsTemp[count] = ownersArr[i];
                count += 1;
            }
        _confirmations = new address[](count);
        for (i=0; i<count; i++)
            _confirmations[i] = confirmationsTemp[i];
    }

I could understand whats the point of running two loops inside this function when only one loop is sufficient to get all the addresses that confirmed for a transactioId.

    function getConfirmations(uint _transactionId) public view returns (address[] _confirmations)
    {
        for (uint i=0; i < ownersArr.length; i++){
            if (confirmations[_transactionId][ownersArr[i]]){
                _confirmations.push(ownersArr[i]);
            }

        }

    }


texts: Contract deploying but not initializing state variables

texts:
I'm deploying via Remix and Metamask.

I have an intializer function MyToken() { ... } that initializes a few state variables, and calls test(); test(); at the end.

The contract deploys, but none of the state variables get initialized. When I remove test(); test();, it works.

Why could this be? If those two calls to test() produced an error, then wouldn't the contract simply not deploy?

edit

When I deploy to "Javascript VM" rather than "Injected Web3", it works fine.

Just putting one call to test(); works fine; so is it a gas problem? Why is the contract still deploying then?

Also, calling test(); test(); manually (when it is not included in the intializer) works.


texts:
I am trying to use the web3 API through my project in meteor. I saw an example that included web3 the following way:

<script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
...code... </script>

When i run the project i get this error "Uncaught Error: Cannot find module 'web3'". I've already added web3 to meteor withe this command: meteor add ethereum:web3 . What am I missing?


texts: truffle migrate cause "Error: insufficient funds for gas * price + value truffle migrate"

texts:
When I run "truffle migrate" to deploy contract to geth, I got this error: "Error: insufficient funds for gas * price + value truffle migrate".

this is the genesis block of my private chain:

{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "1",
    "gasLimit": "0xfffffffffffffff",
    "alloc":{
            "419746ad0f6de99791821388c9b85c5d85427ba4": {
            "balance": "3000000"
        },
           "3978d4dc7b2d11c9ca40cd9bd24a30dd59cf399a": {
            "balance": "4000000"
        }
    }
}

How can  I solve this problem ?

NB: it works with ganache


texts: Will ethereum.org re-send a presale json wallet if I lost my original and never moved the coins?

texts:
Bought some ether in the presale, received a pdf receipt with my password, transaction id, and future ETH address, but I never did anything with it, never even looked at it again, until now.  I thought saving this info would allow me to repopulate a wallet in the future. Tried a bunch of things and they didnt work so Im wondering:

Can ethereum.org re-send the email containing my json wallet? If anyone has a clue how I can get access to my presale ether now it would be much appreciated since I bought several of them!


texts: What is the 0x I see around Ethereum? For example I see addresses that start with 0x

texts: I see a number of things in Ethereum start with 0x, for example addresses.  Other examples are in the Geth console, JSON-RPC, web3.js.  What is the 0x and what is its purpose?


texts: How can I go about switching from eth to geth while keeping my same accounts?

texts: I'd like to move my accounts from the eth client to geth. Also, I'd like to keep the same addresses. Is this possible?


texts: Test RPC via Node and repeated contract calls

texts:
On the testrpc, I deploy a contract:

myContract.new(....

And it works great.  I get a transaction hash, a transaction reciept, and a contract created address output in the terminal.

But then I close out node (not the testrpc) and then when I restart it and run

web3.eth.getCode(contract_address, function(err, code) { console.log(code);})

I get 0x0

I'm hoping to call that contract again to run functions and call variables.  Anyone have solutions to this?


texts:
If we are to consider the following example, how will Consumer have money to pay the 800 gas necessary for running InfoFeed.feed? By what mechanism is the person calling Consumer.callFeed() charged?

contract InfoFeed {
  function info() payable returns (uint ret) { return 42; }
}
contract Consumer {
  InfoFeed feed;
  function setFeed(address addr) { feed = InfoFeed(addr); }
  function callFeed() { feed.info.value(10).gas(800)(); }
}


texts: How much was BAT (Basic Attention Token) worth in eth / btc / usd during the 1 minute ICO?

texts: What was the value of BAT (Basic Attention Token) during the 1 minute ICO in eth / usd / btc ? I can't seem to find this info anywhere. And what is the total supply?


texts: Etherscan Showing the Crowdvilla Ownership tokens price 0.8754 bt according to CoinMarketCAp the value is $0.07 This is so confusing. And I faced it the first time. Please, someone, answer me if I was wrong.


texts: Can we migrate private blockchain from one aws instance to another?

texts: Right now, I am running my private blockchain on aws ec2(t2.medium) using geth. I am just curious that later on is it possible to upgrade that aws ec2(t2.medium) instance to aws ec2(t2.large) instance? If yes, then What steps I have to follow for that?


texts:
I am currently trying to implement Ethereum's Merkle Patricia Trie using Python 3.6 and I am having some troubles and honestly I am frustrated.

I am using the following sources:

Ethereum Wiki Patricia Tree
Merkling in Ethereum
Understanding the Ethereum Trie - Blog
Understanding the Ethereum Trie - Github Python Code
Trie Test

I do get the concept of the Merkle Patricia Trie (MPT) and how it works. Yet, I am having problems implementing it.

First I would like to know of the example trie is given in Ethereum Witi is correct or not. I feel that it is not correct.

A trie which contains the following key/values pairs: ('do', 'verb'), ('dog', 'puppy'), ('doge', 'coin'), ('horse', 'stallion')

Their result:

rootHash: [ <16>, hashA ]
hashA:    [ <>, <>, <>, <>, hashB, <>, <>, <>, hashC, <>, <>, <>, <>, <>, <>, <>, <> ]
hashC:    [ <20 6f 72 73 65>, 'stallion' ]
hashB:    [ <00 6f>, hashD ]
hashD:    [ <>, <>, <>, <>, <>, <>, hashE, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'verb' ]
hashE:    [ <17>, hashF ]
hashF:    [ <>, <>, <>, <>, <>, <>, hashG, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'puppy' ]
hashG:    [ <35>, 'coin' ]

My result:

rootHash: [ <16>, hashA ]
hashA:    [ <>, <>, <>, <>, hashB, <>, <>, <>, [ <20 6f 72 73 65>, 'stallion' ], <>, <>, <>, <>, <>, <>, <>, <> ]
hashB:    [ <00 6f>, hashD ]
hashD:    [ <>, <>, <>, <>, <>, <>, hashE, <>, <>, <>, <>, <>, <>, <>, <>, <>, 'verb' ]
hashE:    [ <17>, [ <>, <>, <>, <>, <>, <>, [ <35>, 'coin' ], <>, <>, <>, <>, <>, <>, <>, <>, <>, 'puppy' ] ]

Why does it look so different? Right under the example is the following sentence:

When one node is referenced inside another node, what is included is
H(rlp.encode(x)), where H(x) = sha3(x) if len(x) >= 32 else x and
rlp.encode is the RLP encoding function.

Furthermore, I tried to compare the results from my code with the JS MPT implementation and this gives a completely different root hash.

I am wondering, what is correct? Do I misunderstand the example? Are there any other "better" documentation? I appreciate any help.


texts:
I want to define a byte256 and I want to assign different sections of the byte to different variables, any literature or guidance is appreciated.

for further clarity I want to do something like

variable 0 = address
variable 1 = address
variable 2 = value
variable 3 = address
variable 5 = address
variable 4 = address

now Id want to do:

byte50:
    bit 0-10=  variable 0
    bit 10-20=  variable 1
    bit 20-30=  variable 2
    bit 30-40=  variable 3
    bit 40-50=  variable 4

I realize the above may not be correct at all(I'm just trying to give you an idea of what I'm trying to achieve). I would like to know firstly whether its feasible and if so how I should go on about it.

I have no idea how to handle this so I'd appreciate any pointers


texts: Paying a transaction fee with an ERC20 token

texts:
As far as I understand, one of the ERC20 token's features is that you can pay a transaction fee with it.  In other words, you can send them without having Ether. I transferred REP tokens to the exchange and back without using Ether on that exchange so that works.

I suppose that fee goes to miners. Where else?

So someone creates a token that has no value at all, makes a transfer and pays a fee with it, then some miner gets it but he doesn't have any idea what it is.


texts: Is a good practice to use a contract just to store ether?

texts:
Is it a good practice to use a smart contract just as storage of eth with no functionality? Not even locking functionality, just having eth there?

Or in such a case a wallet is the correct practice?


texts: How to get Ether in Ethereum Wallet test network?

texts: How can I get some ether to deploy a smart contract when using a test network (like Ropsten, or Rinkeby) in Ethereum Wallet ? Because at the beginning when creating a new account, I have 0.00 ether like below:


texts: How does mining work in ethereum private test net?

texts:
I'm working on smart contracts and using Ethereum wallet. I have formed a private test net and successfully deployed smart contracts on that network. But, I didn't get how the miner functionality works in this scenario.

Why mining is needed in private network?

Can someone explain me how mining is done in private test net on Ethereum?


texts: Duplicate 'Ocean' ERC20 Token on MEW newest version Token List . How to chose the correct one for Sending to Exchage?

texts:
Need help from expert , please.
I try to send Ocean Token on my Trezor Wallet to Binance . On the MEW list, it show two items with the same Token name .  When select Token to send MEW chose the old Ocean Token (0x985) as default and system give message "Returned error . execution reverted ".  However, I still can process to the end sending stage but  sending will always Fail and chaged some Gas fee of 7-15USD.
I try Create the New Token on MEW as suggested by the Ocean Protocol Blog , It still not work as system said "Token already exist".
Anybody could advice me , how can I choose the new Ocean Token (0x967). Thank


texts: What is the difference between a "call" , "message call" and a "message"

texts: Is a transaction a type of a message? Is message call a call? And which of these results in any state change?


texts: Ethereum - Does it only have a single blockchain?

texts:
I still do not get if ethereum creators want it to be single blockchain or not?
If not, where are instructions for creating my own blockchain to play with?


texts: Geth v1.8.21 slow syncing on archival node

texts:
Geth Version v1.8.21+bionic - stable
Machine -  16GB Ram, SSD, i7 processor

I'm currently in the process of syncing a full archival node on Geth.

Up until recently the chain was syncing fine, around 5/10 blocks every 10 seconds (has been like this for 3 months on v1.8.18+bionic). With the 1.8.21 upgrade the speed went down drastically at the point where it will never finish (1 block every 20-30 seconds).

Geth is installed using ppa repository, which makes it quite difficult to downgrade back to v1.8.18, moreover with the hard fork coming soon, I'll have to upgrade never the less.

Current Size is at ~ 1.6TB @ Block ~ 6,480,000

I have tried using the --cache 1024 however it still defaults to 512 for some reason. Using: geth --cache 1024 --gcmode archive --syncmode "full"

Any suggestions as to what can be done?


texts: Is there a limit on no of the parameters that can be passed to a function?

texts:
I have created a smart contract function in ethereum. I am unable to use more than four parameters to the function.
If a I create a function with more than 4 parameters and call the it by passing arguments , the transaction is getting mined but no event is being triggered and no data is getting saved in the transaction.

Also I am unable to send more than 31 characters per string parameter

So adding gas value while calling the function works. But how do I pre-determine how much of gas I would have to send when calling a function??

P.S. :  I am working on a private block chain and using Nethereum's web3 interface  and geth to deploy and call the smart contract.


texts: Is it possible that the block gas limit will drop below its current level?

texts: As I found here (What is Gas Limit in Ethereum?) and here (The Ethereum gas limit seems prohibitively low. Will it ever be raised? If so, when and how?), the gas limit is gradually growing (as the network grows). But is it possible that it will sometime drop below its current level or even below 3,141,592?


texts: What is the blockchain download size and can i reduce it in some way?

texts:
I am currently on a connection with a download cap, and was wondering what the current download size for the whole blockchain was, and if i could reduce this download size to under 2 GB?

I'm currently using parity.


texts: Should an account be associated with a node

texts:
When i use await web3.eth.accounts.create(); to create a account and write something to smart contract in ganache, i get sender account not recognized.
But I get executed properly when i create an account using await web3.eth.personal.newAccount('password')
I want to create separate account for users and store it in the browser memory of the user using web3.eth.accounts.wallet.save('test');

how to use the account stored in the users browser to write something to the smart contract

Should all the users account be associated with the node (ganache) as it is done while executing personal.newaccount to write something on the smart contract.

If it scould be associated, how to store the account created by personal.newAccount to the users local web3 wallet


texts:
I've got a contract here which works fine for the most part, but there's a problem with the whitelisting of addresses in that it doesn't fill the mapping, or the test array I added (wls) when whitelistAddresses is called. Here's the whitelist functionality, as simple as it gets:

// List of addresses who can purchase in pre-sale
mapping(address => bool) public wl;
address[] public wls;

// ...

function whitelistAddresses(address[] users) onlyOwner external {
    for (uint i = 0; i < users.length; i++) {
        wl[users[i]] = true;
        wls.push(users[i]);
        Whitelisted(users[i], true);
    }
}

If you have a test network set up, you can try deploying it locally (use the flattened IcoFlat.sol file) and seeing for yourself. Function can be called without a problem, but it refuses to do any sort of state change.

I'd like to know what the best way to debug this is. Truffle has been buggy of late (i.e. weird error messages like DocstringParsingError: Doc tag @deprecated not valid for contracts. on deployment) and Remix has been very uncooperative with Metamask with infinitely long connection attemtps and a lot of crashes on all browsers, so I'm looking for help in either solving the problem or finding a tool to use for anaylzing it more thoroughly.


texts: 'ALERT: Trying to call a function on a non-contract address' Why Do I Keeping This Error?

texts:
This is the error from metamask directly:

This is the error I get once after I submit the information to IPFS:

My Smart Contract:

pragma solidity 0.5.3;

//Imports for safe math operations
import "https://github.com/OpenZeppelin/openzeppelin-solidity/contracts/math/SafeMath.sol";

//Defining contract name lika class name
contract IPFSPosting{
  using SafeMath for uint256;

  //This struct is for the properties of a post
  struct Post{
    //Address of owner's Post
    address owner;
    //Hash of an image
    string imgHash;
    //Hash of a image caption
    string textHash;
  }

  //A Mapping list post from Post struct.
  mapping(uint256 => Post) post;

  //A counter for the posts mapping list.
  uint256 postCtr;
  event NewPost();
  //img and text hashes are sent to IPFS and stored
  function sendHash(string memory _img, string memory _text)
    public {
      postCtr = postCtr.add(1);
      Post storage posting = post[postCtr];
      posting.owner = msg.sender;
      posting.imgHash = _img;
      posting.textHash = _text;

      emit NewPost();
    }
  // Function that gets the img and text hashes
  // _index number from total post iteration
  // returns stored images and text hashes
  function getHash(uint256 _index)
  public view returns (string memory img, string memory text, address owner)
  {
    owner = post[_index].owner;
    img = post[_index].imgHash;
    text = post[_index].textHash;
  }
  //Gets the total length of total posts
  // Returns the total count of post
  function getCounter() public view returns(uint256){ return postCtr;}
}

Contract Instantiation

import web3 from './web3';
const address = "0xb8ce805b2f346ead5fa5ea1d9756b10ff46642b8";
const abi =[
    {
        "constant": false,
        "inputs": [
            {
                "name": "_img",
                "type": "string"
            },
            {
                "name": "_text",
                "type": "string"
            }
        ],
        "name": "sendHash",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [
            {
                "name": "_index",
                "type": "uint256"
            }
        ],
        "name": "getHash",
        "outputs": [
            {
                "name": "img",
                "type": "string"
            },
            {
                "name": "text",
                "type": "string"
            },
            {
                "name": "owner",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "constant": true,
        "inputs": [],
        "name": "getCounter",
        "outputs": [
            {
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    {
        "anonymous": false,
        "inputs": [],
        "name": "NewPost",
        "type": "event"
    }
]
export default new web3.eth.Contract(abi, address);

I am using this tutorial as a guide for this smart contract. Mostly everything is similar. Github Guide

If there's anything else you need I can provide more code, but this seems where most of the trouble is being caused. If anyone could help me to figure out what's wrong that'll be great!


texts: Parsing Error while compiling pet-shop tutorial

texts:
I am just getting started with smart contract programming and was trying to implement the pet-shop example as per this tutorial https://medium.com/tomochain/how-to-build-a-dapp-on-tomochain-85532a1192e7. The contract code is as under

pragma solidity ^0.5.0;
contract Adoption {
  address[16] public adopters;
  // Adopting a pet
  function adopt(uint petId) public returns (uint) {
    // check that petId is in range of our adopters array
    require(petId >= 0 && petId <= 15);
    // add the address who called this function to our adopter array
    adopters[petId] = msg.sender;
    // return the petId provided as a confirmation
    return petId;
  }
  // Retrieving the adopters
  function getAdopters() public view returns (address[16] memory) {
    return adopters;
  }
}

compiler throws the following error:
Error parsing /Users/Zubair/pet-shop-tutorial/contracts/Adoption.sol: ParsedContract.sol:1:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
^
Compilation failed. See above.
Truffle v5.0.3 (core: 5.0.3)
Node v10.15.1


texts: What does a user have to provide to be able to retrieve the balance of his account?

texts:
I am building an angular based app with ionicframework. In this app the user shall be able to retrieve his balance of an erc-20 token. Using web3js's web3.eth.getBalance(MY_ADDRESS) i have to retrieve this address and hand it to web3.eth.getBalance(MY_ADDRESS).

Thank you very much for your detailed response!

I think I got a better idea of what an account an its address does. Unfortunately I am not directly included in developing the smart contract code and cannot provide it.
I want to display an accounts balance of my token in the app. Thereafter I want to implement a voting system. Currently I plan on sending the public address as identifier, his balance and some information (what he is voting for) to a database.

I am simply not sure what this public address is and if I can be sure the user is going to what to enter if I simply prompt him to enter his "address".

Do you have different addresses for each erc-20 token?

Can one account have different addresses?

Do you need to have an account for each erc-20 token?

Is my general approach correct?

Any feedback appreciated and thanks in advance!

EDIT: I currently am planning to let the user enter a public address.


texts:
I'm working with a private chain. Sometimes after trying to create a contract it gets stuck spitting out this over and over:

I0616 15:17:12.778089   32745 http.go:157] Sending payload: [
    {
        "id": 9355,
        "jsonrpc": "2.0",
        "result": []
    },
    {
        "id": 9356,
        "jsonrpc": "2.0",
        "result": []
    },
    {
        "id": 9357,
        "jsonrpc": "2.0",
        "result": []
    },
    {
        "id": 9358,
        "jsonrpc": "2.0",
        "result": []
    }
]

The id keeps updating, all the rest says the same. This happens very quickly and the contract never seems to get mined.


texts:
I'm a beginner of ethereum.
I have seen some solutions.
I can use sendRawTransaction to transfer costumed tokens from one account to another account.
But my boss asked me to use ERC-20 "transfer" method.(not to use"web3.eth.sendRawTransaction")
I'm using infura & Web3 0.20 version & ropsten testnet, running in the back-end(node.js).(I don't want to run in the front-end)

pragma solidity ^0.4.24;
function transfer(address _to, uint256 _value) returns (bool) {
  balances[msg.sender] = balances[msg.sender].sub(_value);
  balances[_to] = balances[_to].add(_value);
  Transfer(msg.sender, _to, _value);
  return true;
}

  Blockquote

var Web3 = require('web3');
const testnet = 'https://ropsten.infura.io/';
const web3 = new Web3(new Web3.providers.HttpProvider(testnet));

var contractABI = [.....{"constant":false,"inputs":
[{"name":"_to","type":"address"},
{"name":"_value","type":"uint256"}],"name":"transfer","outputs"
 [{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable",
 "type":"function"}.....]

 var contractAddress = '0x9A6...';
 var contract = web3.eth.contract(contractABI).at(contractAddress);

 // transfer 100 tokens form 0xD0A88... to 0x36c90...
 contract.transfer.call("0x36C90...",
 100*Math.pow(10, 18),{from: "0xD0A88..."},
 function(error, txHash){
 console.log(txHash);
 });

Running and "console.log(txHash)" return "true".
But I saw etherscan didn't have this transaction, and tokens also didn't be transferred.
How can I revise it?(Web3 0.20 version)


texts: Is there a maximum number of public functions in a contract?

texts:
I have two contracts A and B, both deploy and work correctly in ganache (they both use less than 6M gas). Now I want to create a third contract C that inherit both A and B.

contract C is A, B {
}

This contract C fails to deploy with out of gas exception. But gas should not be an issue because ganache is configured with a block gas limit of 4 billion.

After trial and error commenting out my code, I found it fails with a public function in contract B. After reordering functions I found it doesn't matter which function in particular, it will fail if there are more than N public functions in contract B.

Update: Trying the deploy the same contracts in a geth private testnet causes the error "oversized data". So I think is not the number of public functions but the resulting contract is too big.


texts: Where can the parity blockchain files be found?

texts:
On my Mac I am looking for the Parity blockchain file for the ropsten chain.
I checked the following locations:

~/.parity and
~/.local but both directories don't exist.
~/.ethash contains 1gb sized files but neither I am certain if these files contain the blockchain nor which one represents the ropsten chain.


texts: Why is there more than one payable function in a solidity contract?

texts:
When someone transfers ether to a contract address the payable callback (without name) function is called automatically.
What I don't understand is why are there many examples with multiple payable functions ? Are all of them automatically called?
Why do they have to be payable and why don't I call them normally from the callback function?

In my examples I noticed that if I have only one payable function and it has a name, the contract can't receive ether so it is somehow not automatically called but only if the payable function has no name. Is that normal or did I do a mistake?


texts: Which mode shoud I use for Parity syncing to use trace_ APIs for TXs since current blocks?

texts:
I want to use Parity for fast tracing TXs in blocks which will be synced only after my project start.

So, if I initially run my Parity node with params —pruning=archive —tracing=on the synchronization process will be veeeeery long.

May I make an initial sync to current block with —fast (—warp) param an then restart node in an archive mode with tracing from current time?


texts:
I recently registered to  Infura and trying to connect to the Ethereum Mainnet using the command below ({MY_PROJECT_ID} is swapped for my actual project id)

curl -H 'Content-Type: application/json' \
>       -X POST \
>       -d '{"id":1, "jsonrpc": "2.0", "method": "eth_getBalance","params":["0xfe05a3e72235c9f92fd9f2282f41a8154d6d342b", "latest"]]}' \
>       ropsten.infura.io/v3/{MY_PROJECT_ID}

It times out and outputs the following error here: https://gist.github.com/Genysys/6bbb8eb6415cd3c6c6b591dee741db91

I have tried other networks but run into the same issue.

I would be appreciative of any pointers on this


texts: Who generates the mathematical problem for miners?

texts: In POW miners solve an problem for successfully mining a block, who provide the question to the miners ?, does all miners work on same problem ?, and how the miners verify the answer ?, if the problem is generated by the client(geth) then isn't it a vulnerable ?, you could tamper the problem complexity.


texts: How to open multiple terminals using docker?

texts:
Here I am trying to create private ethereum instance using dockerfile. I want to open two terminals and run command1 in terminal1 and execute command2 in terminal2 only when command1 returns true.

Commands are shown below:

  Command1: geth --verbosity 4 --port 3000 --networkid
  --datadir=/ethereum --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth, net, web3 ,personal, admin, db,mine"

  Command2: geth attach /ethereum/geth.ipc

But I couldn't get any document related to this. Please help me to resolve this issue and any help will be appreciated.


texts:
I am trying to sync my node with testnest rpc with following command.
geth --testnet --syncmode "fast" --rpc --rpcapi db,eth,net,web3,personal --cache=1024  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"

But it is just stuck after starting a localhost server. Here is the screenshot of my terminal.

When i try to sysnc with just geth command its syncing fine. Anyone having idea what's wrong here?


texts:
I exported the private key from Metamask and wants to import it into geth. geth is running on Windows 10.

geth is started using

  geth --rinkeby  --rpc --rpcapi="personal,eth,network,net,web3" --rpcport 8545 --rpcaddr 127.0.0.1 --unlock "0xcede48d8ac162d1b08ed9419010de3c99f2cfdd6" console

this prompts me to enter the password

Unlocking account 0xcede48d8ac162d1b08ed9419010de3c99f2cfdd6 | Attempt 1/3
Passphrase:
Fatal: Failed to unlock account 0xcede48d8ac162d1b08ed9419010de3c99f2cfdd6 (no key for given address or file)

Why is it failing to unlock the account even though the password I entered into geth is the same password that was used to export the private key from Metamask?


texts: Function execution right based on external contract state, ballot and proposal example

texts:
i'm building a sample application which require voting.
I think it needs to be split into 2 contracts where the owner of Ballot will create Proposal contracts.
Splitting simply because the logic is got too complex to be clearly understandable in a single contract.

Question: what is the proper way to let only the contributors from Ballot contract vote for proposals.

My implementation - simply a call to Bellot to check if the address is in contributors. I've read that there are a lot of security flaws in interacting between 2 contracts(since i'm new to solidity might not know all details), so i want to verify if this is correct solution.

Ballot

contract Ballot {
    address public manager;
    mapping (address => bool) public contributors;

    Proposal[] proposals;
    mapping(address => Proposal[]) proposalsByAddress;

    constructor(address _creator) public {
        manager = _creator;
    }

    function createProposal() public {
        Proposal memory newProposal = new Proposal();
        proposalsByAddress[msg.sender].push(newProposal);

        //to be able to returl all porposals later
        proposals.push(newProposal);
    }

    function checkIfContributor(uint address _address) public view returns (bool) {
        require(proposalsByAddress[msg.sender]);

        if (contributors[_address]) {
            return true;
        } else {
            return false;
        }
    }
}

Proposal:

contract Proposal {
        Ballot ballot;
        bool complete;
        uint approveCount;
        uint rejectCount;
        mapping (address => bool) voters;

        constructor() {
            ballot = new Ballot(msg.sender);
        }

        function vote(bool _vote) {
            require(ballot.checkIfContributor(msg.sender));
            require(!voters[msg.sender]);

            voters[msg.sender] = true;
            if (_vote) {
                approveCount++;
            } else {
                rejectCount++;
            }

        }
}


texts: How to reset the length of array in solidity v6.0?

texts:
The code gives the following error in solidity v0.6 compiler but works fine with compiler v0.5:

TypeError: Member "length" is read-only and cannot be used to resize arrays.
nodes.length = 0;

pragma solidity >=0.4.22 <0.7.0;

contract TestNode {
    uint[] nodes;

    function createNode(uint data) public {
        nodes.length = 0; // This line gives the ERROR
        nodes.push(data);
    }

    function pushNode(uint data) public {
        nodes.push(data);
    }

    function getNode() public view returns(uint[] memory) {
        return nodes;
    }
}

How to convert the code that works with solidity v0.6?


texts: truffle migrate fails when I remove console.log

texts:
I have this migration script:

var MyTok = artifacts.require("./MyTok.sol")
var MyTok_Crowdfund = artifacts.require('./MyTok_Crowdfund.sol')

module.exports = function (deployer, _, accounts) {

    var kycSigner = [],
        wallet = accounts[1],
        startTime = web3.eth.getBlock('latest').timestamp,
        endTime = startTime + (86400 * 30), //30 days
        price = 18000

    // console.log("DEBUG: \nstart Time: " + startTime + "\nend Time: " + endTime)
    deployer.deploy(MyTok).then(function() {
        return deployer.deploy(MyTok_Crowdfund, kycSigner, MyTok.address,
          wallet, price, startTime, endTime)
    })
}

Which does not work, unless I uncomment the console.log line.
This suggest me I should somewhat wait for the web3.eth.getBlock call, but I can't figure out how.


texts: Watch pending transactions with ethjs.js

texts:
I am trying to use ethjs.js to listen to pending transactions, but nothing really worked. Does anyone have a working example fetching pending transactions with ethjs.js?

I have tried the following:

https://github.com/ethjs/ethjs/blob/master/docs/user-guide.md#ethnewpendingtransactionfilter

https://github.com/ethjs/ethjs/blob/master/docs/user-guide.md#ethfilter

Thanks!


texts: Ropsten Node finally synchronized after 3 days: why a blockchain testnet should be so difficult?

texts:
I have started a new Ropsten Node running on a Pi4 4GB.
Here is the relevant information for those who might want to start a new Ropsten Node:

more than 3 day syncing
$ geth --ropsten --datadir /mnt/ropsten --cache 2048
SSD 250GB mounted on /mnt/ropsten, connected through Pi4's USB3.0 (tested speeds read/write > 350MB/250MB), for all Ropsten Node's files
$ df -hT => 85GB disk space used
"Imported new state entries" processed = 263.974.548 (29Oct2020) this is the most important number to watch for (to know how close your Node is to be in sync)... ;-)
"Imported new state entries" pending = 0 finally...
on console > eth.syncing yields "false" => in sync ;-)
eth.currentBlock => 8.975.055

Now my question is: why should it be so difficult to start a TESTnet blockchain?
Is it really necessary to be so difficult (time consuming)?


texts: Send signed transaction hash to the network

texts:
The Parity native signing app takes the hash of a transaction and signs this has with a private key, derived from a seed phrase. Below is the corresponding code from signer.js:

let account = getState().accounts.selected
let hash = getState().signer.hashToSign
let seed = await decryptData(account.encryptedSeed, pin)
let signature = await brainWalletSign(seed, hash)

The signature is then displayed as a QR code.

Can this signature be used to send the transaction to the network? If yes how would this be done in code?

Note: the signature is created from the hash of the transaction, not the transaction, and so does not contain the transaction details. Can the signature and the transaction data be combined somehow?


texts: Passing struct types to libraries by reference, internal and external calls

texts:
I need some clarification on internal and external library calling in relation to whether a struct is passed by reference or copied or something else.

In this following library example, L_i() is internal, is compiled into the derived contract's bytecode and called by jump.  The struct parameter _s is passed by reference and so _s.i will be updated contract wide (so to speak).

library lib_internal {
    struct LStruct { uint i; }
    function L_i (LStruct storage _s) internal {
        _s.i++;
    }

In the following external instance, and this is where I need help, is _s still passed by reference but within the context of the contract or is it copied in the DELEGATECALL data to L_i()?

library lib_external {
    struct LStruct { uint i; }
    function L_i (LStruct storage _s) public {
        _s.i++;
    }


texts: web3.isConnected() returns false when connecting to geth with web3.js

texts:
I am totally new to cryptocurrency stuff. I have installed geth and web3. I want to build a web page showing account balance. I start geth with below command

build/bin/geth --rpc  --rpcaddr 127.0.0.1 --rpcport 8545 --rpcapi web3,db,eth,net,personal

[ec2-user@ip ethereum]$ curl http://127.0.0.1:8545
[ec2-user@ip ethereum]$ curl http://127.0.0.1:8545
[ec2-user@ip ethereum]$ sudo netstat -nlp | grep :8545   tcp        0      0 127.0.0.1:8545              0.0.0.0:*                   LISTEN      18238/build/bin/get

My code in stest.html is:

<script src="web3.js/dist/web3.js"></script>
<script>
if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
  //var web3 = new Web3('http://localhost:8545'); // TypeError:   this.provider.send is not a function
}
console.log(web3); // {eth: .., shh: ...} // it's here!
if(!web3.isConnected()) {
  console.log("fail");
} else {
  console.log("succ");
}
//var coinbase = web3.eth.coinbase;
//var balance = web3.eth.getBalance(coinbase);
//console.log(web3.eth.accounts);
var version = web3.version.api;
console.log(version); // "0.2.0"
var version = web3.version.node;
console.log(version);

I get the below errors in the browser console when I run stest.html:

Object { _requestManager: {…}, currentProvider: {…}, eth: {…}, db: {…}, shh: {…}, net: {…}, personal: {…}, bzz: {…}, settings: {…}, version: {…}, … }
stest.html:13:1

fail

0.20.5

Error: CONNECTION ERROR: Couldn't connect to node http://127.0.0.1:8545.
web3.js:3118:16

Source map error: request failed with status 404
Resource URL: http://34.215.167.9/plugins/ethereum/web3.js/dist/web3.js
Source Map URL: web3.js.map

Below is the info I got from the terminal:

[ec2-user@ip go-ethereum]$ build/bin/geth version
Geth
Version: 1.8.0-unstable
Git Commit: 722bac84fa503199b9c485c1a3e2bfba03bc487d
Architecture: amd64
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8.4
Operating System: linux
GOPATH=
GOROOT=/usr/lib/golang

Sorry for the question format. I wanted to add as info as possible. Please edit question or ask for more info.
How can I avoid the "Connection Error?"
Is this method of connecting to Ethereum correct?
How can I improve my code?
I have tried a few questions here, but no answers resolve my error.

UPDATE:
Now CURL gives result after starting with below geth command

build/bin/geth --rpc --rpccorsdomain "http://localhost:8545"

$ curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' http://127.0.0.1:8545
{"jsonrpc":"2.0","id":67,"result":"Geth/v1.8.0-unstable-722bac84/linux-amd64/go1.8.4"}

But in browser console error changed to

ReferenceError: Web3 is not defined


texts: Encountered during contract execution [Reverted]

texts:
When trying to sent some ETH from myetherwallet getting followinf error:

 Warning! Error encountered during contract execution [Reverted]

transaction links:
https://etherscan.io/tx/0xad2aacfeb5c23d192b9f4bd5e9b402962012c61f0bc16a3a9902e10dd4ea8675
https://etherscan.io/tx/0x241ba9fc1fc75a87afe70767b99276a1fa4ea72c1da6a6b4eb155d2800d6a251

contract code - https://etherscan.io/address/0x37d82a4e03e93529c1a32429984e12e7875ea1d8#code

It this due to issue in code ?


texts: What's the equivalent of Vyper's create_forwarder_to in Solidity?

texts:
In Vyper, there's a built-in function called create_forwarder_to, which

  Duplicates a contract’s code and deploys it as a new instance, by means of a DELEGATECALL.

If my understanding is correct, what create_forwarder_to does is:

Choose an existing contract instance A.
Deploy a new contract B that will behave the same as A by delegatecalling A's functions whenever there's an incoming function call to B.

The size of bytecode of B can be extremely small, since it's not deploying A again but deploying a forwarder contract that utilizes A's bytecode.

Here is an example of a forwarder contract in Uniswap, and you can see how the forwarder contract is deployed in the factory contract of Uniswap. (create_forwarder_to was called create_with_code_of before and got renamed in this release.)

How can I do what create_forwarder_to does with Solidity?


texts:
https://github.com/ethereum/go-ethereum/wiki/Management-APIs

  {"method": "personal_sign", "params": [message, account, password]}

The param message is a hex string, how can I generate it from a tx?

What I want to ask is, if I have a tx, for example: {from:0x1234,to:0x4321,value:xxxx,gas:xxx,gasPrice:xxxx}

How can I generate the message?

I try to find a sample of it but got nothing.
Hope someone can give an example.
Very thanks.