texts: How does the SafeMath library of OpenZeppelin protect your code from integer overflow?

texts:
Sorry for the newb question. I am reading the SafeMath code and it seems that it just does some multiplications and calculations?

How do you use it to protect your code? Do you just import it?


texts: Passing 13 arguments in function giving error: Stack too deep, try using less variables

texts:
I am trying to pass 13 arguments as string and creating a structure with them. But I am getting error: Stack too deep, try using less variables.

My code:

struct Test {
// 13 string variables... }

function myfunc(13 string parameters...){
      Test t = Test(13 parameters...); // have to initialize t
}

Any possible solution to the problem ?


texts: Non-interactive transactions with Web3 interface

texts:
would like to build a blockchain simulator with web3 interface.
I use ganache and solidity.
my simulator is a microgrid simulator (autonomous energy community) where a house is represented by an eth address (with ganache)
However, as soon as I make a transaction or interact with a contract, a metamask notification appears.
is it possible to remove this notification in order to run my simulator which will proceed to multiple transactions without the user having approved these transactions.

Thank’s for response


texts: How do I set the constructor arguments when deploying using OpenZeppelin CLI?

texts:
My Token contract compiles fine using solidity 0.5.0:

import "/Users/lennard/Desktop/GGToken/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
import "/Users/lennard/Desktop/GGToken/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol";
import "/Users/lennard/Desktop/GGToken/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";

contract GGToken is ERC20Capped, ERC20Detailed, ERC20Burnable {

    constructor (uint256 cap)
        ERC20Detailed("GGToken", "GGT", 18)
        ERC20Capped(cap)
        public {
            _mint(msg.sender, 10000);
    }
}

When I deploy this contract in Remix I get the option to set a constructor argument:

When I try to deploy the same contract using OpenZeppelin CLI's npx oz create I don't see this option, and it throws error: Invalid number of parameters for "undefined". Got 0 expected 1!

How do I set this constructor argument using OpenZeppelin CLI?


texts:
For EIP1155 standard the current implementation means you are supposed to have 1 base uri and then the metadata for the token is inferred from the tokens ID.
Example of such a URI: https://token-cdn-domain/{id}.json
So no matter the token type in EIP1155 they all have the same base uri.
My question was that is it possible to have different uri's for each token type. So something that looks like this?
https://token-cdn-domain/{token-type-id}/{id}.json
While preserving the EIP1155 standard. Since it's URI getter function okay accepts a single param.
  /**
 * @dev Returns the URI for token type `id`.
 *
 * If the `\{id\}` substring is present in the URI, it must be replaced by
 * clients with the actual token type ID.
 */
function uri(uint256 id) external view returns (string memory);

It seems EIP1155 is not as flexible as EIP721 in this case.


texts: Ropsten light node block number ~1000 greater than it should be

texts:
I'm running geth on Ropsten, using
geth --ropsten --syncmode "light" --http.addr localhost --http.port 8545 --rpc
My most recent block number is 10266786 (and increasing), whereas etherscan.io says 10265079 and  others confer something within that range of etherscan. About an hour ago, my block number was also 10266000 < n < 10267000, though etherscan and others showed somewhere in the range 10264000 < n < 10265000. I'm fairly new to ethereum. Is somebody sending malicious blocks to light nodes in the Ropsten testnet? Or is there an easy fix to this?


texts: Token Contract Verified and Signed on Mainnet Does Not Show MINT Function

texts:
The Token Contract Address https://etherscan.io/address/0xa2e7a0d1cfeda4d3977277265e205f6092d02e3b was successfully tested on Ropsten (See Ropsten Contract Address 0x82Bc5871e30FB2C00A3E5B5E6475A2baD88978ba).
Now exactly the same contract has been deployed, verified and signed on Mainnet , However I am unable to interact with the main functions, specifically with the MINT Function.
Etherscan Helpdesk tickets #120001 and #120314 have been opened and I have interacted with Mr./Ms. Raja C, but he/she has not been able to address/resolve the problem.


texts: JavaScript console on Parity: unable to unlock account. Error: Method not found

texts:
How to open the JavaScript console on Parity? guide us to open a console for communicate with Parity.

Inside the console I was not able to unlock my eth.account using personal.unlockAccount(). I faced with following error: Method not found.

personal.unlockAccount("0x75a4c787c5c18c587b284a904165ff06a269b48c")
Unlock account 0x75a4c787c5c18c587b284a904165ff06a269b48c
Passphrase:
Error: Method not found

[Q] How could I prevent this error from error happening in order to unlock my eth.account successfully?

How I run Parity:

parity --chain parity.json --network-id 32344 --reserved-peers myPrivateNetwork.txt --jsonrpc-apis web3,eth,net,parity,parity_accounts,traces,rpc,parity_set,personal -ludp=debug,tcp=debug,sync=debug --author "0x75a4c787c5c18c587b284a904165ff06a269b48d"

Please note that java console sees personal.

> personal.  //press tab
personal._requestManager personal.constructor personal.getListAccounts personal.listAccounts personal.lockAccount personal.newAccount personal.sendTransaction personal.sign personal.unlockAccount

Thank you for your valuable time and help.


texts:
I have few mining parity on docker container in AWS instances.
Each AWS instance have private and public IP.
When I ask "parity_enode" it return enode address with private IP. I want it use public IP. Can I?

The reason use public IP is that nodes can not connect each other over private IP, only by public IP.

It seems I can do this by add all other nodes in bootnodes config.toml , but it will be better if they use public IP.


texts:
I was mining on my own pool with open-ethereum-pool.
Now I had mined and I have Pending Balance on my account there.

How can I payout it? When I make ./build/bin/open-ethereum-pool payout.json which has the payout config from config.json

It says No payees that have reached payout threshold

But I don't know why. Minimum Payout is 0.5 and I have 10.0 in the account. So the minimum is reached.


texts: I am new to ethereum. I have some knowledge about the fundamentals. What would be the best starting point for gaining more knowledge?


texts: Real address of myetherwallet. How to know?

texts:
I am going to use

https://myetherwallet.com/

However, is that the real address?

How do I know it's not phishing?

Any phissing site will be like that too right?


texts: Geth miner has 0 hashrate on private chain even with coinbase addr set and miner.start() called

texts:
I have a multi-node private chain and recently had to switch the networkId and the ChainID in the Genesis block to match in order to obey Metamask's requirements.

Now that I have made those changes and redeployed, it worked fine for me locally, but my Dockerized Geth nodes are not able to "Successfully sealed a new block" but is able to "Commit new mining work".
Below is the following Dockerfile:

FROM ethereum/client-go:v1.7.2

RUN mkdir -p /root/myChain/
WORKDIR /root/myChain

COPY Genesis.json /root/myChain/

RUN geth \
    --identity "myChainNode" \
    init \
    --datadir "/root/.ethereum/myChain/" \
    "/root/myChain/Genesis.json" \
    --ipcdisable \
    --mine --autodag --networkid 777 --nat "any" --gasprice "3000000"

EXPOSE 30303
EXPOSE 8545

ENTRYPOINT geth \
    --identity "myChainNode" \
    --datadir "/root/.ethereum/myChain/" \
    --ipcdisable \
    --networkid 777 \
    --rpcapi eth,web3,net,personal \
    --rpc --rpcaddr "0.0.0.0" --rpcport "8545" \
    --rpccorsdomain "*" \
    --nat "any" \
    --port "30303" \
    --etherbase "<myPublicAddress>" \
    --ws --wsport "8546" --wsaddr="0.0.0.0" --wsorigins "*" \
    --mine \
    console

When I miner.start() or miner.start(8) the response is null
I am connected to peers in my private chain and my hashrate is still 0.

AWS has the appropriate 30303 and 8545 ports open for my EC2 running it.

My local node is mining beautifully and it's run script looks like the following:

sudo geth \
    --identity "myChainNode" \
    --datadir "~/Library/Ethereum/myChain" \
    --ipcdisable \
    --etherbase "<myPublicAddress>" \
    --networkid 777 \
    --rpcapi eth,web3,net,personal \
    --rpc --rpccorsdomain "*" \
    -rpcport "8545" \
    --verbosity 3 \
    --ws --wsport "8547" --wsorigins "*" \
    --mine \
    console

Any thoughts?


texts: How to get liquidity of a coin traded on a DEX?

texts:
Let's take WBNB / SNOWDOGE pair.
I know, thanks to api.pancakeswap.info/api/v2/pairs, that the liquidity of the token pair is BNB 169 or SNOWDOGE 102356.
{
  "base_address": "0x00514d3057E8d2d1f4d9D8aDF358FA5B61a89E4B",
  "base_name": "SNOWDOGE",
  "base_symbol": "❄",
  "base_volume": "455189315425177.907993399014311871",
  "liquidity": "102356.5401368347882626626526498501",
  "liquidity_BNB": "169.9525546159748748702221776516506",
  "pair_address": "0xc63558660734a242E230B422c6a6e5e6F6ADaA5F",
  "price": "2.44128279e-12",
  "quote_address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
  "quote_name": "Wrapped BNB",
  "quote_symbol": "WBNB",
  "quote_volume": "78.982724993986055396"
}

However, how do I pull this information using web3js?


texts: Accessing dynamic variable name - external contract

texts:
Contract A wants to call an external contract B/C/D/E/F but the variable name is different within each contract B/C/D/E/F, and contract A does not know the variable name for B/C/D/E/F at the start.
---Contract A---
function callExternal(address _externalContract, string _variableName) public {
  interface(_externalContract)._variableName
}

---Contract B---
uint256 public variableName;

---Contract C---
uint256 public aDifferentVariableName;

One route is to go through storage slots, but that assumes that each contract will have the same ordering of storage slots.  How can I look up specifically the passed in string on another contract.


texts: Transfer ownership of a contract in the constructor

texts:
I'm trying to create a contract, and set its owner at the same time

contract ERC721CrowdSale is Ownable { ... }//contract is in the same file and has access to methods

contract CS_Creator is Ownable{
  ERC721CrowdSale _cs;

  function create_crowdsale(string _name, address _wallet, uint256 _token_goal) onlyOwner returns(address){
      address _new_crowdsale = new ERC721CrowdSale(_name,  _wallet,  _token_goal);
      transfer_CS_ownership(_new_crowdsale, _wallet);
      return _new_crowdsale;
  }

  function transfer_CS_ownership (address _new_crowdsale, address _wallet)  internal {
     _cs = ERC721CrowdSale(_new_crowdsale);
    _cs.transferOwnership(_wallet);
  }
}

this creates the crowdsale, but in remix i get an error when i try any methods on the crowdsale

transact to ERC721CrowdSale.(fallback) errored: Cannot read property 'length' of undefined

I just need a convenient way to transfer the ownership of the crowdsale to the wallet address.  Right now they are all owned by CS_Creator


texts: access mapping inside mapping of struct in Solidity ^0.5.0

texts:
I have a contract which looks like this:

contract a {
    struct Str {
        uint256 totalTokens;
        mapping(address => uint256) playerTokens;
    }

    mapping(uint256 => Str) public tokenStores;
}

now assume that we have defined tokenStores as public and a getter method will be automatically allocated, is it possible to access a particular playerTokens
value using a key from javascript? Any workaround possible in Solidity ^0.5.0 ??


texts: Trying to iterate through an array to send signed transactions results in one failure and one success

texts:
I'm trying to iterate through an array of address/key pairs and send a transaction from each one. When I do this on testrpc with an array of the account info for two different accounts, one transaction succeeds (ie I get the transaction information, both in the console log and in my ganache-cli) and the other fails (returns an empty error, no transaction hash).

Can anyone tell me what I'm doing wrong? Here's my code:

var Web3 = require('web3');
var web3 = new Web3(new
Web3.providers.WebsocketProvider("ws://localhost:8545/"));
const Tx = require('ethereumjs-tx');
var numWallets = 0;

wallets.forEach(function(account) {
  var addr = account.address;
  var key;
  web3.eth.getBalance(addr).then( (result) => {

    web3.eth.getGasPrice()
    .then((gasPrice) => {
      var gasLimit = 25000;
      web3.eth.getTransactionCount(addr).then( (nonce) => {
        var nonce = nonce.toString();
        addr = account.address;
        key = account.key;
        key = key.slice(2);

        var rawTransaction = {
          "from": addr,
          "nonce": web3.utils.toHex(nonce),
          "gasPrice": web3.utils.toHex(gasPrice),
          "gasLimit": web3.utils.toHex(gasLimit),
          "to": destinationAddr,
          "value": result - (gasPrice * gasLimit),

        };

        var privKey = Buffer.from(key, 'hex');

        var tx = new Tx(rawTransaction); // This object has the same output in both iterations

        tx.sign(privKey);
        var serializedTx = tx.serialize();

        var transaction = web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
        transaction.on('receipt', receipt => {
            console.log(receipt);
            numWallets++;
            if (numWallets == wallets.length) {
                // further logic
                console.log("finished iteration");
            }
        });
        transaction.on('error', console.log);
});


texts: Contract Execution Completed But Transaction Failed


texts: Calling another contracts function -minimum info required

texts:
I understand how to call another contracts function. My question is, if I want to use an interface like in this question over call(): Call function on another contract

contract Name {
    mapping(address=>string) public text;
    string public test;

    function register(string _text) {
        text[msg.sender] = _text;
    }
}

contract Proxy {
    address watch_addr = 0xEB1e2c19bd833b7f33F9bd0325B74802DF187935;
    address user_addr = msg.sender;

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

I know you don't need to have the function definition so having only this from Contract Name would work fine:

contract Name {
    function register(string _text) {}
}

What if contract Name had other functions defined in it too? Would the interface contract being used need to implement all the functions in contract Name, or only the function being used by the Proxy contract?

Also if the function we wanted to call from contract Name had a modifer, say onlyOwner, would the interface version need to too?

Thanks for any help.


texts: Mapping primary key of each struct in array to them-self

texts:
pragma solidity ^0.4.17;
contract Campaign{
    struct Transaction {
        address Creditor;
        uint Amount;
    }
    Transaction[] public Transactionss;
    mapping(address => Transaction) public TransactionsMap;

    function addTransaction(address _address,uint _amount) public {

        Transaction memory newRequest = Transaction({
           Creditor: _address,
           Amount: _amount });
        Transactionss.push(newRequest);
        TransactionsMap[_address]=Transactionss[Transactionss.length-1];

    }
    function Testing()public {
        addTransaction(0xaef0B7Edd5D2E9315027ADFA4642E16a5c85Afd8,100);
        TransactionsMap[0xaef0B7Edd5D2E9315027ADFA4642E16a5c85Afd8].Amount++;
    }

    function a()public view  returns (uint){
        return TransactionsMap[0xaef0B7Edd5D2E9315027ADFA4642E16a5c85Afd8].Amount;
    }

    function b()public view  returns (uint){
        return Transactionss[0].Amount;
    }

}

Running function a  will give 101.

Running function b  will give 100.

Why?   How to fix it?


texts: How is the market cap calculated of tokens traded on DEX like Pancakeswap?

texts:
Let's start with two an example contract 0xD52B599F88A0dD095DD07dd7d98ea965192C3F2a.
If you look at Poocoin or Bogged, both of them show market cap as:
$7,415,949,681,815,443,000,000,000,000,000,000,000,000,000,000,000,000,000
Safe to say that this cannot be true.
What's the formula behind it and how can it be done better?


texts: How to resync your time of private ethereum network?

texts:
Solidity has special keywords now to return current timestamp.
solidity documentation on Globally available variables.

uint timestamp = now; //should return current date.

With the help of Ethereum Date and Time tools contract I can obtain followings:

getYear(uint timestamp) constant returns (uint16)  //Given a unix timestamp, returns the DateTime.year value for the timestamp.

getMonth(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.month value for the timestamp.

getDay(uint timestamp) constant returns (uint16)   //Given a unix timestamp, returns the DateTime.day value for the timestamp.

getHour(uint timestamp) constant returns (uint16)  //Given a unix timestamp, returns the DateTime.hour value for the timestamp.

getMinute(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.minute value for the timestamp.

getSecond(uint timestamp) constant returns (uint16) //Given a unix timestamp, returns the DateTime.second value for the timestamp.

I am working on my private ethereum network. The problem is only the returned hour is 2 hours behind than my server's time. I have used following answer's (https://ethereum.stackexchange.com/a/9790/4575) guide to update my server's time.

sudo ntpdate -s time.nist.gov

Also on populus, returned date is wrong for all variables such as year returned 2014 (it should be 2017), month returned as 9 (it should be 1), day returned as 17 (it should be 7) and so on.

[Q] How could I update private blockchain's date that timestamp should updated with an accurate time?

Thank you for your valuable time and help.


texts: Is it normal for a DAI vault to cost between $80 - $160 in gas fees?

texts:
I am trying to open a Vault for the first time with ETH-A as collateral.
Do the below fees make sense? They seem quite expensive to me ...

Additionally I see this:


texts: How to find out what happened with a contract transaction

texts: I have a question regarding one transaction which happened at the 17th of January 2018: https://etherscan.io/tx/0xabe5ac6176e1096bf4fbfa983cb8b04262ae1d57daf94ebb1668b5d45e3145f4 It should be transferred to my Blockchain Wallet 0x64f81834474FadF5A0AEd6C1e70C9B3b8300A1D3 but I cannot see it there. I remember that I used MetaMask for some ICOs back then but cannot really find out what happened with the 2.57 ETH. How to find out what happened with the money? Can you please help me to solve that riddle? Thanks in advance.


texts: Why does a signed transaction include a "hash" field?

texts:
When signing a transaction using the go-ethereum library, the resulting object looks something like this:

"tx": {
        "nonce": "0x7",
        "gasPrice": "0x77359400",
        "gas": "0x5208",
        "to": "0x9ea773969b2622a0a361fd137b088f90f88bd82f",
        "value": "0x7a120",
        "input": "0x",
        "v": "0x47a",
        "r": "0x1944717416cde8sa47ed607325bfb85a40618da4a6dab9c6e1636609612deddd",
        "s": "0x5480b689ffbab6o7dc58ae5d04369c3841a4fcbc95edecf7cf8608b9bf818e9c",
        "hash": "0x997d39754493fee0581985667s89874a83c8d93b29e0e8802831781b140b87d2"
    }

The way I understand the transaction verification process is that the Public key, the Hash of he transaction and the signature's r, s, v values are all used to verify that the transaction was indeed signed by the user's Private key.

What I can't seem to understand is why does the signed transaction object often include a "hash" field e.g. https://web3js.readthedocs.io/en/1.0/web3-eth.html#signtransaction

i.e. my assumption would be that if you are veryfiying against the provided hash, then you're not really veryfying anything (the hash could be compromised). My understanding is that you always want to hash the transaction yourself in order to verify that this is indeed the correct hash which has been signed by the user's private key.

What am I missing?


texts: Should I upgrade to the latest go-etherum before the Constantinople upgrade activates at Block #7280000? If I do not upgrade, will it affect my node to do transactions?


texts: How does a private network take advantage of new EIPs

texts:
Say, I setup a private network using geth. My genesis config is made aware of ByzantiumBlock and all nodes (tx & miners) are all happy and healthy.

Now Constantinople release is on the horizon. How could my running network take advantage of new features available in Constantinople?


texts: What happens to transactions in orphaned/forked blocks?

texts: From my investigation and reading a lot about this, it seems like the transaction is just removed and the ether returns back to some address. With Bitcoin, orphaned blocks are initially accepted by the network, but will be rejected once a longer blockchain is received that doesn't include the block. Is the same thing true in Ethereum?


texts: Is there a SetTimeout function in Solidity?

texts:
Essentially, is there a SetTimeout in Solidity?

creationTime = now;

lastBlockNumberA = block.number - 1;

first = lastBlockNumberA;

if(now >= creationTime + 1 days){
  lastBlockNumberB = block.number - 1;
  second = lastBlockNumberB;
  if(first == second){
     doSomething();
  }
}

function doSomething(){ };

Assuming a block has been mined over the course of the time period, does first == second? Does the doSomething function fire?

Preferably, is there a way to wait (x) number of blocks before running the if statement? I would like to wait a certain number of blocks (or time) before I get a new lastBlockNumber- is it even possible (without invoking the contract again - just from the one contract invocation, in this example 1 day ago).

From my tests it would appear as though the invocation of a contract does not allow for functions/if statements within it to be called (x) units of time or blocks in the future, without having to invoke the contract again, is that correct? If not, how would one do that?

I found this:
https://solidity.readthedocs.org/en/latest/common-patterns.html#state-machine

It talks of stages, but does one have to interact with the contract to perform the stage 'guard tests' or do these happen automatically regardless?


texts: Would "Clearing" Blocks Diminish the Size Of The Blockchain?

texts:
As I understand the EVM has the ability to "clear" or "delete" information from future blocks. However, all older blocks would still contain contract information.

If a sizable amount of information is cleared from future blocks, could this considerably diminish the file size of the blockchain?


texts: Call instance function of a contract from embark console

texts:
I was following this tutorial.I have deployed the following two contracts on testrpc:

pragma solidity ^0.4.7;

contract MDBService {

    mapping (address => address) accounts;
    mapping (uint => address) ids;
    uint numberAccounts;

    function MDBService() {
        numberAccounts = 0;
    }

    function register() {
        require(accounts[msg.sender] == 0); //We check if the user is already registered
        ids[numberAccounts] = msg.sender;
        accounts[msg.sender] = new MDBAccount(msg.sender);
        numberAccounts++;
    }
}

contract MDBAccount {

    struct Post {
        uint timestamp;
        string message;
    }

    uint public numberPosts;
    address public owner;
    mapping (uint => Post) posts;

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

    function MDBAccount(address _owner) {
        owner = _owner;
        numberPosts = 0;
    }

    function post(string message) isOwner() {
        require(bytes(message).length <= 160);
        posts[numberPosts].timestamp = now;
        posts[numberPosts].message = message;
        numberPosts++;
    }
}

Now when I call

MDBService.register({gas:700000,from:web3.eth.accounts[1]})

a new instance of MDBAccount is created(i.e. a new account MDBAccount for the user with address of account[1]).So now I want to post a message from this account instead of the default account[0].

When I call

MDBAccount.post('Hello')

it works because it uses the instance created when the contract deployed.But when I use

MDBAccount.post('Hello',{from:web3.eth.accounts[1]})

it fails because isOwner is not satisfied as it is using the same instance and not the one created on calling the above register.So how can I call post for account[1].


texts: IPFS hash link keep loading without not responding

texts:
I'm trying to add many JSON files in IPFS using the following API from this liberary py-ipfs-http-client, after running locally ipfs daemon:
client.add('item.json')
And here is the output of the item.json file
{"name":"Musk","description":"description","image":"https://ipfs.io/ipfs/QmP8ZD7YrSyPWaU1UnTD9jFR6rwokncCCd3WK7f7eSJi11/0003.jpeg"}
The returned hash for this item.json works successfully, but when I'm trying to add another JSON file that's slightly different from the first one, the output IPFS hash keeps loading for a long time without any outputs.
And here is the output of the second item2.json file
{"name":"Musk2","description":"description","image":"https://ipfs.io/ipfs/QmP8ZD7YrSyPWaU1UnTD9jFR6rwokncCCd3WK7f7eSJi11/0004.jpeg"}
And that happens also many times if I just changed the name of the value with anything other than "Musk".
And when I try with localhost IPFS domain it works http://localhost:8081/ipfs/<hash> but not with the main ipfs link https://ipfs.io/ipfs/<hash>
I need your help to understand this behavior.
Thanks.


texts:
I am trying to create a smart contract where people can send some data as string. This data must be not-visible/not-readable by anyone until a certain date(let's say one month from now)
Have I to set up private this data and after a certain date make it public? Is a private variable readable in any way?

Or have I to encrypt this data?

Thank you very much.


texts: Smart Contracts made on remix IDE are permanently avaialble on etheruem blockchain?

texts: When you develop smart contracts using the remix, we got an address for that contract, I wanted to know does the contracts are permanently available to be used? or they are deleted after the certain time?


texts: Why are ERC 20 transfer(...) gas costs different?

texts:
We have 2 identical transactions, one spends 22409, and the other 37345 gas, why so?

https://etherscan.io/tx/0xaeefbb8aab4fd61fc057b4013f8ca2accd4ed573ec4dcfacc02a1bcfb99cb3f8

https://etherscan.io/tx/0x42071ede01368cd04c621ccbc2197da91302a54da320ee03147bd86e3742cb02


texts: What is the difference between an Ethereum client and Ethereum API?

texts: Pardon me if this is silly, but as per my limited observation, the number of APIs is higher than the number of clients that exist. How are APIs different from clients?


texts: Etherbase ID changed after depositing funds to Mist wallet?

texts:
So it appears that my Mist wallet hadn't fully sync'd to a node, yet it produced a Etherbase ID for me to use.. I dumped the address into Kraken for a withdrawal, and realized after sending things over that the Mist wallet was still looking for peers.. I went to bed and let the wallet sync overnight. Upon waking up the Ether base ID has changed, and the funds aren't received from Kraken.. Are these funds lost forever or stuck somewhere I can get to?

Running Mist on Windows machine


texts: Does the expected average block time for Ethereum 2.0 will change much so that transaction confirmation times can reach sub-seconds on-chain?

texts:
I am trying to Google the answer but cannot find any. What is the expected average block time for Ethereum 2.0 when it comes live (on the mainnet)?

I am aware that there is cabapility to do faster-than-on-chain transactions with Raiden Network, but I hope to be able to do it on-chain.

Average block time will depend on the minig algorithm, and there will be a change in this when transition to PoS happens.

This says:

  In chain-based PoS, the algorithm pseudo-randomly selects a validator
  during each time slot (e.g. every period of 10 seconds might be a time
  slot), and assigns that validator the right to create a single block,
  and this block must point to some previous block (normally the block
  at the end of the previously longest chain), and so over time most
  blocks converge into a single constantly growing chain.

Does this mean the average blocktime will be 10 seconds? (If yes, why not set it to less than 1?)


texts: Unable to deploy contract (2 lines of code) to chain (ETC)

texts:
Anyone know what causes this contract to not deploy on Ethereum Classic?

contract A{
    function b() public returns(uint) {return 4;}
    uint public c = b();
}

Deploying the contract on Ethereum Classic with Remix and Nifty wallet gives the error,

While it works on the application rescue fork of Ethereum,


texts: Since transactions require a nonce that is one more than the previously mined transaction for a given address, what happens if someone sent a transaction with a low gas price that was refused by miners? They would have all subsequent transactions refused unless they were given the same nonce and a more favourable gas price.


texts: Differences/similarities of "Bitcoin script" and "Ethereum smart contract"?

texts:
Can we compare Bitcoin script and Ethereum smart contract ?

And if yes,

What are differences/similarities of Bitcoin script and Ethereum smart contract in sense of functionality, architecture and how to interact with blockchain?

Does Bitcoin script run on-chain (similar to Ethereum smart contracts) or they run off-chain?


texts: Will miners meet the situation that they can not find the nonce？

texts:
Because the Nonce is uint64 in the Golang code. the code is here:

    // Compute the PoW value of this nonce
        digest, result := hashimotoFull(dataset.dataset, hash, nonce)
        if new(big.Int).SetBytes(result).Cmp(target) <= 0 {
            // Correct nonce found, create a new header with it
            header = types.CopyHeader(header)
            header.Nonce = types.EncodeNonce(nonce)
            header.MixDigest = common.BytesToHash(digest)

            // Seal and return a block (if still needed)
            select {
            case found <- block.WithSeal(header):
                logger.Trace("Ethash nonce found and reported", "attempts", nonce-seed, "nonce", nonce)
            case <-abort:
                logger.Trace("Ethash nonce found but discarded", "attempts", nonce-seed, "nonce", nonce)
            }
            break search
        }
        nonce++

and the target is 0~2^256, the nonce is 0~2^64.
so, Is there the possibility that the target is out of the nonce's range, such as only when the nonce is in 2^64~2^256, the target will be satisfied: new(big.Int).SetBytes(result).Cmp(target) <= 0


texts: How to make transactions real-time for Dapps

texts:
I am intrigued how exactly an Ethereum transaction's "state changing" works. I have read about the Bitcoin transactions, and so understand how the basics of validation and propagation through the network work.

What I'm wondering is how you accomplish what feels like real-time updates to your app if the transactions take ~20 seconds to resolve. In that post it was recommended this:

  Typically it's a tradeoff between decentralization + trustless nature vs (partially) centralized + trusted. So the more centralized something is the faster it is typically. Centralized databases are very fast. Decentralized blockchains are "very" slow. So it just depends on what you are looking for. For speed, just use centralized databases. For trustless properties, use Ethereum. And then there are lots of options in-between (for example Ripple, Neo or BigChainDB).

However, I'm wondering if there are any techniques in Ethereum or any other blockchains where you can have sort of a "prevalidated transaction" which is part of a "prevalidated block" or something, such that when you create a transaction, it runs the code immediately, and ends up in some final meta state in the blockchain so you can treat it in your app as if everything was a success. Sort of how in an app like GitHub if your credit card expires, you can still use the service for a month or two and get warnings to update it, until finally it's shut off, sort of like a grace period. In essence, it still lets you perform transactions, without having any gas, and you go into debt so to speak.

Wondering if anything anywhere close to this exists in Ethereum or anywhere else. Something that would allow some sort of near-real-time Dapp. Because transactions and blocks must propagate across the network before they are incorporated into a final block, I can see no way of making it take less than a few seconds to 20 seconds like Ethereum's case. The only way I can see it taking less time is if there is a middle state between having a final valid transaction or block, and having an "in process" transaction or block, sort of thing. Wondering if anything does anything like this, haven't seen it.


texts: Connecting to AWS Ethereum using Putty SSH tunnel

texts:
I created an AWS Ethereum network, and I created a bastion host and I can access the explorer URL and stats URL in a browser successfully.
But I am now trying to curl, like this:
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[]}' http://localhost:8545

But I am not sure how I need to configure the settings in putty to make this work?
Under Connection > SSH > Tunnels I've tried setting forwarded ports to:
Source port: 8545
Destination: localhost:8545
But that doesn't work. I have been stuck trying to figure this out for days and it is driving me crazy. Any advice would be appreciated.


texts: Can I record the Time taken for a transaction to complete in Test Net

texts: I am trying to benchmark the time taken for a transaction to execute, can anybody advise me is there anyway I can record the time taken for smart contract transaction to complete?


texts: Deploying contract via Remix costs less gas than deploying via javascript

texts:
When I launch my contract via remix, it launches with no issues.
When I try to launch the contract via my javascript web3, using the same gas price and gas limit, it fails b/c it ran out of gas.

This was sent by my javascript
https://ropsten.etherscan.io/tx/0x27bc68deb0323086d440df5b1daa5aeaf25790b096d4fa492188268294a394c7

This was launched with Remix
https://ropsten.etherscan.io/tx/0x15887ebca7e6204e32c98fd600d3b0c695b75e31d48ba3785789ef687b3b3cc8


texts:
It’s a simple question, but I couldn’t find an answer. In an ERC20 contract lies this code

//The nonce for avoid transfer replay attacks
mapping(address => uint256) nonces;

.

    uint256 nonce = nonces[_address_from];
    bytes32 h = keccak256(_address_from ,_address_to ,_token_amount, _amount_fee ,nonce);
    if(_address_from != ecrecover(h,_v,_r,_s)) revert();

_r _s _v are functions parameters which must be set manually when calling it on contract execution.

How do I compute _r _s _v from my address and amounts in order to not get the transaction rejected ?


texts: Mist refusing to open following computer freeze/crash

texts: I've been using Mist on a Windows 10 machine for a few weeks, only minor issue I've encountered to date was an increase in system crashes, but today following a crash/freeze when I had to do a "hard reset" Mist refuses to launch. I click the icon (even with "run as admin") get the little blue spinning wheel for 3 seconds then nada. I've tried un-installing and reinstalling 5+ times already with no success. Also tried without the firewall just in case, but still no joy. I'm getting concerned as I have bids I need to reveal on the ENS now. Any help getting Mist back up working again would be GREATLY appreciated!!


texts: Error when try to connect to infura using HDWallet

texts:
I would like to debug a transaction using truffle and infura.

truffle debug --network=infurarinkeby 0x7...

truffle-config.js:

    infurarinkeby: {
        provider: function() {
            return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/<my api key>")
        },
        network_id: 4,
        gas: 6e6,
        gasPrice: 5e10,
        from: "0xc491c11f6c2e031e99d7c93300baced83019041d"
    },

Error:

Could not connect to your Ethereum client. Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle.js)


texts: Mistake when using web3.eth.filter() and filter.get()

texts:
I went to the website https://etherscan.io/txs?block=4067373

and with that information choose the following address (third in line) to test on:

0x25f000254108a104A7127B5a5697cb3C12643e62

And the following code was tested:

var options = {
  fromBlock: 4067373,
  toBlock: 4067373,
  address: "0x25f000254108a104A7127B5a5697cb3C12643e62",
};
var filter = web3.eth.filter(options);

filter.get(function(error, result){
  if (!error)
    console.log(JSON.stringify(result, null, 2));
});

I also did another test with the options object being:

var options = {
  fromBlock: 4067372,
  toBlock: 4067374,
  address: "0x25f000254108a104A7127B5a5697cb3C12643e62",
};

In both cases, the result was an empty array:

[]

Question:

Is there anything being done wrong above? I expected to get some values in the result array and I don't know why it is empty.


texts: Oracle service and oracle smart contract

texts:
I read this article https://medium.com/@robinagist/building-an-ethereum-oracle-with-web3-js-1-0-1272b59cfc31 but there are some things I didn't understand. Does the oracle need a node (like geth or parity) to communicate with the oracle smart contract?
At this link there is the code https://github.com/robinagist/EthereumWeatherOracle in wxoracle.js I did not understand the sleep function what it is for.


texts:
I keep getting Error: Invalid address when trying to run the application.
My current setup of web3 using infura node is

if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  const provider = new Web3.providers.HttpProvider('https://rinkeby.infura.io/doeL97MLPLVXBgAnRZRJ');
  web3 = new Web3(provider);
}
web3.eth.defaultAccount = web3.eth.accounts[0];
web3.personal.unlockAccount(web3.eth.defaultAccount)

The instance of the contract is

const contract = web3.eth.contract(abi);
const instance = contract.at(address);
instance.web3.eth.defaultAccount=instance.web3.eth.coinbase;

when trying to do a call to the contract, the value returned is undefined

const count = await EmployeeStore.employeesCount().then(function(value) {
      console.log(parseInt(value));
    });

as shown in the picture below, web3 is injected correctly and able to retrieve the accounts.


texts: Any systems based on blockchain technology are blockchain platform? I read topic on the internet with list of blockchain platform but there is no bitcoin although bitcion based on blockchain. Can you clarify what is really blockchain platform is and how to differentiate them?


texts: Is it possible to communicate between ethereum smart contract and binance smart chain contract?

texts: I would like to call a function in the Binance smart chain contract from my ethereum mainnet smart contract is this possible?


texts: Running an external command upon transaction confirmation

texts:
I was wondering if it were possible to launch an external command (system call) when a transaction sent by a node is confirmed?

For example if node A runs pyethapp (in the context of a private blockchain) as:

$ pyethapp -c eth.network_id=1337 -c node.privkey_hex=091bd6067cb4612df85d9c1ff85cc47f259ced4d4cd99816b14f35650f59c322 -b 'enode://288b97262895b1c7ec61cf314c2e2004407d0a5dc77566877aad1f2a36659c8b698f4b56fd06c4a0c0bf007b4cfb3e7122d907da3b005fa90e724441902eb19e@0.0.0.0:30303' -c eth.genesis_hash=283bd9430c5f3114872f93beefe99d6626980b3a4a18a44ddd27749cd89688f2 -m 50 run

and then node B connects to it through pyethapp:

$ pyethapp -c eth.network_id=1337 -b 'enode://288b97262895b1c7ec61cf314c2e2004407d0a5dc77566877aad1f2a36659c8b698f4b56fd06c4a0c0bf007b4cfb3e7122d907da3b005fa90e724441902eb19e@192.168.2.12:30303' -c eth.genesis_hash=283bd9430c5f3114872f93beefe99d6626980b3a4a18a44ddd27749cd89688f2 run

and sends a transaction from an account on its end to one on A's end can it take action (initiate a system call) once the transaction is confirmed?


texts:
Before the question, I want to list my development environment configuration:

I am using Remix online solidity IDE for coding
My contract is running on local PC with RPC (web3 provider option in Remix)
I set up MEW to run on my http:127.0.0.1:8545 node

I managed to deploy my ERC20 token contract, adding it to the MEW list that displays the current amount on that account; however, even though in the contract I set 10000000 as the initial supply of tokens, MEW displays '0.000 1e-11 RC' as the total amount. What am I missing out?

The code:

pragma solidity ^0.4.0;

contract UnclearlyToken {

    string public constant name = "Unclearly";
    string public constant symbol = "UC";
    uint8 public constant decimals = 18;
    uint totalAmount = 10000000;

    mapping (address => uint256) public balances;
    mapping(address => mapping (address => uint256)) allowed;

    event Transfer(address indexed _from, address indexed _to, uint _value);
    event Approval(address indexed _owner, address indexed _spender, uint _value);

    function UnclearlyToken() {
        balances[msg.sender] = totalAmount;
    }

    function totalSupply() constant returns(uint) {
        return totalAmount;
    }

    function balanceOf(address _owner) constant returns(uint256) {
        return balances[_owner];
    }

    function transfer(address _to, uint _value) returns (bool success) {
        if(balances[msg.sender] >= _value
            && _value > 0
            && balances[_to] + _value > balances[_to]) {

            balances[msg.sender] -= _value;
            balances[_to] += _value;
            Transfer(msg.sender, _to, _value);

            return true;
        }
        return false;
    }

    function transferFrom(address _from, address _to, uint _value) returns (bool success) {
        if(balances[_from] >= _value
            && _value > 0
            && balances[_to] + _value > balances[_to]
            && allowed[_from][msg.sender] >= _value) {

            balances[_from] -= _value;
            balances[_to] += _value;
            Transfer(_from, _to, _value);

            return true;
        }
        return false;
    }

    function approve(address _spender, uint _value) returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);

        return true;
    }

    function allowance(address _owner, address _spender) constant returns (uint remaining) {
        return allowed[_owner][_spender];
    }
}

MEW side:


texts:
I have some contracts written in solidity and I am testing in geth on a private blockchain. I am seeking something like a console statement to display variables.

I have been trying to work this out but nothing seems to work.

I have no UI and this is all just examining the contract itself without any UI.

Is there anyway to display variables as the program runs or is there any debugging process using geth?

I have looked at events but I cannot get them to display.


texts: Why won't my HTML file run/import my JS file?

texts:
My app.js file runs a node.js HTML server using nodemon app.js. I'm using fs.readFile to run index.html for the front-end. index.html file imports main.js using <script type="text/javascript" src="/Users/lennard/Desktop/numberChanger/build/app/main.js"></script>.
But when I start up the server and run the app in Chrome, index.html apparently does not find main.js as I get the following error:

Uncaught SyntaxError: Unexpected token '<'

I suspect that index.html is somehow loading itself whilst looking for main.js. When looking at Chrome's JS console the main.js file seems to be showing the contents of index.html:

When I simply copy and paste the main.js contents within the index.html <script> tags the code seems to execute just fine.

Does anyone know what's going on here?


texts: Unit testing compiled Contracts with Pudding and Mocha + NodeJS constructor not being invoked

texts:
I just starting out looking at Ethereum and am trying to test a Contract (using the simple cryptocurrency contract as an example) using Mocha, so I can take advantage of things like chai and sinon, etc, and stick to the rspec like format they follow.

The contract looks like:

contract MetaCoin {
  mapping (address => uint) balances;

  function MetaCoin() {
    balances[tx.origin] = 10000;
  }

  function sendCoin(address receiver, uint amount) returns(bool sufficient) {
    if (balances[msg.sender] < amount) return false;

    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    return true;
  }

  function getBalanceInEth(address addr) constant returns(uint) {
    return getBalance(addr) * 2;
  }

  function getBalance(address addr) constant returns(uint) {
    return balances[addr];
  }
}

The test looks like:

import {expect}   from 'chai';
import fs         from 'fs';
import solc       from 'solc';
import Pudding    from 'ether-pudding';
import TestRPC    from 'ethereumjs-testrpc';
import Web3       from 'web3';

const name = 'MetaCoin';

describe(name, () => {
  let ContractJS, address;

  before((done) => {

    const result = solc.compile(fs.readFileSync(`./contracts/${name}.sol`,
                                {encoding: "utf8"}), 1);
    const compiled = result.contracts[name];
    const abi = JSON.parse(compiled.interface);
    const binary = compiled.bytecode;
    const web3 = new Web3();
    const provider = TestRPC.provider({
      accounts: [{
        balance: 50000000
      }]
    });
    web3.setProvider(provider);

    web3.eth.getAccounts((err, accounts) => {
      address = accounts[0];
      ContractJS = Pudding.whisk(name, {
        abi: abi,
        binary: binary,
        address: address
      });
      ContractJS.setProvider(provider);
      done(err);
    });
  });

  it('has a contract instance', () => {
    expect(ContractJS).to.be.defined;
  })

  describe('#getBalance', () => {
    let instance;

    before(() => {  // put done back in if you switch this over.
      instance = ContractJS.at(address);
    });

    // This fails. balance.valueOf() is '0'
    it('gets the correct balance', (done) => {
      instance.getBalance.call(address).then((balance) => {
        expect(balance.valueOf()).to.equal('10000');
        done();
      }, done);
    });
  });
});

This test fails: complaining that '0' is not equal to '1000'.

This implies that the contract's constructor is not being invoked, or that the contract's tx.origin is a different address that the one provided. Maybe I am just missing something core and simple.


texts: Oraclize random datasource, what is trusted by using it?

texts:
I'm currently looking into ways of accessing randomness in a smartcontract.

I found oraclize random datasource https://github.com/oraclize/ethereum-examples/tree/master/solidity/random-datasource and read the paper, but I'm not fully sure what exactly I'd be trusting if using it as in their randomExample.sol

If I understand the paper correctly, they have a Ledger Nano S device connected to some machine which their smart contract interacts with.

So, if I use it, I'd have to trust the following things:

Their code is bug-/tamperfree
The device they use is bug-/tamperfree
They don't just switch out the device with a source they control
They don't just unplug the device and thereby cripple the service

Is this correct? Am I missing something?

Also, what are the cost of this service? In the example I just see that it defines

uint callbackGas = 200000; // amount of gas we want Oraclize to set for the callback function

Does the contract send this amount of gas to the random datasource contract and this contract sends the same ammount of gas back to execute the callback function? Or do they keep a part of the gas? how much? What's the right value here?


texts: Invalid transaction v,r,s values with geth when reading from of signed MEW RLP transaction

texts:
I generated a signed transaction with myEtherWallet:

0xf86b80847735940082520894ef5bbb9bba2e1ca69ef81b23a8727d889f3ef0a1880de0b6b3a7640000802ba06fef16c44726a102e6d55a651740636ef8aec6df3ebf009e7b0c1f29e4ac114aa057e7fbc69760b522a78bb568cfc37a58bfdcf6ea86cb8f9b550263f58074b9cc

I can convert it to a geth transaction object via:

Geth.newTransactionFromRLP(hex)

And successfully read fields like value or to - but when trying to access the from field I get an exception "Invalid transaction v,r,s values"
Is there anything I am doing wrong here - or should I report this as a bug?
Also interesting when doing transaction.encodeJSON() it also does not include the from field.
But it does not seem to be a general problem - when encoding/decoding with geth like this:

Geth.newTransactionFromRLP(transactionWithSignature.encodeRLP())

I can access the from field.

Update: Hint from Péter Szilágyi (@karalabe) on gitter:
Hmmm, one bet is that the mobile library might be using homestead signatures
and mew returning proper eip155


texts:
I have a smart contract which  balance is very dynamic.
Is there a way to transfer just half of the balance?

I tried:

account[4].transfer(this.balance / 2);

I think it's not the greatest idea since number of ether may not be divisible by 2


texts:
I would like to know how to set up an Ethereum node behind sentries (proxy nodes). I know there are several ways to approach this issue as mentioned here.
https://medium.com/@kidinamoto/tech-choices-for-cosmos-validators-27c7242061ea
But I'm interested in just the simplest option: the Single Layer Sentry Node Setup which would look something like this:

Are there guides or publications out there that can help me set up this kind of private network architecture and while still being able to communicate with a live blockchain using the sentry nodes?


texts:
I'm using my main desktop for casual mining.

Windows 10
i7. 16 GB RAM.
GTX1080 8GB.
20MHs.

When I'm running Geth and Ethminer, CPU is at 2-3%, GPU is at 100% (obviously). The entire desktop experience (light casual browsing) including mouse movement becomes very slow. This didn't happen when I had a Radeon RX480, where I can mine and use the desktop at the same time, without seeing a perceivable mouse lag.

Is there a way to tell the NVidia driver to save some some juice for Windows, or tell Windows to not run the desktop in hardware accelerated mode?

Thank you


texts: Consequences of making an ERC20 token burnable

texts:
My understanding is that if I implement an ERC20 token but also add an ability to burn some tokens, that token is no longer considered ERC20 token, because when coins get burned, the total amount decreases.
The question is - are there ANY negative effects? Incompatibility with any wallets?


texts: Remix Warning - No visibility specified, Violate Checks-Effects-Interaction pattern, Function state mutability can be restricted to pure - Can ignore?

texts:
Two months ago, I wrote a smart contract with Remix.ethereum.org.  Line 1 of my code has:

pragma solidity ^0.4.11;

It compiled fine with no errors and nor warnings.  I tested every function in Ropsten and it worked fine.

Now, I'm getting closer to deploying it on the Main net.  I see that Remix has changed.  Now, it says:

  Static Analysis raised 50 warning(s) that requires your attention.

Under the Analysis tab, there are many warnings, that I cannot figure out how to resolve.  One example is,

  Potential Violation of Checks-Effects-Interaction pattern in
  TestContract.testFunction(address): Could potentially lead to
  re-entrancy vulnerability. Note: Modifiers are currently not
  considered by this static analysis.

Another example is,

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

Another example is,

  Fallback function of contract browser/TestContract 8.sol:Test requires
  too much gas (null). If the fallback function requires more than 2300
  gas, the contract cannot receive Ether.

Another example is,

  Test.transferFrom(address,address,uint256): Potentially
  should be constant but is not.  Note: Modifiers are currently not
  considered by this static analysis.

There are multiple occurrences of each of the above examples.  Can I ignore all of these warnings?  If not, how do I resolve them?

Under Settings, it was using Solidity version 0.4.11.  If I change this to 0.4.17, I get dozens of warnings under the Compile tab as well.  One example is,

  browser/TestContract 8.sol:15:3 Warning: No visibility specified. Defaulting to "public":

  function register(string key) {

  ^

  Spanning multiple lines.

I can add "public" after the close bracket for the parameters in each of the functions to resolve the above warnings, but I'm not sure if that is the right thing to do.

Another warning example is,

  browser/TestContract 8.sol:100:3 Warning: Function state mutability
  can be restricted to pure

  function mil(uint256 a, uint256 b) internal constant returns (uint256) {

  ^

  Spanning multiple lines.

I have no idea how to resolve the above warning.

Am I correct to assume that I can ignore 0.4.17 and go back to 0.4.11?

0.4.11 up to 0.4.16 will not show these warnings under the Compiler tab.  Should I use 0.4.16?

My code can be seen here


texts:
I am pretty now the blockchain/solidity/ethereum world. I started in February, reading and diving into the world. Currently, I am trying to implement a simple game with ethereum and the help of smart contracts. I am using solidity because vyper is too new and there is more stuff to read and learn from solidity.

While researching the web for different questions about my problems and my observation in solidity/smart contract i never could find good resources or github repos that show how the actual work was don. (or it was in solidity 0.4.5, which is pretty old now).

I am using Truffle with Ganache to test out my application.

So i though i could get help from someone here in this community. Can someone recommend me their go-to websites or whatever, when trying to learn and understand smart contract and solidity.


texts: I can already implement a basic onlyOwner modifier. But what if I have an onlyOwner modifer already in my function and I want to specify that a function can be called by anyone other than the owner in the same contract. Would I have to write a separate modifier, or does solidity build in something like myFunction() !onlyOwner {...] that I could use instead?


texts: Quorum Swarm: Can't find swarm account: no key for given address or file

texts:
While using Swarm in Quorum, I am getting the following error: Can't find swarm account: no key for given address or file

Any similar encounters?


texts: Is it possible to be notified about errors in a production contract?

texts:
As a smart contract developer, is it possible to listen for errors or throws that happen in the mainnet? The motivation for this question is from an analytics perspective.

Events don't work in this situation since all effects are reverted.


texts: Which competing technologies are similar to Ethereum?

texts: Ethereum is widely known for its smart contract system, but which other competing technologies are also out there that does something similar. Just like in the early days of Bitcoin, many clone coins followed after. Which ones have come before or after Ethereum?


texts: Access to list of internal transactions via etherscan API

texts:
Is there any way to get a list of all of the internal transactions which affect an account, as presented on the etherscan "internal transactions" page on etherscan, using their API?

Or any other block explorer API?


texts: What's the best way to detect an incoming transaction with websockets and update balance?

texts:
What's the best way to detect an incoming transaction with web sockets and update balance?

Should it be done with polling?

Like for example - how would a web wallet do it? It's sitting idle - is it really polling the entire time?

If it's pooling all time, if you were on a sidechain like POA, you'd be checking every ~5 seconds, this doesn't seem efficient.

Is there any other way?


texts: Unlisted ethereum wallet. Maybe can you help me?


texts: Sending private information to account owner

texts:
I'd like to send an encrypted message, outside the blockchain, to an account owner who has previously interacted with a contract and whose public key is now known.

Is there yet any existing infrastructure (contracts?) in place to do this
Can I simply somehow encrypt the message with the public key and then the account owner can decrypt with the private key?


texts: sending signed transactions from contract

texts:
Is it possible to send private key signed transactions directly from the contract? The thing I want to do is to create a similar function

function sendTransactionForUser(_signedData, contractAddress){ sendSignedTrx(contractAddress, signedData) }

the main point is that the user would sign data -> send it to the owner -> owner would send transaction on behalf of the user, and pay gas for the user.


texts:
I am following remix connection manual.
Running remixd like this:

  remixd -s ~/myProjects/cleanKyber/smart-contracts/contractsV5/
  --remix-ide https://remix.ethereum.org/

trying to connect and getting this message on terminal:

  Connection from origin https://remix.ethereum.org rejected.

Following related questions, I made sure

  https

in both places is used.


texts:
In BigChaindb paper, it's mentioned that it's compatible with Ethereum and is complementary to Ethereum. But BigChaindb has has its own consensus.

Question 1: How can BigChaindb work with Ethereum (smart contract)?

Question 2: Why would it improve scalability if we use it with Ethereum?


texts: ERC20 is it possible create them for private users?

texts:
I created my erc20 and i would like no one, except me and those people to whom I send them, to generate my tokens.

Is it possible to generate all the tokens and send them to one wallet during the erc20 contract, and then send them to my friends wallets only?

Is it possible that there are other ways to do the same thing?


texts: Type Error: web3.eth.Contract is not a constructor but web3.version is 1.0.0

texts:
Why can't I instantiate my smart contract?

When I try and instantiate an instance of a smart contract with the following code...

let contractInstance = new web3.eth.Contract(abi, '0x6c6101607c84368dd130909bae7c7273d8914708');

... I get the following Error:

Uncaught TypeError: web3.eth.Contract is not a constructor

This is confusing to me because when I use web3.version in my console, it returns 1.0.0-beta.36. I instantiated my web3 provider in the following way:

window.addEventListener('load', async () => {
if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
    console.log('MetaMask Success');
    await window.ethereum.enable();
    web3.eth.defaultAccount = web3.eth.accounts.givenProvider.selectedAddress;

} else {
    console.log('No web3? You should consider trying MetaMask!');
    web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
}
});

Any suggestions?


texts: can anyone explain how this works mapping(string => Asset) private assetStore;?

texts:
I have used mappings in solidity
for example this line is from solidity documentation

mapping(address => uint) shares;

here we are mapping addresses to uints and shares being the identifier of that mapping.
But I came across this example

mapping(string =&gt; Asset) private assetStore;

on online tutorial and that does not make any sense. Can you explain how this works or is there any syntax error?


texts:
From the blog post The White Hats and DAO Wars: Behind the Scenes, the Goodies intend to:

develop the smart contracts that will be used to distribute ETC to the addresses holding DAO Tokens at block 1,919,999.

Update 00:57 Aug 20 2016 UTC
From ETC withdraw contract to be reviewed, the DAOBalanceSnapShot contract at 0x180826b05452ce96e157f0708c43381fee64a6b8 will be used to determine The DAO Token Holder's (DTH) balances at pre-hard-fork block 1,919,999.

Daobalance directory, containing the dao_balance_snapshot.sol contract and the script that generates the data. This is populated from the ETH chain but is deployed in the ETC chain and contains the DAO Token Holder balances at the time of the hard fork. This contract is already deployed and filled with data in the ETC chain at 0x180826b05452ce96e157f0708c43381fee64a6b8. You can test it live using the following interface in geth:
var daobalancesnapshot_abi = [{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[],"name":"seal","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"totalAccounts","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"data","type":"uint256[]"}],"name":"fill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"sealed","outputs":[{"name":"","type":"bool"}],"type":"function"},{"inputs":[],"type":"constructor"}];
var daobalancesnapshot = web3.eth.contract(daobalancesnapshot_abi).at("0x180826b05452ce96e157f0708c43381fee64a6b8");
daobalancesnapshot.balanceOf(YOURACCOUNTHERE);

How can I verify that my The DAO token balance is correct when the Goodies provide an ETC refund on the Ethereum Classic chain?


texts: What mobile wallets support scanning qr codes that are created using the EIP67 standard? Link to EIP67


texts: Cannot find accounts while using personal.listAccounts

texts:
While following this udemy tutorial and configuring the geth client I am presented with the following problem. The instructor hasn't responded yet so I thought I should ask here.

The thing is, on invoking personal.listAccounts , the console showed his account address but in my case nothing is being shown. I'm sure I did not skip over anything and the fact that our geth versions are slightly different bothers me in the sense that a few of the commands and options used simply do not work anymore in the latest version 1.8.15

What should I do to make sure that personal.listAccounts shows my address. I already have an account created in Ropsten and Rinkeby networks using metamask.


texts:
I'm writing test for my smart contracts with truffle test. I got these strings of code:

Library.new()
  .then((lib) => {
    console.log(lib.address); //0xd6f066a5b07562b6c8fdb6a59b7ba42036d5516c
    console.log(Library.isDeployed()); //false
    Deployer.link(Library); // Error: Cannot link contract without an address.
    ...

As you can see instance of library has an address but contract Library didn't handle it and still has false value in isDeployed() field. This weird behavior causes error on the next step when I'm trying to link my library to another contract.

Any advices?


texts: Can I avoid impermanent loss if I only as a LP of BETH/ETH pair in binance？

texts:
Can I avoid impermanent loss if I only stake ETH as a LP of BETH/ETH in Binance？ Is BETH's price stable？
If I don't want to hold any crypto assets except ETH，what are the best DEFI options to improve profit？


texts: On  official solidity page , there is an example Safe remote purchase, in that example there is a payable function Purchase, and function firsts checks if msg.value is even or odd. I want to know if that is just for purpose of demonstration or is there any significance of that code.


texts: Can I compile a smart contract without removing the line breaks?

texts:
According to an official document, compiling a smart contract needs to remove all the line-breaks in the contract's source-code:

  If you have the SolC Solidity Compiler installed, you need now reformat by removing spaces so it fits into a string variable.

var greeterSource = 'contract mortal { address owner; function mortal() { owner = msg.sender; } function kill() { if (msg.sender == owner) suicide(owner); } } contract greeter is mortal { string greeting; function greeter(string _greeting) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'
var greeterCompiled = web3.eth.compile.solidity(greeterSource)

As I think the removing process is not smart, I want to compile the code itself without stripping the line break manually.

Does anyone know how to do that?


texts: How can I generate a cold wallet completely offline WITH a random number seeded by me?

texts:
Requirements:

1) An account created on a raspberry pi that has never been connected to the internet ever.
2) A great private key on this account, that does not rely on any random number generator.
3) The ability to sign transactions on the pi (probably a QR code will be used to get them off the pi).

I found a great solution from Vitalik himself showing how to create the account and even sign a transaction: python_cold_wallet_instructions. The line eth.sendRawTransaction("<output of last line of code here>") is what I would perform on a separate computer. All seems great except one thing:

The line k = os.urandom(32) implies using the random number generator. How can I avoid using the RNG? Isn't this a legit concern?


texts:
I'm new to solidity I need to transfer my token(ERC20) to a list of specified addresses.

pragma solidity ^0.4.19;
import "./BorgiasCapitalFundToken.sol";

contract SendBCF {
    BorgiasCapitalFundToken public borgiasCapitalFundToken;

    struct OldToken {
        uint256 value;
        address member;
    }

    OldToken[] public oldTokenList;

    address public owner;

    function SendBCF(address contractAddress) public {
        borgiasCapitalFundToken = BorgiasCapitalFundToken(contractAddress);
        oldTokenList.push(OldToken({ value: 440000000, member: 0x54C340CcD7C35753F6BC638f2eDA9f9443D08876}));
        owner = msg.sender;
    }

    function finalSend() public {
        for (uint i = 0; i < oldTokenList.length; i++) {
            borgiasCapitalFundToken.transfer(oldTokenList[i].member, oldTokenList[i].value);
        }
    }
}

However, i'm getting a revert whenever finalSend is called. What is the correct implementation of this?


texts: Account created using web3 is not showing in geth console

texts:
I have created a new address using web3.eth.accounts.create() and it responds with

{ address: '0x9AA2767207d0aC9cCdD2e3B244210f630588F3E3',
  privateKey:
   '0x15bc394db36ab8745ca34a9961d84abf5a45697823726d500785df940e416cbc',
  signTransaction: [Function: signTransaction],
  sign: [Function: sign],
  encrypt: [Function: encrypt] }

But in geth console, it lists out all my accounts, except 0x9AA2767207d0aC9cCdD2e3B244210f630588F3E3. What have gone wrong here? I'm using web3 -1.0.0-beta.34 . I also tried using web3.eth.personal.newAccount('qwerty') but it shows The method personal_newAccount does not exist/is not available but clearly they mentioned this method in the 1.0.0 documentation.

I have initialised web3 and personal like

var personal = new Personal('http://localhost:8545' || 'ws://localhost:8546');
    web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545') || 'ws://localhost:8546');

Can some one help me on this problem? Thank you.


texts: Guessing mnemonic phrase based on the first 2 public addresses

texts:
Last hopeless attempt. I know that infinite amount of private keys can be generated from a mnemonic phrase and usually MetaMask, etc picks the first one from the list to use as the public address. Also if you create an additional account on the same MetaMask, it will generate an address which is the second in the list. I tried this in Ganache and I see it is true.
So would it be possible to guess the mnemonic phrase based on knowing the first 2 generated addresses?
I am asking this because I created a wallet on MEW which I used in Metamask as a primary account and then created an additional account without backup which has ERC20 tokens with high value locked now. Now I have lost my laptop and I only have the private key and password of Account 1 and the public address of account 2


texts: development environment for solidity 0.4

texts: Is there any development environment currently supporting solidity 0.4+? Apparently Truffle doesn't support it yet, Mix IDE appears to have been discontinued, ether.camp is offline. I haven't tried Dapple or Embark so I can't say anything about those. Has anyone already switched to the new solidity version and if so what are they using to develop and test contracts?


texts:
I have a user A and a user B. They do not trust each other. So, they run the following smart contract:

User A specify a time locked deposit of x coins to user B under a predefined condition( For example: revealing the correct solution of a function ∅(i))
If the user B within a specific time T sends a valid solution, so User B gets the deposit.
Otherwise, if the user B does not sent any correct solution or misbehave by sending non valid solution. Then, User B get fined with x coins that goes to user A.


texts: Does ecRecover in solidity expects the "\x19Ethereum Signed Message:\n"-prefix

texts:
I struggle heavy to actually recover the ethereum address from a hash and the {r, s, v} from a signature with the ecRecover-method in solidity.

What i want is to sign another ethereum-address. So i hash that address with sha3 and hex-encoding in web3, and sign it with my address. I then extract {r, s, v} from it and call my method. But i never get the correct result.

    function recover(bytes32 _h, uint8 _v, bytes32 _r, bytes32 _s){
    ecRecovery = ecrecover(_h, _v, _r, _s);
}

The address i want to sign is: 0x8CbaC5e4d803bE2A3A5cd3DbE7174504c6DD0c1C

The resulting hash for it for me is: 0x4d55361a8f362c8fc244dbd1e4968ca4b96d58e63a0f0c01a2cad1149106568a

After signing it, i get: 0x7709ac9c45926cc4d9791d868ad6c81883b624db44fbae1e62c0e6cc6c19784b74eb7f5ecdcf33f9c61946dc33b57964b1a0fee40ebf3b9c875424553cb865031b

From which i extract:

v = 27
r = 7709ac9c45926cc4d9791d868ad6c81883b624db44fbae1e62c0e6cc6c19784b
s = 74eb7f5ecdcf33f9c61946dc33b57964b1a0fee40ebf3b9c875424553cb86503

feeding that into my function, i get: 0x9a5aAF102C82FaB302923bF8838678728A520103
whis is wrong. What i expect is:
0x1b7fBea9e926B1eAfC299b9Fab8f7174f466244e

My first instinct was to add the prefix of "\x19Ethereum Signed Message:\n", but that doesn't work either. Probably because i'm doing it wrong. So, is anybody able to help me with that one?


texts: Uncaught (in promise) Error: Returned error: oversized data when calling the set method for a very large cipher string

texts: I am using a quorum 7 nodes example with IBFT genesis file. I have modified the maxCodeSizeConfig to 128KB (which is maximum). I have also increased the gas limit to 0x3B9AC9FFFFFF. But, when I am trying to call my setVariable(ciphertext).send() method, I am still getting the same error as Oversized data when calling the method.


texts:
I am using geth and writing a js script and I try to load it using loadScript command, but when I run this command, I get false :

 loadScript("C:\Users\Sandi\Desktop\Solidity\sol_js.js")

  false

I am not able to load the script. How i should do to load it in order to get true message ?


texts: I keep getting the `Set 'ethereum.autoRefreshOnNetworkChange' to 'false'` warning, despite setting value to false

texts:
I'm using ethers.js to connect to MetaMask. I keep seeing this warning in my console:

inpage.js:1 MetaMask: MetaMask will soon stop reloading pages on
network change. For more information, see:
https://docs.metamask.io/guide/ethereum-provider.html#ethereum-autorefreshonnetworkchange
Set 'ethereum.autoRefreshOnNetworkChange' to 'false' to silence this
warning.

I tried setting the value to false immediately after detecting window.ethereum - but I'm still getting this warning. Here's my code:
    try {
      if(window.ethereum) {
        window.ethereum.autoRefreshOnNetworkChange = false;
        window.ethereum
          .on('accountsChanged', accounts => {
            window.location.reload();
          })
          .on('chainChanged', () => {
            window.location.reload();
          });
        await window.ethereum.request({method: 'eth_requestAccounts'});
        //...do stuff
      }
      else {
        throw new Error('Cannot connect to MetaMask or other Web3 wallet');
      }
    }
    catch(err) {
      throw err;
    }

Am I putting the value in the wrong place? I tried moving that line around, and nope.


texts:
I've ran into a problem trying to install web3.  I went through here and stackover flow to try and solve the issue but had no success. I had to install python2.7 but still getting this error.  Any ideas where I am going wrong? Thanks.

Traceback (most recent call last):
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
    sys.exit(gyp.script_main())
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
    return main(sys.argv[1:])
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
    return gyp_main(args)
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
    options.duplicate_basename_check)
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
    generator.CalculateVariables(default_variables, params)
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables
    generator_flags.get('msvs_version', 'auto'))
  File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion
    versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2017'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Mark\Documents\GBR\GBCoin\node_modules\sha3
gyp ERR! node -v v10.16.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN gc@1.0.0 No description
npm WARN gc@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3@1.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.


texts:
Node 1 is mining but Node 2 is not syncing
Running admin.peers on Node 1 gives:

Running admin.peers on Node 2 gives:

Both Nodes are using same genesis block
When starting console on Node 2 I used --ipcdisable flag? could that be the issue as inter-process communication is disabled on Node 2?


texts: Will my transaction get lost if it's in a block which was forked due to double-spending?

texts:
I have a contract which I need to update occasionally.

This update has nothing to do with "real money transfer".

It deals only with the value of a state (global) variable in my contract.

Also, I am the only one who can change this state variable (protected with an onlyOwner modifier).

My general question is:

Do I need to worry about the status of this transaction in any way whatsoever?

For example, do I need to keep the receipt and check that it is still valid after 12 blocks?

More specifically, do I need to worry about this transaction not taking place because it coincidentally went into a block which also contained a "double-spending" transaction and was forked out of the chain due to that?

In other words, with regards to that block - does everybody need to worry about their transactions, or only the one who issued the "double-spending" transaction?

I found this post, which more or less refers to some of my concerns.

However, the answer does not refer to one specific question in that post, which happens to be exactly what I'm asking here:

  What if it was included in some block, but then the block gets orphaned? Will my transaction be "removed"?

Thank you very much!


texts: how to import unencrypted private key in testnet

texts:
I tried using the following command

geth --testnet account import <path_to_key_file>

I am getting the following error:

Fatal: Failed to load the private key: unexpected EOF

Note that my key is the actual key I used while creating the account. Am I doing something wrong? If yes, how to do it correctly.


texts: how to see contract that only has bytecode

texts:
I am looking at this contract - https://etherscan.io/address/0xf8681dad1ce4f1f414fb07fc07f81a3a82e91d8f#code but it turns out that there's only ByteCode and if I decompile it, the code it gives me is just horrible to look at.
Question 1: Is it possible to deploy the contract and noone can see the actual source code ?
Question 2: even if only ByteCode appears, how do i get the actual source code ?


texts: How do you change a contract value using ConciseContract in web3.py?

texts:
In my contract, I expect that my_contract.a() will not make any updates to values in the blockchain, but my_contract.change_value(new_val) should. However, change_value() is not making the change I expect.

How do I get the value in my contract to change?

My full code for interacting with the contract is below:

web3 = Web3(HTTPProvider('http://localhost:8545'))
print('Last block is ' + str(web3.eth.blockNumber))
print('Accounts: ' + str(web3.eth.accounts))
print('Unlock account: ' + str(web3.personal.unlockAccount(web3.eth.accounts[0], '123', 10000)))

abi_raw='''[{"constant":true,"inputs":[],"name":"a","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getValue","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newValue","type":"int256"}],"name":"change_value","outputs":[{"name":"","type":"int256"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_newValue","type":"int256"}],"name":"NewValue","type":"event"}]'''
abi = json.loads(abi_raw)
bytecode = '6060604052341561000f57600080fd5b5b60646000555b5b61013a806100266000396000f300606060405263ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630dbe671f811461005357806320965255146100785780635e21b8601461009d575b600080fd5b341561005e57600080fd5b6100666100c5565b60405190815260200160405180910390f35b341561008357600080fd5b6100666100cb565b60405190815260200160405180910390f35b34156100a857600080fd5b6100666004356100d2565b60405190815260200160405180910390f35b60005481565b6000545b90565b6000818155817fd9c5893d0867e0ea2c1c5251cb2bc831b6121f6db93f76fa1db9cca46e2f99b960405160405180910390a2506000545b9190505600a165627a7a723058204820bc0702b61905d788684d628adc4cc3a320161ead0a1a3268b1c715fbaa740029'
tokenContract = web3.eth.contract(abi, bytecode=bytecode)
tx_deploy_hash = tokenContract.deploy(transaction={"from":web3.eth.accounts[0]})

# wait for contract deployment transaction to be mined
txn_receipt = web3.eth.getTransactionReceipt(tx_deploy_hash)
while txn_receipt is None:
    time.sleep(1)
    txn_receipt = web3.eth.getTransactionReceipt(tx_deploy_hash)

contract_address = txn_receipt['contractAddress']
my_contract = web3.eth.contract(abi=abi,
                                address=contract_address,
                                ContractFactoryClass=ConciseContract)

result = my_contract.a()
print('a = ' + str(result))

b = my_contract.change_value(20)
print('return from function - ' + str(b))

result2 = my_contract.a()
print('a = ' + str(result2))

Running the above code prints the following:

  Contract address  - 0xbf71e4662e3fc46f0522ea4a1bb425505b072a90
  a = 100
  return from function - 20
  a = 100
  result from func getValue - 100

Why can't I change the value?

The Solidity code for this contract is in this screenshot


texts: Dynamic number of inputs to a smart contract

texts:
Assume we a smart contract that accepts a number of cryptographically signed attributes. The smart contract will validate each signature and check that all the addresses of those signed signatures match. The smart contract should be able to take a minimum of two signature and a maximum of say ten signatures. How do we create a smart contract that allows the user to input a dynamic number of attributes? Is that even possible?

The following code works for a single signature and returns the address of the signer:

pragma solidity ^0.4.8;

contract test {

    function recoverAddr(bytes32 msgHash, uint8 v, bytes32 r, bytes32 s) constant returns (address) {
        bytes memory prefix = "\x19Ethereum Signed Message:\n32";
        bytes32 prefixedHash = sha3(prefix, msgHash);
        address signer = ecrecover(prefixedHash, v, r, s);
        return signer;
    }
}

I want to add to this so that it can accept the n signed msgHashes (considering sometimes a user might enter at least 2 and other times the user might enter more attributes, up to the maximum number allowed, 10 in this case). Then if all addresses match, we return the address.


texts:
Consider im having to deal with 3 uint8 values each of which are to be stored for each user.
Is the gas cost the same if i use 3 different arrays or if i use a structure array which contains the 3 uint8 values together.

struct Users{
  uint8 no1;
  uint8 no2;
  uint8 no3;
}
Users[] public users;

Thanks


texts: What is the easiest way to write truffle tests in typescript?

texts:
I read about Typechain, but the configuration is rather verbose and generally feels like a very custom solution:

  Everytime you change contracts you need to run yarn generate.


texts: What happens when a function call fails within my contract method?

texts:
I am mostly interested in the following aspects:

does the entire stack get unwind?
if the entire stack gets unwind does this lead to all the changes made to the state by the contract get reverted?
do events get reverted? I imagine that event are stored in the (global) state and reverting the state would also remove the events.


texts: Transaction sent from web3 cannot reached all transaction to network node

texts:
I used one node endpoint to interact with the network. While sending a transaction from web3.js 0.20 to ethereum network, transaction per second (TPS) I achieved is only 28 TPS. I have configured the network in such a way to handle 100 TPS by increasing block Gas limit. whereas I achieved-

  Above 30 tps transaction sent from web3js cannot actually be sent all transaction
  to node properly.  I am sure that, this is not due to Block Time and
  Block Gas Limit.

Why web3js is not sending all transaction to the network node in higher TPS. Is there anything that restricts to send transaction in higher TPS ?


texts: Can't transfer ether from contract to another contract ^0.5.0

texts:
I try to transfer ether from one contract B to contract A. But I get "Transaction mined but execution failed"

Code:

pragma solidity ^0.5.0;

contract A {
  address payable public owner;
  uint public block_number;

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

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

  function () external payable {
      block_number = block.number;
  }
}

contract B {
  address payable public owner;
  address payable public contract_a = 0x600F51a64e8A703b759EB3d735132d6C802A0a7b;  //contract's A address after deploy

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

  function () external payable {
      contract_a.transfer(msg.value);
  }
}

At first I deploy A and copy and paste address to B. Then I send ether from wallet to B  and get error. What am I doing wrong? If I send ether from wallet directly to A it's successful.


texts: How to call a read-only function on a deployed contract?

texts:
I'm trying to interact with this contract using geth: https://etherscan.io/address/0xA33c4A314fAA9684eefFA6ba334688001Ea99bBC#code

From MEW I can call the function whatRound() and get current results.

But from geth I always get 0 back so it looks like I'm not connecting to the
contract or something.

This is what I'm doing:

>var phoenixContract = eth.contract(< ABI >).at('0xA33c4A314fAA9684eefFA6ba334688001Ea99bBC');
>phoenixContract.whatRound();
>[0, 0, 0, 0]

Why isn't this returning the actual values from the contract?


texts:
I am going to get all ehtereum wallet addresses with positive balance.
I tried to get addresses with a method to get transaction.
I have got transaction from blocknumber(0~ Inf).
Using web3 and following code:

block_number = 0
while True:
    tx = web3.eth.getTransaction(block_number)
    if not tx:
        break
    ...
    block_number += 1

But above running time is too slow.
If anyone know how to get all addresses by another way, please help me.


texts: Why don't blockchains use simple voting based consensus algorithms?

texts:
Suppose we have an malicious agent Bob with account balance of 100 units trying to double spend a coin by broadcasting two messages simultaneously:
A: Bob sends Alice 100 units
B: Bob sends Emily 100 units
Now some nodes in the transaction will receive message A first, and others B first. If a node receives both messages, it will only validate the first message (since Bob has only 100 units in his account).
Theoretically, we can figure out how many nodes consider each message to be valid, and add the transaction with the most number of validators to the blockchain.
So why exactly do we need PoW in such a scenario?


texts:
I am facing a strange issue. Please read the below case craefully and assit me to geth this issue resolved.

I have ERC20Token created by Zeppling templates.

[Please ignore syntaxes, I am just trying to expling my use case:]

Here is a protoype of token code:

Contract 1:

SampleErc20Token

{
    constructor(_tokenHolderAccess)
    {
        balances[_tokenHolderAccess]=1000000;
    }

    transfer(to, amount)
    {
        balance[msg.sender]///// Here is the issue.
    }
}

DummyContarcts(_erc20TokenObject)

{
    DoSomething
{
    _erc20TokenObject.transfer(newTokenHolderadress, 10000);

}

}

In Truffile test case I am deploying
SampleErc20Token and DummyContarcts from accounts[0]

In SampleErc20Token Constructor I am passing the address of DummyContarcts .

Now with the instance of DummyContarcts I call method DoSomething, which internally calls _erc20TokenObject.transfer. In this case msg.sender in transfer methid should be DummyContarcts onject.
But its picking some random address. Can any one help me to solve this puzzle please.


texts: Fatal: Error starting protocol stack: invalid argument (vagrant)

texts:
I'm trying to set up a local node in Vagrant (trusty64, geth 1.7.1-stable):

geth --identity "test_remote" --datadir "./geth_data_remote" --trace "./geth_data_remote/trace.txt" --dev

and getting the following error:

  19:00:20.199679 syncDir: sync /var/www/vhosts/localhost/htdocs/geth_data_remote/geth/chaindata: invalid argument
  19:00:20.199749 CURRENT: sync /var/www/vhosts/localhost/htdocs/geth_data_remote/geth/chaindata: invalid argument

Locally (OSX 10.12.6, geth 1.6.7-stable) it works very well that's why I can't get the problem. Does anybody have a clue?

p.s. it also works, if I don't specify the directory, but it's still quite important for me.


texts: What is the reason behind writing "using Counters for Counters.counters" when using the Counters openzeppelin library

texts:
while trying to understand the OpenZeppelin contracts that a contract inheritated from I stumbled unto this line "using Counters for Counters.Counter;" (after the library counters of openzeppelin was imported : https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Counters.sol).
I realized that this way of using the library is "advised" in the source code on OpenZeppelin github. However I don't understand why. Quick researches learned me that the using keyword was used to allow specific types to use function from a library as if they were properties from those types (https://medium.com/coinmonks/soliditys-using-keyword-c05c18aaa088).
I would have thaught importing the library would have been enough. If anyone could explain to me the coding logic behind that it would help me a lot. Thanks


texts: Can Mist communicate (via IPC) with a geth instance running by other user?

texts:
I'm aware that Mist cannot connect to a geth node in another computer, but how about to a geth instance running in the same computer but under a different user?

My goal would be to have Alice and Bob run the same wallet (via Mist) in the same Linux box, but the geth always be running under the hood in the background when the computer starts, so that the blockchain is always in sync without the need of leaving the Mist UI open 24/7.

For that, I created a user called geth, and created a shared folder called /home/shared which will hold the .ethereum subfolder. Then I make these symlinks for all users:

/home/geth/.ethereum -> /home/shared/.ethereum
/home/alice/.ethereum -> /home/shared/.ethereum
/home/bob/.ethereum -> /home/shared/.ethereum

Then I run geth by doing:

sudo runuser -l geth -c 'nohup /home/shared/Ethereum-Wallet-linux64-0-8-1/resources/node/geth/geth > /home/geth/geth.log 2>&1 &' &

And it seems to run and sync well. The problem is when I try to run Mist inside alice's or bob's session, it gives:

[2016-08-06 15:02:36.604] [INFO] Sockets/node-ipc - Connect to {"path":"/home/alice/.ethereum/geth.ipc"}
[2016-08-06 15:02:36.621] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:37.623] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:38.624] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:39.626] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:40.626] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:41.628] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...
[2016-08-06 15:02:42.630] [WARN] Sockets/node-ipc - Connection failed, retrying after 1000ms...

I thought it was a permissions problem, but I created a unix group called family, put all users in it (geth, alice and bob), and gave enough permissions for all to read the ipc file, proof:

$ ls -lha /home/alice/.ethereum/
total 496K
drwxrwx--- 6 alice family 4.0K Aug  6 14:58 .
drwxrwsr-x 5 alice family 4.0K Aug  5 17:19 ..
drwxrwx--- 2 alice family 468K Aug  6 15:16 chaindata
drwxrwx--- 2 alice family 4.0K Aug  6 14:58 dapp
srwxrwx--- 1 geth  family    0 Aug  6 14:58 geth.ipc
drwxrwx--- 2 alice family 4.0K Aug  5 12:21 keystore
-rw-rwx--- 1 alice family   64 Aug  5 11:40 nodekey
drwxrwx--- 2 alice family 4.0K Aug  6 14:58 nodes

However after making these permissions changes, it still cannot connect. What's wrong with the IPC connection?

UPDATE: Apparently, after I stop geth and run it again, it re-creates the file again but with only 600 permissions. So maybe changing the permissions after the file has been created is not enough, and I have to make geth create the file with the correct permissions? I tried to do this by doing two things:

Use umask 022: this doesn't work, either by adding it in /home/geth/.profile or by adding it before the launch of geth via sudo runuser -l geth -c 'umask 022 && nohup /home/shared/Ethereum-Wallet-linux64-0-8-1/resources/node/geth/geth > /home/geth/geth.log 2>&1 &' &
Using ACL: doing setfacl -d --set u::rwx,g::rwx,o::- /home/shared/.ethereum. Still doesn't work.
Setting the getid of the folder via sudo chmod g+s /home/shared/.ethereum.

And it still doesn't work, geth keeps creating a 600 file in /home/shared/.ethereum instead of 660

UPDATE II: Changing the ipc file's permissions to 777 makes it work!!! Why does 770 doesn't work? I'm puzzled. I don't want to use 777 because it seems like a security risk.

:'(

$ getfacl geth.ipc
# file: geth.ipc
# owner: geth
# group: gatecoin
user::rwx
group::rwx
other::---


texts: Validate Ethereum addresses on JSFiddle or other quick & dirty REPL

texts:
Can anyone who's gotten the Ethereum utility libraries to work in JSFiddle or Python lend me a headstart?

All I want to do is validate some addresses by hand in a REPL environment (EIP-55 etc).

Tried pip install ethereum in my Python 3.6 environment but it fails with this error.  Not sure why it's trying to invoke binaries from Visual Studio.

Next went to try in a Python 2.7 environment but mine must be buggered as I'm getting:

C:\Python27>python -m pip install ethereum
C:\Python27\python.exe: No module named pip

even after reinstalling python-2.7.14.amd64.msi to the C:\Python27 folder and ensuring pip is checkmarked (and ensuring my PYTHONHOME environment variable is correctly set of course).

Tried to figure out how to import the Ethereum libraries into repl.it (that would be ideal) but didn't manage it before moving on.

Was hoping to make a JSFiddle with something like:

<script src="https://rawgit.com/ethereumjs/ethereumjs-util/master/index.js"/>

but apparently the libraries need to be browserify'ed first.

I could keep kicking at this but I'm sure somebody out there must have already done it.  All I'm looking for is a quick and dirty, friction-free way to get starting playing with the validate functions against some addresses I want to inspect.


texts: What does this line of solidity do (new Deed).value(msg.value)(msg.sender)?

texts:
ENS's HashRegistrarSimplified has a line I'm having trouble understanding. Inlined:

function newBid(bytes32 sealedBid) payable {
  if (address(sealedBids[msg.sender][sealedBid]) > 0) throw;
  if (msg.value < minPrice) throw;

  // Creates a new hash contract with the owner
  Deed newBid = (new Deed).value(msg.value)(msg.sender);
  sealedBids[msg.sender][sealedBid] = newBid;
  NewBid(sealedBid, msg.sender, msg.value);
}

It targets v0.4.0, if that makes a difference. The best I've been able to figure is:

(new Deed) // calls the constructor but with no arguments?
          .value(msg.value) // calls the accessor for value?
                           (msg.sender) // I'm pretty confused


texts:
I believe this is a very simple question, but i couldn't find a direct answer in documentation or google. I'm new to solidity/ethereum and maybe i don't fully understand some core concepts yet.

So, let's use a simple code like this

contract StrangeToken {

  uint256 private repurchasePrice;
  mapping(address => uint256) balances;

  function setPrice(uint256 price) {
   repurchasePrice = price;
  }
}

Anyone can call setPrice() function to set a repurchasePrice variable. Let's assume that there are thousands of users and setPrice() is called every minute or even more often and the value is set to some random number.

The questions is: how difficult is it to predict and/or influence the value of repurchasePrice for the nearest future/coming blocks.

As far as i understand ethereum does not necessarily keep a sequence of calls so there is no practical possibility to time the call, so attacker has to be at least a miner, not a ordinary user. But the possibilities of miners in this area are not completely clear to me.

Thanks!


texts:
I am sending a transaction through this code

public String transferEthByPk(String amount, String toAddress, String privateKey, Web3j web3j) {
        BigDecimal value = new BigDecimal(amount);

        Credentials credentials = EthWalletUtil.createCredentialByPrivateKey(privateKey);
        System.out.println("credentials"+credentials);
        if (credentials != null) {
            try {
                TransactionReceipt transactionReceipt= Transfer.sendFunds(
                        web3j, credentials, toAddress,
                        value, Convert.Unit.ETHER)
                        .send();
                String tx_Hash = transactionReceipt.getTransactionHash();

                return tx_Hash;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

And I return this exception.

org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds for transaction: 0x28f2896b750e8480f87f831abd8fbdb00177527c31f5f9b4315ed8c8f374e481

This exception occurs here

 TransactionReceipt transactionReceipt= Transfer.sendFunds(
                        web3j, credentials, toAddress,
                        value, Convert.Unit.ETHER)
                        .send();

I can find this transactionHash in etherscan ,but it is always pending.I don't know why it is.


texts: Web3.js Get Contract Abi Knowing Only Contract Address

texts:
is there a way with web3.js to get a contract abi json, knowing only the contract address?

I cannot find anymore a link in wich they explain how to do this, in this post the guy replied telling that there is a way to do this but it's not so well documented.

How can I do this?