texts: What do I put in the "ifSuccessfulSendTo" field in a crowdsale contract

texts:
Here is the code:

pragma solidity ^0.4.18;

interface token {
    function transfer(address receiver, uint amount) external;
}

contract Crowdsale {
    address public beneficiary;
    uint public fundingGoal;
    uint public amountRaised;
    uint public deadline;
    uint public price;
    token public tokenReward;
    mapping(address => uint256) public balanceOf;
    bool fundingGoalReached = false;
    bool crowdsaleClosed = false;

    event GoalReached(address recipient, uint totalAmountRaised);
    event FundTransfer(address backer, uint amount, bool isContribution);

    /**
     * Constructor function
     *
     * Setup the owner
     */
    function Crowdsale(
        address ifSuccessfulSendTo,
        uint fundingGoalInEthers,
        uint durationInMinutes,
        uint etherCostOfEachToken,
        address addressOfTokenUsedAsReward
    ) public {
        beneficiary = ifSuccessfulSendTo;
        fundingGoal = fundingGoalInEthers * 1 ether;
        deadline = now + durationInMinutes * 1 minutes;
        price = etherCostOfEachToken * 1 ether;
        tokenReward = token(addressOfTokenUsedAsReward);
    }

    /**
     * Fallback function
     *
     * The function without name is the default function that is called whenever anyone sends funds to a contract
     */
    function () payable public {
        require(!crowdsaleClosed);
        uint amount = msg.value;
        balanceOf[msg.sender] += amount;
        amountRaised += amount;
        tokenReward.transfer(msg.sender, amount / price);
       emit FundTransfer(msg.sender, amount, true);
    }

    modifier afterDeadline() { if (now >= deadline) _; }

    /**
     * Check if goal was reached
     *
     * Checks if the goal or time limit has been reached and ends the campaign
     */
    function checkGoalReached() public afterDeadline {
        if (amountRaised >= fundingGoal){
            fundingGoalReached = true;
            emit GoalReached(beneficiary, amountRaised);
        }
        crowdsaleClosed = true;
    }

    /**
     * Withdraw the funds
     *
     * Checks to see if goal or time limit has been reached, and if so, and the funding goal was reached,
     * sends the entire amount to the beneficiary. If goal was not reached, each contributor can withdraw
     * the amount they contributed.
     */
    function safeWithdrawal() public afterDeadline {
        if (!fundingGoalReached) {
            uint amount = balanceOf[msg.sender];
            balanceOf[msg.sender] = 0;
            if (amount > 0) {
                if (msg.sender.send(amount)) {
                   emit FundTransfer(msg.sender, amount, false);
                } else {
                    balanceOf[msg.sender] = amount;
                }
            }
        }

        if (fundingGoalReached && beneficiary == msg.sender) {
            if (beneficiary.send(amountRaised)) {
               emit FundTransfer(beneficiary, amountRaised, false);
            } else {
                //If we fail to send the funds to beneficiary, unlock funders balance
                fundingGoalReached = false;
            }
        }
    }
}

and here is the image of what I need to fill in when deploying the contract:


texts: where can i find the addresses of the pancakeswap coin pairs smart contracts

texts: where can I find the smart contract address of all (or the major) coin pairs of the pancakeswap AMM. I can't find it anywhere and searching on google yields random articles.


texts: truffle migrate --network kovan >> ProviderError: VM Exception while processing transaction: revert

texts:
I am a beginner.
I can deploy to a private network but I can not deploy to a public network.
I need a Deploy to the kovan test network. please help me.

>truffle init

>npm install truffle-hdwallet-provider

***** Token.sol *****

pragma solidity >=0.4.25 <0.6.0;

contract Token {

    mapping (address => uint256) public balanceOf;

    constructor(uint256 initialSupply) public {
        balanceOf[msg.sender] = initialSupply;
    }

    function transfer(address _from, address _to, uint256 _value) public returns (bool success) {
        require(balanceOf[_from] >= _value);                // Check if the sender has enough
        require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
        balanceOf[_from] -= _value;
        balanceOf[_to] += _value;
        return true;
    }
}

***** Shop.sol *****

pragma solidity >=0.4.25 <0.6.0;

import "./Token.sol";

contract Shop {

    struct Product {

        string name;

        string imgPath;

        uint256 price;

        uint256 quantity;

        address seller;
    }
    event AddedProduct(uint256 pid, address seller, uint256 timestamp);
    event BuyProduct(uint256 pid, address buyer, uint256 timestamp);
    mapping (uint256 => Product) products;
    mapping (uint256 => address[]) buying;
    Token token;

    constructor (address _tokenAddress) public {
        token = Token(_tokenAddress);
    }

    function addProduct(
        uint256 _pid,
        string memory _name,
        uint256 _price,
        uint256 _quantity,
        string memory _imgPath,
        uint256 timestamp
    ) public {
        products[_pid] = Product({
            name: _name,
            imgPath: _imgPath,
            price: _price,
            quantity: _quantity,
            seller: msg.sender
        });
        emit AddedProduct(_pid, msg.sender, timestamp);
    }

    function getProduct(uint256 _pid) public view returns (string memory, uint256, uint256, string memory, address) {
        Product memory product = products[_pid];
        return (product.name, product.price, product.quantity, product.imgPath, product.seller);
    }

    function buyProduct(uint256 _pid, uint256 _timestamp) public {
        require(products[_pid].quantity > 0, "Product is sold out");

        Product storage product = products[_pid];
        address _buyer = msg.sender;
        token.transfer(_buyer, product.seller, product.price);

        product.quantity -= 1;

        buying[_pid].push(_buyer);
        emit BuyProduct(_pid, _buyer, _timestamp);
    }
}

***** 2_deploy_contracts.js *****

const Token = artifacts.require('./Token.sol');
const Shop = artifacts.require('./Shop.sol');

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

  deployer

    .deploy(Token, 1000000, {from: accounts[0]})

    .then(async () => {

      const tokenContract = await Token.deployed();
      return deployer.deploy(Shop, tokenContract.address);
    })
    .then(async () => {
      const token = await Token.deployed();
      const coinbase = accounts[0];
      const value = 50000;
      await token.transfer(coinbase, accounts[1], value);
    });
};

***** truffle-config.js *****

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

const mnemonic = ".....";

module.exports = {

  networks: {

    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*"
    },

    kovan: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "https://kovan.infura.io/v3/.....")
      },
      network_id: 42,
      skipDryRun: true
    },
},

}

>truffle migrate --network kovan

Error: Error: ProviderError: VM Exception while processing transaction: revert

at Object.run (C:\Users\WINDOWS\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:92:1)

at processTicksAndRejections (internal/process/next_tick.js:81:5)

Truffle v5.0.33 (core: 5.0.33) Node v11.12.0

PS D:\Blockchain Dev\t2>


texts: how to "lock" in place a certain amount of ETH

texts:
Newbie here, making my first steps in the smart contracts/dapps world;
let's assume a simple scenario, 2 people making a wager on a game outcome. They agree on the amount waged, and who ever wins is automatically credited with the waged amount. How would one go and "lock" in place the waged amount from the 2 wallets? Or what other means of reserving that amount can  be employed in a smart contract?
I'm particularly interested in the core logic, not necessarily the code for it.

Thank you.


texts: Geth fails after move of freezer content to new SSD, sites gap in Ancient and leveldb

texts:
I'm attempting to split my chaindata files across two Samsung T5 SSDs. Mounted the new SSD at /media/t5 and copied the 'ancient' chaindata subdirectory files with
cp -r /var/lib/goethereum/geth/chaindata/ancient /media/t5/ancient

changed group and file ownership of ancient and contents to geth
changed permissions on ancient directory to 755
Changed geth.service file:
ExecStart=geth  --http --syncmode fast --cache 1024  --datadir /var/lib/goethereum  --datadir.ancient /media/t5/ancient

Did a daemon-reload and restarted geth
Result:

Fatal: Failed to register the Ethereum service: gap (#11992073) in the
chain between ancients and leveldb

Should I have stopped geth before copying those files?
Was cp -r not the correct way to copy the directory?
Or is there some other step I missed?


texts: How to bind Go auto-generated code to a smart contract over IPC?

texts:
I wish to create a go-binding to my smart contract which was mined on a private blockchain.

I've looked at the Native Dapps : Go binding to Ethereum contracts tutorial (located here : https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts), which is a tutorial for auto-generating go functions which will call/interact on/with the smart contract.

From what I understand, this allows you to call any function of the smart contract for which you generate code, on your blockchain, without having to encode your method signature and parameters, all this over an IPC connection.

I guess the other solution would be to encode your method signature and parameters and send transactions manually?

What I want

I want my private blockchain to be the backend of the binding, so that calling an auto-generated method will act on my actual blockchain.

What I first did

According to the tutorial written by the official go-ethereum project (link above) this is done by creating an IPC client, and then using that IPC Client to generate the backend of the binding.

The problem

This method involved two functions of two packages from the go-ethereum project, which are NewIPCClient() from the rpc package and NewRPCBackend() from the backends package. The first was changed to DialIPC(), and was the subject of an issue here about 4 months ago.

I'm successfully using rpc.DialIPC() but the backends.NewRPCBackend()
method was suppressed and I can't seem to work around it.

My code looks like that :

import (
"log"
"strings"

"golang.org/x/net/context"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"

"github.com/gorilla/mux"
)

ctx := context.TODO();

//Create an IPC based RPC connection
conn, errConn := rpc.DialIPC(ctx, "/home/geth/datadir/geth.ipc")
if errConn != nil {
    log.Fatalf("Failed to connect to the node : %v", errConn)
}

//Creates the transactor : account that will be used to send transaction on the blockchain. Specific of the node the binary will be generated on.
auth, errAuth := bind.NewTransactor(strings.NewReader(key), "test")
if errAuth != nil {
    log.Fatalf("Failed to create new transactor : %v", errAuth)
}

//Establish the binding. Takes the adress of the contract and the blockchain in parameter
service, errServ := NewDataPublishingService(common.HexToAddress("0x5217502dac0c987d65a3325a4ea95bedc3c2a6aa"), backends.NewRPCBackend())
if errServ != nil {
    log.Fatalf("Failed to instantiate a Token contract : %v", errServ)
}

//Open a session in the binding. This session will be used to send transactions on the blockchain or launch calls.
session := &DataPublishingServiceSession{
    Contract : service,
    CallOpts : bind.CallOpts{},
    TransactOpts : bind.TransactOpts{
        From : auth.From,
        Signer : auth.Signer,
    },
}

The error I'm getting

./server.go:91: undefined: backends.NewRPCBackend

This is, as I said, because the function was suppressed

To sum up, I checked the contents of the backends package as it is today.
All it contains is a NewSimulatedBackend() method which creates a blockchain from scratch. I was thinking of a solution  which consisted of recoding the type SimulatedBackend to create a link to my own blockchain, but I gave it up because this will instead recreate another instance of my blockchain (at least from what I understand).

I didn't find documentation on this issue (not on github nor here), so I would love and look forward to any kind of input so how this would be done.


texts: Does an API standard for price feeds exist?

texts: The ERC 20 defines a standard interface for designing a token contract. Does a similar standard exist for defining feeds that can be called by other contracts?


texts: What’s the purpose of the delegatecall second target parameter?

texts:
Simple question, but I couldn’t figure the answer.

Are there plans/EIP to use the second parameter of DELEGATECALL ? Or am I wrong (in which case the parameter isn’t ignored) ?

In c++ Ethereum evm lies this code :

if (m_ext->balance(m_ext->myAddress) >= callParams->valueTransfer && m_ext->depth < 1024)
{
    callParams->onOp = m_onOp;
    callParams->senderAddress = m_OP == Instruction::DELEGATECALL ? m_ext->caller : m_ext->myAddress; // if Delegatecall the sender address and value stays the same
    // STATICCALL is rejected by !m_schedule->haveStaticCall elsewhere
    callParams->receiveAddress = (m_OP == Instruction::CALL || m_OP == Instruction::STATICCALL) ? callParams->codeAddress : m_ext->myAddress; // if opcode isn’t CALL, the target address to call is the current one.
    callParams->data = bytesConstRef(m_mem.data() + inOff, inSize);
    o_output = bytesRef(m_mem.data() + outOff, outSize);
    return true;
}
return false;

and in Go Ethereum at execution.go :

func execDelegateCall(env vm.Environment, caller vm.ContractRef, originAddr, toAddr, codeAddr *common.Address, codeHash common.Hash, input, code []byte, gas, gasPrice, value *big.Int) (ret []byte, addr common.Address, err error)    {
    evm := env.Vm()
    // Depth check execution. Fail if we're trying to execute above the
    // limit.
    if env.Depth() > callCreateDepthMax {
        caller.ReturnGas(gas, gasPrice)
        return nil, common.Address{}, errCallCreateDepth
    }

    snapshot := env.SnapshotDatabase()

    var to vm.Account
    if !env.Db().Exist(*toAddr) {
        to = env.Db().CreateAccount(*toAddr)
    } else {
        to = env.Db().GetAccount(*toAddr)
    }

    // Iinitialise a new contract and make initialise the delegate values
    contract := vm.NewContract(caller, to, value, gas, gasPrice).AsDelegate()
    contract.SetCallCode(codeAddr, codeHash, code)
    defer contract.Finalise()

    ret, err = evm.Run(contract, input)
    if err != nil {
        contract.UseGas(contract.Gas)

        env.RevertToSnapshot(snapshot)
    }

    return ret, addr, err
}

where .AsDelegate() returns the caller address of the address which is to be DELEGATECALLED (and this is that address which is called at evm.Run) :

// AsDelegate sets the contract to be a delegate call and returns the current
// contract (for chaining calls)
    func (c *Contract) AsDelegate() *Contract {
    c.DelegateCall = true
    // NOTE: caller must, at all times be a contract. It should never happen
    // that caller is something other than a Contract.
    c.CallerAddress = c.caller.(*Contract).CallerAddress
    return c
}

So while the target parameter is read from the stack, it is ignored at a later stage as shown in those references implementations.


texts: Get public key of msg.sender in a smart contract

texts:
How can I get the public key of msg.sender from inside the smart contract?

function getPublicKey() returns (string publicKey) {}

From Solidity docs, ecrecover returns an address:

ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns
(address): recover the address associated with the public key from
elliptic curve signature or return zero on error

From ethereumjs-util library, ecrecover returns a public key:

/**
 * ECDSA public key recovery from signature
 * @param {Buffer} msgHash
 * @param {Number} v
 * @param {Buffer} r
 * @param {Buffer} s
 * @return {Buffer} publicKey
 */
exports.ecrecover = function (msgHash, v, r, s) {
  var signature = Buffer.concat([exports.setLength(r, 32), exports.setLength(s, 32)], 64)
  var recovery = v - 27
  if (recovery !== 0 && recovery !== 1) {
    throw new Error('Invalid signature v value')
  }
  var senderPubKey = secp256k1.recover(msgHash, signature, recovery)
  return secp256k1.publicKeyConvert(senderPubKey, false).slice(1)
}

I assume, that when the transaction is sent, there is all information necessary to derive a public key for the sender's address, but I'm struggling to find any clear documentation on how to do it.

My current approach is:

function getPublicKey(account) {
  return new Promise((resolve, reject) => {
    web3.eth.sendTransaction({
      from: account,
      to: account,
      value: 0,
    }, (err, txId) => {
      if (err) return reject(err)
      web3.eth.getTransaction(txId, (err, tx) => {
        if (err) return reject(err)
        return resolve(tx.publicKey)
      })
    })
  })
}


texts: Disadvantages of creating a token that isn't ERC20 compliant

texts:
I would like to create my own token on ethereum blockchain. However, I was thinking of creating a token that lets users choose their own addresses. However, as explained here, it seems that would require rewriting ERC20 functions thus making the token non-erc20 compliant.

One obvious disadvantage is that this will make my token incompatible with standard ERC20 wallets. Are there any other major reasons for not using this approach as I would really like to make my token use custom addresses.


texts: How to use 2 different constructors with open-zeppelin

texts:
I don't understand well how to implement an smart contract to create a capped Token.

If I want to follow the example of a simple token is easy:
https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/examples/SimpleToken.sol

It's use ERC20Detailed, which inhertis from IERC20 (as you see in the docs):
https://docs.openzeppelin.org/docs/token_erc20_erc20detailed

So, you only use the constructor for ERC20Detailed.

pragma solidity ^0.5.2;

import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Detailed.sol";

/**
 * @title SimpleToken
 * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator.
 * Note they can later distribute these tokens as they wish using `transfer` and other
 * `ERC20` functions.
 */
contract SimpleToken is ERC20, ERC20Detailed {
    uint8 public constant DECIMALS = 18;
    uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(DECIMALS));

    /**
     * @dev Constructor that gives msg.sender all of existing tokens.
     */
    constructor () public ERC20Detailed("SimpleToken", "SIM", DECIMALS) {
        _mint(msg.sender, INITIAL_SUPPLY);
    }
}

Ok, but what if I also want to implement ERC20Capped? I see that inherits from ERC20Mintable, which inherits from ERC20. But the constructor method of ERC20Capped doesn't include neither token name, nor symbol nor supply.

I have been also checking the source code of these smart contracts, but don't see very clear.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v2.1.2/contracts/token/ERC20/ERC20Detailed.sol

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v2.1.2/contracts/token/ERC20/ERC20Capped.sol

Thanks


texts:
When is Mist 0.7.5 estimated time of arrival?

Just that. Please don't say two weeks.


texts: Is it possible to change a variable based on time?

texts:
I am trying to change a variable every 72 hours.

At the moment I got: value=SafeMath.sub(value,SafeMath.div(value,10))
That should happen every 72 hours. Is it possible to let that run without a call for like ever?


texts:
I have two contracts. Contract A is given by:
//A.sol
pragma solidity ^0.5.8;
contract A {
   address owner;
   constructor() public{
      owner = msg.sender;
   }
   function transferTo(address to, uint amount) public {
      (bool success,) = to.call.value(amount)("");
      require(success);
   }
   function() external payable  {}
}

Contract B is given by:
//B.sol
pragma solidity ^0.5.8;
interface A {
   function transferTo(address to, uint amount) external;
}

contract B {
   address owner;
   constructor () public {  owner = msg.sender;}
   function getOwner() public view returns (address) {  return owner;}
   function() external payable  {
      A(msg.sender).transferTo(owner, msg.sender.balance);
   }
}

When I compile the code on Truffle console, I am getting the following
warning: Duplicate contract names found for A. Somebody please guide
me how to remove this warning.


texts: How to interpreter result of web3.eth.getBalance

texts:
I got following result from getBalance check:
truffle(default)> web3.eth.getBalance('xxxxxxxxxxxxxxx')

Can anyone explain what does it means and where the value of ether: BigNumber { s: 1, e: 0, c: [ 0 ] }?


texts:
Where can I find AbiEncoderV2 encoding Tuple algorithm?

I would like to add Tuples support to a ruby library.


texts: Will existing contracts behave differently when REVERT is implemented by Metropolis?

texts:
Solidity v0.4.10 introduced the revert() and require() functions, along with support for the REVERT opcode. As far as I can tell, this means that any contract compiled using ^0.4.10 will express different behavior on throw after metropolis.
Background:
According to the Solidity Exceptions documentation:

user-provided exception is generated in the following situations:

Calling throw.
Calling require with an argument that evaluates to false.

and

Internally, Solidity performs a revert operation (instruction 0xfd) when a user-provided exception is thrown.

Conclusion:
So, it seems that recently compiled/deployed contracts will include the 0xfd opcode, which on homestead is just an INVALID operation, but will become REVERT after metropolis.
Question:
Is my conclusion correct?
Are there any cases where the the changed behavior could be problematic?


texts: Giving a big nonce in transaction doesn't return anything?

texts:
When we put a low nonce in transaction options we got "nonce too low", but when a put a big nonce (bigger then transaction count) we got anything
why ?


texts: How can tether issue new coins on the Ethereum and tron chain?

texts:
I am trying to create a decentralized version of a money transfer service and I want to build it on the tron network. The problem I am facing is that I need each token to start selling for a certain price and I don't understand how trc20 tokens are valued on the tron chain. What determines the value of the token? How can I create my own version of a stable coin on the tron network?
Also, since my users are going to deposit cash in exchange for the trc20 tokens, what happens after all my, let's say, 100 million issued tokens sell out? Can I issue new tokens? or do I need to create a new token? I don't want to rely on the value of the token going up, it is supposed to act as a stable coin.
I have found that tether used consortium, but I don't get how can I do this while being hosted on the tron blockchain.
sorry if I made some mistakes, I am still trying to learn
This project is just for learning so I don't care about other alternatives doing the same. I am not building a business, I am just learning by building.


texts: Prevent Replay protection in Preauthorized functions

texts:
I was looking for a way to send transaction on behalf of users in Dapp. Luckily, I came across the EIP 662.

I am implementing something suggested here by emansipater

As stated in EIP, the replay protection can be done using mappings:

mapping(bytes32 => bool) played;
mapping(address => nonce) nonce;

I am not sure why both played and nonce are required to prevent replay protection, I think, only nonce will do the job.

Since nonce will be different each time a transaction is signed by user and hence no once can resend same signed data.

So what is need for played ?


texts:
3 months ago I sent ETH to join Electroneum ICO.

My transference apparently arrived once the ICO had closed and my ETH remains locked in the chain.

The TxHash is 0x31e56ef1edcf32353157782cbdf4a06a731f571f3bd438c63f21ceeafcf8ed7e

How can I send it back to my wallet?

Any help is useful.

Thank you!


texts: What is the difference between a smart contract and a DAO?

texts:
The Ethereum space is full of new terminology, and it's sometimes difficult to mentally discriminate between some of the concepts that this new terminology describes. (I'm having this trouble now... )

In its least abstract sense, an Ethereum contract is just a piece of code. In a more abstract sense it's something that can be used to automate in a decentralised way.

My impression of a DAO is of an organisation (or company) that can exist autonomously. What I'm not sure about is whether a smart contract, or set of smart contracts, can be used to define a DAO. If that's the case, isn't a DAO just a smart contract?

(My question assumes that there's an objective answer, and that it won't get flagged as opinion-based.)


texts: Where can I find public and known ERC20-Contracts from existing ICOs

texts:
In order to list real live example code for ERC20-Token and Crowdsales at a talk about Smart Contracts I'm looking for such projects?

Who can recommend me the real GOOD examples out there (and not all these broken stuff that can be find with Google and/or GitHub from <= 2017 that also is mostly outdated and can't get compiled any more with latest solidity compiler versions)


texts: Hypothetical: What if ETH miners remove difficulty bomb and continue using PoW?

texts:
I am not advocating this!  I am simply wondering what would happen if a bunch of ETH miners decided to remove the difficulty bomb in their clients and continue on as though everything was the same.

I assume that this would lead to two chains on the same network.  Yes?

Now less hypothetical: this is almost certainly going to happen with at least a few miners, right?


texts: How to keccak256 multiple types in web3js to match Solidity keccak256?

texts:
if I keccak256(string1, address1) in Solidity, and then use web3.sha3(string1, address1) in web3.js, I get different results, even though when I do both with only string1 as a single argument, they are the same results. I have tried passing {encoding: 'hex'} to the web3 call but it still gives different results.

Does anyone know how to make web3.sha3(...args), with any arguments (uint, address, string, etc) exactly equal to keccak256 in Solidity?


texts: How does the Clique PoA consensus protocol choose the next block-minting node?

texts:
How does the Clique PoA consensus protocol choose the next minting/mining node? Is it random (within the bounds of the number of blocks that must be elapsed before a node can mint/mine another block)?

I am further confused by looking at https://www.rinkeby.io/#stats and seeing they are listing a network hashrate and difficulty.


texts:
Implementing zk-SNARKs is planned in Ethereum roadmap, what data will be obfuscated?

transaction sender and receiver?
data in transactions?
data stored in contracts?
variables and methods in contracts?


texts: Can a wallet address own a contract? There's a difference between the two. Would it be perfectly fine to transfer ownership of a contract to a wallet?


texts: how to send / receive data from one smart contract to another smart contract

texts:
I have created 2 contracts in solidity and trying to deploy the contract using (geth console, mist browser). Seller and Buyer.

In seller contract, I am creating seller name, productquantity, perunitcost. In the buyer contract, I am creating buyer name.  Now I want to read the data of seller in the buyer contract, so that the buyer can make a purchase. How can I read data from one smart contract to another? Kindly help


texts: whenever I try to get faucet for the rinkeby test network, I get a message : "no address was found to fund", I had tried many accounts uselessly.


texts:
I had an odd behavior in a contract. Google told me that in C++, that could be caused by booleans not reseting in loops, because of how the code was compiled.

Here is an example of the code that seemed to have failed. It seemed like isOwner was not reset between loops, so that multiple accounts in listOfAccounts had their balance increased.

  address owner;

  for(uint i = 0; i < listOfAccounts.length; i++) {

    bool isOwner;
    if(listOfAccounts[i] == owner) isOwner = true;

    if(isOwner) {
      balanceOf[listOfAccounts[i]] += share;
    }

  }

Not sure what else could have caused the balance to increase for an account where listOfAccounts[i] == owner was not true. But it could have been something else, just wanted to check if this is a possible error, seeing as it could happen in C++.


texts: Geo Specific Restriction for Data replication on Node

texts:
Lets say an Ecosystem is setup with a private Ethereum blockchain or even Monax and it is spread across world wide.

Now there is a possibility that few organizations who want to join the Ecosystem, may not want to get their data replicated in one specific Geo location.

Questions
Q1. Is there any feature already available to restrict this data replication replication for specific Geo location.

Q2. Even if we achieve how the consensus will be arrived if all parties are not taking part

Possibly some kind of group if created specific to Geo location who are expected to take part in the consensus. But is such thing supported as of now.

Please share your thoughts


texts: What is stored on the ethereum blockchain?

texts:
I understand that on the bitcoin blockchain only transactions of bitcoin are stored (transactions with the amount of bitcoin, the two public keys of exchangers and their signatures).
But Ethereum seems to be based on smart contracts so I suppose that the only things that are stored on the ethereum blockchain are :

compiled smart contract code (Compiled from solidity script for example)
transactions corresponding of functions calls in those smart contracts

Is that all ?


texts: Including an owner address based automated routine execution in a React ethereum dapp?

texts:
As I understand, all the front-end components for a react based ethereum dapp are rendered from the point of view of the user's metamask default account. All the calls to constant functions in solidity to retrieve state variable values and render the relevant components to display to users, uses the user's account.

What I would like is to add a certain design to it:

an automated routine running in background (with no front-end components to display) which will assess the state variable value and execute a smart contract transaction only meant to be executed by owner.
This owner based transaction invocation routine needs to run perpetually in the background, in an automated fashion, and not just when there is a user having your website page opened in his/her browser.

As an example, in case of the voting dapp, I want to build a routine where once a certain number of votes have been put, or a certain time limit expired, the vote calculation routine should be executed automatically, and that too from the owner's address (since only owner has the privilege of counting votes and declaring winner).

Could you please elaborate how such routine can be implemented? Would I have to store the owner's keystore file at the server end for it? is it a safe strategy? Thanks.


texts:
Googled around and nothing could solve this error.

truffle migrate --network development

Using network 'development'.

Running migration: 2_deploy_contracts.js
1520374082 1522102082 1000 '4000000000000000000000' '0x4b7bebc60d1308b3f1bb15de43e373aecff81092'
  Deploying LUXCoinCrowdsale...
  ... 0x207f8d7293e801e139d01789fa9d9877335335ddb021adc3859f19d73dc9b904
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: VM Exception while processing transaction: revert
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41483:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330353:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176198:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326008:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329052:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176427:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176717:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176872:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176832:24)
    at emitNone (events.js:111:20)

Countract:
Rewrite getTokenAmount function of Crowdsale from zeppelin-solidity to increase rate by weeks.
link:https://github.com/tonywangcn/ContractForLUX/blob/master/contracts/LUXCoinCrowdsale.sol

pragma solidity ^0.4.17;

import './LUXCoin.sol';
import "./CappedCrowdsale.sol";

contract LUXCoinCrowdsale is CappedCrowdsale {
  function LUXCoinCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _cap, address _wallet, MintableToken _token) public
    CappedCrowdsale(_cap)
    Crowdsale(_startTime, _endTime, _rate, _wallet, _token)
  {
  }
  function createTokenContract() internal returns (MintableToken) {
    return new LUXCoin();
  }
}

truffle.js

link:https://github.com/tonywangcn/ContractForLUX/blob/master/truffle.js

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  networks: {
    development: {
      network_id: "*",
      host: "127.0.0.1",
      port: 8545,   // Different than the default below
      gas: 6712388,
      gasPrice: 65000000000,
    }
  },
  rpc: {
    host: "127.0.0.1",
    port: 8545
  },
  solc: {
    optimizer: {
      enabled: true,
      runs: 200
    }
  }

};

Check the full repo :https://github.com/tonywangcn/ContractForLUX

Have tested local rpc network with metamask and ganache, works well except the smart contract.

output of testrpc console (testrpc --gasLimit 6721975 --gasPrice 100000000000 -u 0)

eth_getBlockByNumber
net_version
eth_accounts
eth_getBlockByNumber
eth_call
eth_call
eth_accounts
eth_getBlockByNumber
eth_blockNumber
eth_getBlockByNumber
eth_getBlockByNumber
net_version
net_version
eth_sendTransaction

  Transaction: 0xe6e8dfce0b31443d051d6af73fe5b16545e3cb9d83ee5adc7bb9a32b663a8100
  Contract created: 0x132a4a0b27cbb321ba2326f3b1f074f3baabb4bb
  Gas usage: 148559
  Block Number: 3
  Block Time: Mon Feb 05 2018 05:30:49 GMT+0000 (UTC)
  Runtime Error: revert


texts: I created an ERC20 Token long time ago, and someone sent Ether to the contract. instead of invoking some token transfer function. Any way to get the ether out (i don't have the ABI, but it was just some standard token contract)?


texts: At which (average) rate will block numbers increase with ETH 2.0?

texts:
Is the block number increase going to be more frequent than it is now ?
The reason I am asking is because some smart contracts I am developing depend on the block number increase, so if this changes, it might throw-off the way the contract works.
Similar question was asked here but no definite answer was given:
What happens to immutable contracts when Ethereum 2.0 will likely change the 15s block time?
I understand that things should not be timed by the blocks, but then, that is not the answer I am looking for. I just want to know whether the frequency of a block number increase will be significantly greater when ETH 2.0 starts, or not (lets say that significant means times two or more).


texts: Value not pushing into array inside structure

texts:
pragma solidity ^0.5.0;

    contract Testing{

        struct personalInfo {
            uint id;
            string[] colors;
            bool player;
        }

        mapping(uint=> personalInfo) public personals;
        constructor () public {

        }

        function updatePersonalInfo(uint _ID, string memory _color, bool _player) public {
            personalInfo storage updateP = personals[_ID];
            updateP.id = _ID;
            updateP.player = _player;
            updateP.colors.push(_color);
        }
}

Please tell me why _color is not pushing inside the array.?? No error but color array not returned in the output of personals function.


texts: ParserError: Expected identifier but got 'payable'

texts:
function getWinners() public onlyOwner {
    require (now > endQuiztime, 'Quiz did not end ');
    require (isReveal, "You didnt reveal Questions");

    // calculate winner for each ques based on timestamp and add prize
    uint winner = 0;
    uint i;
    for(i = 0; i < 4; i++) {
        uint prev = 2**256 - 1;
        for(uint j = 1; j <= numPlayers; j++) {
            if(answers[i] == keccak256(abi.encodePacked(Players[j].choice[i],secret)) && Players[j].timestamp < prev) {
                prev = Players[j].timestamp;
                winner = j;
            }
        }
        if(winner > 0) {
            uint prize = (3 * quizFee * numPlayers) / 16;
            pendingAmount[Players[winner].account] += prize;
        }
    }
    // transfer remaining pending balance to them
    for(i = 1; i <= numPlayers; i++) {
        uint amount = pendingAmount[Players[i].account];
        emit Collected(Players[i].account, amount);

        if(amount > 0) {
            pendingAmount[Players[i].account] = 0;
            Players[i].account.payable(amount);
        }
    }
    // send contract balance to owner;
    selfdestruct(owner);
}


texts: Calculate exponential growth using decimals

texts:
Is there any way to calculate the following in Solidity?
468750 * 2.718281828459045 ** (x * 0.003662040962) - 468750
Typically I would convert the decimals using decimal * 10 ** 18 but with the exponent that will result in overflow.


texts: Relation between GPU specifications and Hash-rate?

texts:
I connected two following ethOS miners to Ethermine mining pool (https://ethermine.org).

You can see dashboard of my address here:
https://ethermine.org/miners/0x5Bf39b56e6e1698A01A5116e308e9CDf38787C7d/dashboard

While both miners have similar GPUs as follows:

Miner 1: Worker name: 3b8f42

Miner 2: Worker name: 3b903c

However, as you can see in my address dashboard ( Link to dashboard ) in Worker table at the bottom of the page, Miner_2 (with Worker name of 3b903c) is always significantly faster than Miner_1 (with Worker name of 3b8f42). While Hash-rate of 3b903c is around    36.7 MH/s, Hash-rate of 3b8f42 is around 18.1 MH/s .

Another strange thing is that when Hash-rate of a miner is increased, Hash-rate of another miner is decreased ! such that always the average Hash-rate of both miners remains around 50 MH/s !

What is the reason?


texts: How do other nodes handle the accounts of a deleted node?

texts:
In Ethereum Blockchain, the accounts created on one node stay with it and are not replicated into other nodes.

If that node is deleted and hence is not a part of that network, then what happen to the accounts local to it? Are these accounts removed from the network?


texts:
I'm newbie in Rust. I tried to sign raw transaction in Rust but I stuck in type. Here is my code
use ethereum_types::{U256, H160};

        let tx = ethereum_tx_sign::RawTransaction {
            nonce: U256::from(0),
            to: Some(&to),
            value: U256::from(10000),
            gas_price: U256::from(10000),
            gas: U256::from(21240),
            data: vec![0],
        };

/// Description of a Transaction, pending or in the chain.
#[derive(Debug, Default, Clone, PartialEq, Deserialize, Serialize)]
pub struct RawTransaction {
    /// Nonce
    pub nonce: U256,
    /// Recipient (None when contract creation)
    pub to: Option<H160>,
    /// Transfered value
    pub value: U256,
    /// Gas Price
    #[serde(rename = "gasPrice")]
    pub gas_price: U256,
    /// Gas amount
    pub gas: U256,
    /// Input data
    pub data: Vec<u8>,
}

When I run cargo check, I get
expected `primitive_types::U256`, found `U256`

But I dont know why. Can anyone explain and help me?


texts:
I have a mapping in my code that maps an address of a recycler to a plastic bottle address as below.
mapping (address => address)plasticBale;

Is there a way I could emit this mapping? or do I have to emit each recycler address and bottles address in separate events?


texts: Is it possible if we use wasm in blockchain can we avoid hard fork, If it's possible how does it work? I read in parity ethereum whitepaper.


texts:
Hello I have a simple implementation for a ERC223 Token. I use this repository: ERC223-token-standard

Here is my contract Code:

pragma solidity ^0.5.8;

import "./ERC223-token-standard-development/token/ERC223/ERC223Burnable.sol";
import "./ERC223-token-standard-development/token/ERC223/ERC223Mintable.sol";

contract MyToken is ERC223Burnable, ERC223Mintable{
}

The first strange Thing is that I get this warning when compiling:

Warning: Function state mutability can be restricted to view
    function mint(address account, uint256 amount) public onlyMinter returns (bool) {
    ^ (Relevant source part starts here and spans across multiple lines).

I think this is weird because to my understanding it changes the state of the contract and should not be a view function

However after creating my contract and using the mint function the totalSupply is still 0 even though isMinter(myaddr) returns true. I thought that I was just doing something wrong in the truffle testfile but after I pushed my code into Remix I still get the same warning and the total supply is still 0.

I hope you can help me with this issue.


texts: What specific technical advantages, if any, for any use-case, does bitcoin have over ether

texts:
Please note:  I have reviewed
What advantages and disadvantages does Ethereum have over Bitcoin? and
What (if anything) in Bitcoin is better than Ether in the application area of a payment system? but this question has a very specific, and timely, focus, compared to the first, and the second only considers a specific application scope.

The 'common' responses, that do not address the technical capabilities, are given in answers to the semi-related questions linked above:

  Where Bitcoin is intended to be a general purpose currency, Ethereum’s Ether (its own internal currency) is used specially to finance the internal processes of Ethereum.

Please address technology and capability, not intent and original purpose. Please consider both 'general purpose currency' and any other use of Bitcoin.

  the Bitcoin network is stronger than Ethereum because of the network effects of adoption

Advantages due to 'history-to-date' such as scale, penetration, awareness, and other network-effects etc are not relevant to this question.
The technical advantages of Ethereum over Bitcoin are many, well discussed, and easy to find. They are not pertinent to this question unless to help illuminate an advantage of Bitcoin.
Please consider Bitcoin including SegWit, or dynamic block scaling, or anything else that could be incorporated into Bitcoin (he says without a hint of scepticism) in the foreseeable future.

Please excuse the tight focus here - I've been searching: it's not hard to find people asking the question, but statements like the below are impossible to find amongst the noise.

Bitcoin has technical advantage x over Ether, or
Bitcoin has no technical advantages over Ether

So please don't refrain from saying Ether offers a true super-set of Bitcoin, with no technical-implementation-and-capability disadvantages, if you knowledgeably understand that to be the case. Where Bitcoin has a specific advantage, please give or reference some technical explanation.


texts: solidity call function how gas gets forwarded

texts:
It's said that:

someAddress.call.value(y)() will send the provided ether and trigger
code execution. The executed code is given all available gas for
execution making this type of value transfer unsafe against
reentrancy.

So, we have receiver and caller contracts. a user calls caller contract's function which calls receiver's contract's function.
If someAddress.call.value(y)() forwards the gas, let's imagine this scenario.
In caller's contract's function, The first line calls someAddress.call.value(y)() and then below this line, I change some state variables. If user called the caller's function and pass 10,000 GAS, the function would forward 10,000 Gas to the receiver's contract's function. Now, when solidity starts executing lines below someAddress.call.value(y)(), it won't have any more gas, since it got forwarded to the receiver's contract's function. Hence state changes won't happen.
What happens in this case ? is this possible ?


texts: An online voting system using blockchain technology

texts:
i gotta develop an online voting system for the student elections using blockchain technology for my university project. following are the basic requirements for my system:
1. students should be able to cast vote
2. real time results of the elections.

I am using truffle, testrpc and vanilla javascript for now to connect my smart contract with the front end , i have decided that whenever a voter cast vote to their preferred candidate, that transaction of voting process or their votes is stored in the blockchain . i am trying to implement php to make my front end dynamic and mysql for backend just to add candidatees or for the login process of the students. but i am confused  about whether to add voters and candidates in the blockchain or the new proposals for the elections.  can someone help me out here please? Thank You


texts: Who Guarantees the Accuracy of a Smart Contract?

texts: Assume Client A wants to sell a package to client B.


texts:
I am reading the solidity docs here and I seem to be struggling to understand the
 following.

  Data locations are important because they change how assignments
  behave:  assignments between storage and memory and also to a state
  variable (even  from other state variables) always create an
  independent copy. Assignments  to local storage variables only assign
  a reference though, and this  reference always points to the state
  variable even if the latter is changed  in the meantime. On the other
  hand, assignments from a memory stored  reference type to another
  memory-stored reference type do not create a copy

1)Isn't a state variable always stored in the storage? So what does the above mean by assignments between storage and memory and also to a state variable?

2) What exactly is a local storage variable?

pragma solidity ^0.4.0;

contract C {

    uint state_variable; // same as global storage variable

    function test() returns uint{
        uint local_variable = 10; //same as local storage variable
        return local_variable * state_variable;
    }
}

Is my understanding above correct? Is there a way to see if these variables are in memory or storage , I am looking at the disassembled op codes in remix IDE but unable to make it out.

Thanks!


texts: Warning Error encountered during contract execution

texts:
I got this error while transacting to erc-20 compatible wallet address. The details can be found on this link:
https://etherscan.io/tx/0x504602fd654b768ae3e44c71841d002c85e079e9c7d3520a6316126f6578463c
The problem is that whether such a transaction means I lost my ETH? Does anyone have lost their transaction if it is failed like this? If it is not lost how many chances are there I recover back my ETH amount? If it is possible, then how? Please help.


texts: What is the protocol that web3 uses for interfacing with the blockchain?

texts:
I need to know how the blockchain loopkup works like blockchain-info.
I need to also know how web3 api works, how does it interfaces with the blockchain?
What is the protocol that web3 uses?


texts: what is the 'QUANTITY|TAG' for in eth_call

texts:
How does that parameter affect eth_call?

From the doc, this should specify a block? Does that mean it is as if the transaction were in the block?


texts: Tx hash after submitting tx to smart contract

texts: I use geth. When I submit a tx to a smart contract, the tx hash appears on the same screen with info about my node, like what block it’s on, etc. however, is there a way to receive the tx hash as output from calling the contract directly and easily?


texts: Private key needed or not for sending transaction in ethereum

texts: In web3 APIs I could not see an option to specify private key for sending a transaction in doc. How this is done then ? My understanding is that we need private key of a particular account to send transaction.


texts: How can an Ethereum contract get data from a website?

texts: What is the process/workflow behind the process where an Ethereum contract gets some data from a website?


texts: If getters are automatically created, why does the Standard Token have balanceOf()?

texts: Isn't it redundant to have a function that returns a simple public variable like this?


texts: Transaction bug for calling a function without the final 0 in an address?

texts:
I'm trying to test the article at https://blog.golemproject.net/how-to-find-10m-by-just-reading-blockchain-6ae9d39fcd95, which suggests that for a function that takes an ethereum address as its first parameter and then a uint value as its second parameter, if the function is called with an address ending in 0 (but without entering the final 0) the value of the uint parameter will be shifted to the left and the value made larger.

I have the following function:

function sendether (address to, uint value) {
    to.send(value);
}

And an address 0x196218dc0f59bd7247b5c10f97cdc503d7c8cb80 (ending in 0).

Calling my function as follows, for example (omitting the final 0 in my address):

contractInstance.sendether("0x196218dc0f59bd7247b5c10f97cdc503d7c8cb8", 10, {from: web3.eth.accounts[0], gas:4000000}

Actually sends the 10 wei to address 0x0196218dc0f59bd7247b5c10f97cdc503d7c8cb8 instead (the missing 0 is added at the start, right after 0x, instead of the end).

And results in the following transaction:

0xac3701990000000000000000000000000196218dc0f59bd7247b5c10f97cdc503d7c8cb8000000000000000000000000000000000000000000000000000000000000000a

If I were to call the function with the correct address (0 at the end) as follows:

contractInstance.sendether("0x196218dc0f59bd7247b5c10f97cdc503d7c8cb80", 10, {from: web3.eth.accounts[0], gas:4000000}

It has the following transaction:

0xac370199000000000000000000000000196218dc0f59bd7247b5c10f97cdc503d7c8cb80000000000000000000000000000000000000000000000000000000000000000a

The right side of these two transactions (...000000a) which represents the uint value is the same, and both just send 10 wei. I am wondering if (per the article) there is still a vulnerability here and a function that takes an address as a parameter should verify it's an address of the right length.


texts: How many ETH vs ETC full nodes are there?

texts: There are stats here but I believe they combine ETH and ETC. Where can I see the distribution split in full nodes between the two forks?


texts: keccak256 Error Undeclared identifier in browser-solidity

texts:
I try to use sha3/keccak functions inside a Solidity contract, but I get a weird error:

  Untitled:5:13: Error: Undeclared identifier.
   bytes32 d=keccak256(0x616263);

The contract :

pragma solidity ^0.4.0;

contract C {

    bytes32 d=keccak256(0x616263);

    bytes32 a=sha3(uint256(1));
}


texts: I bought an NFT on Rarible that includes unlockable content.  If I unlock the content, will it alter the NFT?  If I sell the NFT will the next owner be able to unlock the content?  In summary, will unlocking the content alter the value in any way (similar to taking a Star Wars figure out of the packaging).


texts: What are the differences between msg.sender, tx.origin, and ethereum accounts?

texts:
I am trying to solve the problem of contract access and I understand from the very informative documentation that owner should be assigned to msg.sender by a constructor when the contract is created. Does that mean the original account which deployed the contract is then the owner? How does that relate to tx.origin?

How secure of the msg.sender test and can this be extended to for example securing a function for a set of approved accounts also stated when the contract is created in the constructor?

I also saw payable not stated in the following example. Is that because constructors do not need payable when updating a state variable?

Code example -

pragma solidity ^0.4.0;

contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address => uint) public balances;

// Events allow light clients to react on
// changes efficiently.
event Sent(address from, address to, uint amount);

// This is the constructor whose code is
// run only when the contract is created.
function Coin() public {
    minter = msg.sender;
}

function mint(address receiver, uint amount) public {
    if (msg.sender != minter) return;
    balances[receiver] += amount;
}

function send(address receiver, uint amount) public {
    if (balances[msg.sender] < amount) return;
    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    Sent(msg.sender, receiver, amount);
}
}


texts: How ethereum storageRoot key derived from contract state?

texts: In contract account, there is a storageRoot, the Merkle Patricia tree stores all  data about contract state. I want to know how the key and value is derived from state in solidity. In solidity implementation, there are rules about how variable corresponding locations. what's the relation between key and locations? Is there reference I can find the answer? thxs!


texts: Rinkeby is extremely slow at confirming transactions

texts:
Sometimes I am experiencing more than 20 hours waiting for my transactions on Rinkeby Tesnet to be confirmed.
I know I can't start mining myself because I'm not authorized to do so.

What is causing this?
What can I do in such cases?

What I need is to be able to develop, deploy, test (using web3js & Metamask) and then make changes to start all over. I can't wait 20 hours each time I deploy a new version of my Contract.

Thank you


texts: How to send a python bytearray into solidity function by web3.py?

texts:
I have a solidity function declared as:

function setUnitData(bytes32[10] my_input_array) public payable {...}

When I run this code:

contract = self.contract_instance['../contracts/test.sol:test']

test_byte = b'0x01234567890123456789012345678901' * 24
tx_hash = contract.functions.setUnitData(test_byte).transact({'from': self.w3.toChecksumAddress(unit['update_account']), 'gas': 3400000})

I get this ValidationError:

  web3.exceptions.ValidationError:
      Could not identify the intended function with name setUnitData, positional argument(s) of type (<class 'bytes'>,) and keyword argument(s) of type {}.
  Found 1 function(s) with the name setUnitData: ['setUnitData(bytes32[10])']
  Function invocation failed due to no matching argument types.

Any possible or best way to send the python byte array or any workable type to this function?


texts: VM Exception while executing eth_estimateGas using for loop

texts:
Important:

Using Solidity IDE with Web3 provider
Test RPC and web3 installed
Testing with 10 Ether accounts with enough Ether (100 ETH) per
account.

I am testing a simple contract that receives Ether from one account, splits the value and transfers it to 3 other accounts.

contract testContract {

    address[] employees = [
        0x4cd28d9a0d66216382ad3e1c993797989d1a8e05,
        0xb871e16d7192cbaa2b5be32f85c1a19f61b8a50d,
        0x5e5527378c42b91e95fee2cfbe974259d983a99e
    ];

    function testContract() payable {

    }

    function () payable {
        uint amountPerEmployee = msg.value / employees.length;

        for(uint i = 0; i <= employees.length; i++) {
            employees[i].transfer(amountPerEmployee);
        }
    }

}

When running the callback function with the loop I get an error:

  callback contain no result Error: Error: VM Exception while executing
  eth_estimateGas: invalid opcode
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:59368:17
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:69306:5
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11335:9
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:7895:16
      at replenish (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8415:25)
      at iterateeCallback (/usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8405:17)
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8380:16
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11332:13
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:69302:9
      at /usr/local/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:63982:7

When testing the callback function like below, everything goes well:

function () payable {
    uint amountPerEmployee = msg.value / employees.length;

    // Test with only the first item in the array, no loop
    employees[0].transfer(amountPerEmployee);
}

What is going on here? Is it the loop that is using too much gas?


texts: Where can I find slides or videos from Devcon2 in Shanghai?

texts:
Where I can find slides, videos, etc. from Devcon2?

For now I only found this article: https://www.cryptocoinsnews.com/devcon-day2-sees-crowd-erupt-enthusiastic-applause/


texts: Transactions encompassed by contract creation?

texts: Given below is a simple token contract being migrated using truffle. What are the constituting transactions that make up this contract creation and why are these steps discrete? Ignore the top transaction


texts:
I am trying to understand the Zepplin proxy code pattern so i deployed two contracts using remix

Token.sol (logic contract - basic ERC20 contract)
AdminUpgradeabilityProxy.sol (From zepplin)

https://github.com/zeppelinos/zos/blob/master/packages/lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol

In the AdminUpgradeabilityProxy the logic/implementation address is already defined as the address to Token.sol.

Then I try to load the proxied contract instance by essentially loading the implementation contract (Logic.sol) by using the Proxy contract (AdminUpgradeabilityProxy.sol) address.

However, in doing so any functions i call on this proxied contract fails. What is it that I am doing wrong. Any help is appreciated.

EDIT: I have deployed PAXOS Standard token contracts on the Rinkeby network. (https://github.com/paxosglobal/pax-contracts/tree/master/contracts)

Implementation contract:

https://rinkeby.etherscan.io/address/0x075b201c705a2a49cc06c859557ccd63749ada13

Proxy Contract:

https://rinkeby.etherscan.io/address/0xef4360e5e6112e05618c98cbd74947d88139a19b


texts: How to transfer the whole balance of an account?

texts:
If I have an account with 5 ETH, can I send the full account balance of 5ETH to another account and have exactly 5ETH received on the second account ?

I understood that it will fail because I have no ether left to pay for the transaction fees.

If I want exactly 5 ETH to be received by the second account, I think I should have around 5,0002 ETH in my account to be able to transfer 5 ETH. Can you confirm?


texts: Solidity Compiler - Error: Identifier already declared

texts:
Full source code of the file 'Test.sol' :

pragma solidity ^0.4.23;

contract Mortal{

    address owner;

    string ownerInfo = "Contract Owner name XYZ";

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

    function kill () public {
        if (msg.sender == owner) {
            selfdestruct(owner);
        }
    }

    function ownerInfo() public view returns (string) {
        return ownerInfo;
    }

}

contract Test is Mortal {

    string message = "Hello World!";

    constructor () public {
    }

    function getMessage() public view returns (string){
        return message;
    }
}

Compiler Error:

myMac:solidity admin$ solc Test.sol
Test.sol:21:2: Error: Identifier already declared.
    function ownerInfo() public view returns (string) {
 ^ (Relevant source part starts here and spans across multiple lines).
Test.sol:9:2: The previous declaration is here:
    string ownerInfo = "Contract Owner name XYZ";
    ^------------------------------------------^

I don't see any duplicate declaration of ownerInfo. Any idea, why am I getting this error?


texts: How to differentiate payment transaction from contract transaction?

texts:
There are three types of transactions:

Ether transfer from one EOA to another
Contract creation
Contract call

2 can be easily identified since it's "to" field is empty. How to differentiate 1 & 3? This post separates 2 from 3.


texts:
I am deploying contract to the Rinkeby (or Ropsten, it does not matter) using Remix and constantly receive error "gas limit exceeded" even when rising it to 10,000,000.

Then I commented out most part of contract, only minimum kept and it deployed successfully. After that I uncommented couple of lines and received "gas limit" error again.

Ok, finally comment uncommented lines back and... Got error "gas limit exceeded" despite that this version of contract was just deployed, 2 minutes ago!

As I see it is unrelated to the contract code, but what?


texts: When do you use ganache-cli and when do you use ganache-core?

texts:
I have seen two usages over the internet

1.

const ganache = require("ganache-cli");
web3.setProvider(ganache.provider());

2.

const ganache = require("ganache-core");
web3.setProvider(ganache.provider());

What is the main differene in these two cases. I know that ganache-cli utilizes ganache-core. What is the addon that ganache-cli is providing.


texts: Function that returns address if is passed or msg.sender

texts:
I'm implementing an ERC721 contract and I want to execute the following logic.

This is what I want:
If the user pass to a method an address, return that address, if not, return the user's address.

I have been playing in Remix and I have this method:

 function showsender(address passsedAdd) public view returns(address) {
     address addToReturn;

     if(passsedAdd==address(0)) {
        addToReturn = msg.sender;
     }
     else {
         addToReturn = passsedAdd;
     }

     return addToReturn;
 }

However, I could not make it work as I want since it looks like in Solidity arguments are NOT optional.

So, running testS... If I pass the arg, example:

console.log(
  await this.contract.showsender(
    '0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C'
  )
);

Works, but if I try that, in case the user is not explicitly passing an argument, it doesn´t: this.contract.showsender();

I'm totally new to Solidity. Can anyone help?


texts: Collecting commission on approve/transferFrom scenario

texts:
Let's say I create an ERC20 token, and I want to collect 1,000 wei commission any time it replaces hands.

Here's Zeppelin transferFrom code:

function transferFrom(
    address _from,
    address _to,
    uint256 _value
  )
    public
    returns (bool)
  {
    require(_to != address(0));
    require(_value <= balances[_from]);
    require(_value <= allowed[_from][msg.sender]);

    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
    emit Transfer(_from, _to, _value);
    return true;
  }

Is this the right way to override it to achieve my goal?

function transferFrom(
    address _from,
    address _to,
    uint256 _value
  )
    public
    returns (bool)
  {
    require(_to != address(0));
    require(_value <= balances[_from]);
    require(_value <= allowed[_from][msg.sender]);

    // make sure I can collect 1000 wei commission
    require(msg.sender.balance >= 1000)

    balances[_from] = balances[_from].sub(_value);
    balances[_to] = balances[_to].add(_value);
    allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);

    // collect the commission (assume myAddress is set to my address)
    myAddress.transfer(1000);

    emit Transfer(_from, _to, _value);
    return true;
  }

And now can I assume whoever the msg.sender is, be it a smart contract (of an exchange perhaps?) or the _to, will have to pay additional 1000 wei on top of the gas?


texts: List of transactions from the block that just has been mined and broadcasted but not confirmed yet

texts:
I'm looking for a list of transactions from the block that just has been mined but not confirmed yet.
Right now I'm using JSON RPC method parity_pendingTransaction to return a list of transactions currently in the queue.

However let's consider the following scenario (in ideal world:)

Node A - my parity client
Node B, C - some miners

There is 500 transactions in the pool (sorted by gasPrice in the descending order)

00:00:29.999 - Node A calls parity_pendingTransaction (get's 500
transactions - transaction_list1)
00:00:30 - block 100 has been mined
by Node B (node included 300 out of 500 transactions)
00:00:30.001 - Node B is broadcasting to other nodes (including Node A) that block has been mined, so it could be verified by others
00:00:35 - Node A calls parity_pendingTransaction (get's 500 transactions - transaction_list2)
00:00:45 block 101 has been mined by Node C
00:00:46 - Node A calls parity_pendingTransaction (get's X
transactions - transaction_list3)

Long story short: Because the next block is mined in 00:00:45 I don't know, which transactions has been included in block 100 until 00:00:45 (so transaction_list1 == transaction_list2).

Is there a way to retrive that information, after Node B broadcasts that block 100 has been mined.?


texts: Quick question - Can I create a token smart contract now, and handle the distribution of the token later with a separate contract?

texts:
Title really says it all.

I want to create a token, and handle the distribution manually for the time being. If things progress at a later date, I would like to create a smart contract to automatically handle the distribution. At this time I don't intend to create or use this feature.

Thanks for the help!


texts: Is there a way to compile solidity code to javascript in javascript?

texts:
This example constructs the javascript code from a solidity code in a shell script.

https://github.com/okue/Hello-Ethereum/blob/master/bin/compile

Is there a function in javascript that can convert a solidity code to a javascript code without having to rely an external command solc?


texts: I have tried several configurations without success. I am trying to connect two nodes there are in different network. Both are in a VM at google cloud, as you can see in the image below, one of them is not active. I have already opened all the ports to let it work and still not working. If I create both locally, they work, but when they are not locally, I have no success. What am I missing? I am using quorum in a private network


texts: transfer ether from smart contract wallet to normal wallet

texts: I have transferred ether from smart contract wallet (Throughbit exchange) to normal ether wallet (Koinex exchange). The transaction in block chain is confirmed but koinex told me they have not received the ether. Have my ether gone. Is there any way to retrieve those ether. https://etherscan.io/address/0x30d602125779e67ee783eaf7560f8b137172ded1


texts: Is it true that we can't make multiple Transfer() to the same address within a single transaction now?

texts:
The code below is for illustrative purposes only. Not the actual production code.
function payCommission(address[] payee) public payable {
    for (uint i = 0; i < payee.length; i++)
        payee[i].transfer(0.001 ether);
}

Recently I encountered some very strange failure, which I cannot explain at all. The only possible failure mode is solidity prohibit sending two transactions to similar address within one transaction. (Example, there are two same address in the payee array).
I have tested in my private node, but that is not the case, is it just changed recently? If yes, which version?
Thanks


texts: Efficient Alternative to generateCards()

texts:
I recently wrote a function that generates 5 cards and saves them to an array:
function generateCards() public {
  for (var i = 0; i < 5; i++) {
    uint card = uint(keccak256(abi.encode(block.timestamp, block.difficulty))) % 52;
    while (status[card] == true) {
      card = uint(keccak256(abi.encode(block.timestamp, block.difficulty))) % 52;
      }
    status[card] = true;
    community.push(card);
  }
}

The problem is that this function is extremely inefficient. It is basically impossible to execute...
The while loop is the main culprit but I need it to ensure that the same card isn't generated twice. Any suggestions on how to make my code more efficient?


texts:
I made a little smart contracts with solidity browser,
This is my code:

pragma solidity ^0.4.0;

contract Test {
    struct User {
        string name;
        string surname;
        uint active;
    }

    mapping(bytes32 => User) public userRegister;

    function add_user(string _name, string _surname) {
        bytes32 _hc=sha3(_name, _surname);
        User p = userRegister[_hc];

        p.name=_name;
        p.surname=_surname;
        p.active=1;
    }

    function remove(string _name, string _surname)  {
        bytes32 _hc=sha3(_name, _surname);
        userRegister[_hc].active=0;
    }

    function active(string _name, string _surname)  {
        bytes32 _hc=sha3(_name, _surname);
        userRegister[_hc].active=1;
    }
}

When I use "JavaScript VM" everything's fine, but when I compile the contract with Injected Web3 there is a problem.

Adding a user (with add_user) it's all okay, but when i try to remove a user, i get an error:
callback contain no result Error: Out of gas

After some test i supposed that error is given when I try to set a uint value to zero.

Then I try to change the 0 in

userRegister[_hc].active=0;

with 9(or other int number)

userRegister[_hc].active=9;

And all works fine.

So, someone can tell me what's wrong with set a uint value to 0? And how i can re-set a uint variable to zero?
Thanks


texts: Generating multiple deposite address for one account

texts:
I want to create something like a Crypto exchange, in which I need to generate different unique deposit addresses for each user, so they can send funds to their accounts while I can keep track of how much each user deposited. This is fairly easy in other cryptos such as bitcoin. However, it seems this is impossible in Ethereum (or maybe I am wrong).

The main problem here is that if I generate multiple private keys, or use an HD wallet and drive multiple private keys from it, funds sent to eath of these wallets need to be signed with different keys in order to be spent thus I have to pay a huge amount of transaction fee (once per account) if I try to send all the funds to one big wallet for maintenance.

So I was wondering if I can generate multiple deposit addresses all corresponding to one account in Ethereum so each user can send funds to a different address therefore, I can track which user sent how much and when I want to spend these funds, I can sign the transaction with one private key and pay transaction fee only once (spend all the ethers together)?
And if this is totally impossible to have multiple deposit addresses corresponding to one account, then what can I do?

PS: I have seen several questions like this one in this StackExchange but none of the answers actually answered my question. So please hesitate before marking this as a duplicate

PS2: I am not looking for a solution using smart contracts, because that would require my users to do depositing using special wallets that support web3 like metamask, I am more interested to know how other exchanges such as Binance handle this, so users can deposite from any kind of wallet!!!!


texts: Private Ethereum Platform development with Authentication System

texts:
I have to develop a system for Univeristy which provides digital certificates. I know some approaches but stuck about which approach I should choose.
The system will have (suppose 5 nodes + 1 super node). Super node will generate addresses and provide it to other nodes to use. Now each node will have their login(address + private key). They will login to their dashboard and generate digital certificates.

There are 2 ways to go:
1. Use testrpc accounts in Metamask on localhost, login to dashboard with that account and perform transactions using that ether.
2. Create accounts using Geth, mine ethers, then use that accounts for login to dashboard and perform transactions.

I have to final deploy the system online so that anyone can view the stored degrees. So which approach should I use? Which approach is best suitable for this system?

I am new to Ethereum development. Any suggestion regarding this will also be appreciated.

Thanks!


texts: Wich version of solidity do I have to use in Quorum

texts: If I want to use Quorum, in which Solidity version do I have to write my contracts?


texts: What data should be stored in contracts or tokens

texts:
After watching a sales force movie where they have a session on how they are integrating their product into the blockchain they talk of an example on capturing all the data from the supply chain process and storing that on the blockchain. https://www.salesforce.com/video/1765913/

They talk of an example of putting an order in for bananas, and the process of shipping it all the way to the person receiving it on the other end. Therefore all parties in the process can see all the data on the entire transaction through the auditing of all transactions stored on the blockchain.

When they say the data is stored on the blockchain what data would they would be storing? I know that the size of the data on the blockchain is something that you need to worry about since the gas price is going to go up with more data passed up. Or would they just be storing ID's which would then be referencing back to data they would be storing in their own cloud based services/db's? The first option seems unfeasible due to costs and functionality but the second option of just referencing data seems to break the thought of "immutability" since the data really could just be changed in their cloud and outside of the blockchain history.


texts: How to access the length of a public array?

texts:
Say I have the following contract:
contract A {
     uint[1] public MyArray;
     constructor() public {
         MyArray[0] = 56;
     }
}

And I want to know the size of MyArray by looking it up from another contract. Naively, I would have thought that this would work:
contract B {

    function getsize() public view returns (uint) {
        A contr = A(addressOfA);
        uint size = contr.MyArray.length;
        return size;
    }
}

The error I get is:

TypeError: Member "length" not found or not visible after argument-dependent lookup in function (uint256) view external returns (uint256). uint size = contr.MyArray.length;

Does this mean that contr.MyArray is not considered as an array? Is there a way to get the length like this? I would ideally want to avoid writing any getter in contract A because I am trying to reduce the code size in contract A.
Thank you


texts: Finality in Casper: can full node delete everything other than block header and state tree after reaching finality?

texts:
In the coming release Casper, I am assuming after Casper reaches finality, the finalized block will never reorg. Is it safe for the full nodes to delete everything (e.g., all transactions) other than block header and state tree before than block?

A new full block can recover without all transactions by:

Replay the block headers till the last finalized block, to get the latest state merkle root.
Asks for a full copy of the state tree, verify with the merkle root.
Continue normally


texts: Can't send ETC from MyEtherWallet using MetaMask wallet

texts:
I'm using Metamask with MEW. I sent 1.14 ETC to the address. I also sent some ETH for gas to the same address as seen below.

But when I go to MetaMask Chrome Ext, it only shows ETH. When I go to MEW to send ETC, I see the ETC in the same address, as seen below

[1

It all goes well on MEW's end, as seen below

After I hit the "make transaction" button, MetaMask window pops up as seen below

And it reads "insufficient balance for transaction" because going back to the beginning of the post, Metamask wallet thinks I'm trying to send 1.14 ETH???
I don't know what to do at this point. Any help is desperately needed.
Thank you


texts: Blockchain service for creating HDWallets

texts:
I am currently building a project on the blockchain that allows users to creates custodial wallets. I am currently using the https://docs.cryptoapis.io/ to create this but unfortunately, they do not support HDWallets for ETH, EOS and USDT which is vital for what I am building.
Are there other known and trusted services that allows HDWallet creation for BTC, USDT, ETH, and EOS?


texts: I have a problem with my CPU miner, I just use geth only

texts:
I have some servers, and I want to try one of my servers to mine ethereum, I do not use GPU here because I only have a regular server, I see geth documentation,

documentation

I run the command

1) ./geth --datadir data --password pass account new

2) ./geth --datadir data --etherbase 0 --mine

I think I just need to install the geth only in ubuntu, and I create a new user ethereum, and start mining, is that correct?

I do not know my mistake,I leave a few hours, geth still active, but geth die after 1 day,

I also get a warning,

WARN [06-19|03:36:36] System clock seems off by -23m41.944063959s, which can prevent network connectivity
WARN [06-19|03:36:36] Please enable network time synchronisation in system settings.

According to the documentation, i can mine eth just with geth, what is my mistake?


texts:
I currently use web3 and geth to develop dapps, and we know that web3 interacts with geth through json rpc. If we want to unlock an account through dapp, we need to enter the password in the dapp, and then web3 will unlock it through json rpc. I want to know when web3 uses the password provided by the user to send an unlock request to geth, will this password be hijacked by an intermediary? I personally think that json rpc is also transmitted in plain text, so I think json rpc is not safe, I don’t know if my understanding is correct.
Hope you can help me, thank you!


texts: Why do blockchain networks like Ethereum utilize JSON RPC calls and not REST APIs or graphQL?

texts:
I'm sorry. This might be a silly question but I am very much new to backends and networking protocols. I can write decent smart contracts but I don't know much about the backend.
So... I wanted to learn how I can build an API to get transaction results from transaction hashes. What I got stuck is the very first place... I happened to know that REST API, JSON RPC, RPC, SOAP, GraphQL all are network protocols. But since REST is so famous, why do Ethereum and Blockchain use JSON-RPC calls and not REST.
I'd searched the internet for it but could find no distinct reason that can make me understand. Happened to get it that JSON RPC calls are direct and faster...
I really am a beginner in this so can I get a simple analogy and a precise reason from this talented community please?


texts:
.addMedicalReport(
        patientBio.id,
        patientBio.name,
        patientBio.birthDate,
        patientBio.phoneNumber,
        patientBio._address,
        patientBio.MedReportId,
        parseInt(patientMedicalData.weight),
        parseInt(patientMedicalData.height),
        patientMedicalData.bloodGroup,
        patientMedicalData.diseaseName,
        patientMedicalData.diseaseDescription,
        patientMedicalData.diseaseStartedOn
      ).send({ from: account })
      .once('receipt', (receipt) => {
        console.log('saved')
        // updateList(patientDataContract)
      })

solidity
function addMedicalReport(
    string memory patientId,
    string memory patientName,
    string memory birthDate,
    string memory phoneNumber,
    string memory _address,
    string memory medReportId,
    uint weight,
    uint height,
    string memory bloodGroup,
    string memory diseaseName,
    string memory diseaseDescription,
    string memory diseaseStartedOn
    ) public {
      countSenders++;
    }

Error:
*react-dom.development.js:4091 Uncaught TypeError: Cannot read property 'length' of undefined
    at toUtf8Bytes (utf8.ts:210)
    at StringCoder.encode (string.ts:15)
    at array.ts:62
    at Array.forEach (<anonymous>)
    at pack (array.ts:54)
    at TupleCoder.encode (tuple.ts:23)
    at AbiCoder.encode (abi-coder.ts:106)
    at ABICoder.webpackHotUpdate../node_modules/web3-eth-abi/lib/index.js.ABICoder.encodeParameters (index.js:121)
    at index.js:439
    at Array.map (<anonymous>)
    at Object._encodeMethodABI (index.js:438)
    at Object._processExecuteArguments (index.js:701)
    at Object._executeMethod (index.js:720)
    at addUpdatePatientMedicalData (App.js:100)*


texts:
I am trying to use the OpenZeppelin ECRecovery library for a project I am working on.

Unfortunately I don't fully understand how it works and there's no documentation for it.

Let's say I want to sign the message 'hello'. First I hash it:

msg = web3.sha3('hello');

Then I sign it by using web3.eth.sign and metamask.

web3.eth.sign(web3.eth.accounts[0], msg, (err, res) => {
    sig = res;
})

The returned signature is:

0xebb853cf9818c590e428bfa2b793b23e975d978bfefbb8aff164a282786c3eda0054113161b1a72f29f371a35b9a378413d689e49addcea34a8a617270c2bc951c

In the library code it says:

// Check the signature length
if (sig.length != 65) {
  return (address(0));
}

So if I call the function with the hash and the above signature it will fail because this signature has a length of 132.

I also thought about using the r or the s value of the signature only by splitting it in JavaScript: (even though I don't even know what these values represent, as there is absolutely no information in the solidity documentation)

var r = sig.substr(0,66);
var s = "0x" + sig.substr(66,64);

But both have a length of 66 and fail as well.

Has anyone ever used their library and can help me out?


texts: Interacting with existing Smart Contract deployed on test network like rinkeby from local test environment (truffle)

texts:
I have forked rinkeby network using ganache-cli as shown below
ganache-cli -f https://rinkeby.infura.io/v3/id --account="fsdfmsadklksmdflskamf"
Now, I want to test my smart contract which has dependencies of smart contract present on rinkeby network.
how to create interface of existing smart contract from rinkeby in truffle
So that we can interact with them.
Thanks


texts:
In an example on https://www.ethereum.org/token :

/* Public variables of the token */
string public standard = 'Token 0.1';
enter preformatted text here

Why 'Token 0.1'? Where is the standard definition?
I found ERC #20: Token standard on https://github.com/ethereum/EIPs/issues/20 , but there is no clear link with the term 'Token 0.1'


texts: Out of gas exception: error when using GUI/JS but not within truffle

texts:
I'm trying something with Ethereum and my current testing environment is Truffle.

In the smart contract I have a struct with 5 fields (bytes32, bytes32, bytes32, address, bool). If a call a function (that has as parameters the first three bytes32) that writes in an array of struct within Truffle everything works fine (and then I'm also able to read the values, get them by index using a mapping and so on).

Now I've some problem when dealing with AngularJS and the GUI. If I create a page with an input form for writin a bytes32 on a bytes32 variable in the contract everything works. The problems arises when I pass some arguments (1, 2 or 3) and then write inside the array of struct. I got an out of gas expection.

Do you have any insights on way there could be some problems? I'm sure the transaction doesn't consume all gas (and I've tried to increase the limit) because in Truffle console everything works fine.

Thanks for your time

-------- UPDATE

I think that a possible solution could be to set for the single call of the function an higher startgas than the default one. The limit I've first increased was the BGL.

contract.testWrite2(testNumber1, {from: web3.eth.accounts[0]})

This is the code for calling the testWrite2 function of my contract passing one parameter and using the account 0. How can I set the startgas for this simple invocation?

contract.testWrite2(testNumber1, {from: web3.eth.accounts[0], startgas: 200000})

This unfortunately doens't seem to work. The strange thing is that from truffle console all the functions are working correctly, while from the GUI they're not.

The code of the controller that's managing the GUI is this

    app.controller("TestController", function($scope) {
        $scope.pageTest = "Welcome to the Test page";
        $scope.testWr = 'None';

        $scope.testWrite = function(testNumber1) {
        var contract = Authentication.deployed();
        contract.testWrite2(testNumber1, {from: web3.eth.accounts[0]}).then(function() {
          $scope.testWr = 'success';
          $scope.$apply();
      })
   }

 })

And this is the html page in which there is an input form for a number:

{{pageTest}}

Test

        <form ng-submit="testWrite(test_number1)">

                Hardware
                <input type="number" class="form-control" id="testNumber1"
                        placeholder="ble:..."
                        ng-model="test_number1">

            <button type="submit" class="btn btn-default">Test</button>
        </form>

Write status: {{testWr}}

To test it out, I wanted to call the function and then simply change the variable testWr on the HTML page.

Thanks to everybody that will help me :)


texts:
I installed Geth to work with Web3 and used npm install -g ethereumjs-testrpc
but when i run testrpc the following error shows

testrpc is not recognized as an internal or external command,operable program or batch file.

Is there any additional package or something that I should use to make this work?


texts:
My smart contract looks like this

contract C {
    uint256 a=50;  //

    function setA(uint256 aval) {
        a = aval;
    }
    function getA() constant returns (uint256) {
        return a;
    }
 }

I am calling the function asynchronously like this

var a = contract.setA.call(100, function(error, value) {
    .....
});

After that if I call this immediately

var a = contract.getA.call(function(error, value) {
    .....
});

I am getting the same value(50) before the transaction is mined. This is because it needs some time if I want to get the changed value. Is there any way or event so that I get notification that the changed value is updated in blockchain when I can getA to be ensured the current exact value?


texts: How do miners work in private network? What is their importance?

texts:
I'm a newbie to the blockchain technology and working on the smart contracts using Ethereum. Help me understand the concept of miner in this technology.

I have followed the steps given on https://souptacular.gitbooks.io/ethereum-tutorials-and-tips-by-hudson/content/private-chain.html and done the setup of private network. I have created some basic smart contracts and deployed them in the network. Now I'm not able to relate the concept of miners used in bitcoin network and in my private network.

I have one more confusion regarding the creation of transaction in the network. It says that whatever we do on the contract it is treated as transaction but in case of the SimpleStorage given on this url http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html the get() call is not treated as transaction. Please help me to understand when the transaction is created and when not.


texts:
I'm trying to learn about using libraries in solidity. In the following test contract, swapNumberLib does not successfully set value1 = value2. I thought libraries could act on the storage of a contract if the variables were passed into the function - does it not work in this case?

pragma solidity ^0.4.24;

library TestLibrary {
    function swapNumber(uint value1, uint value2) internal {
        value1 = value2;
    }
}

contract Test {
    uint public value1;
    uint public value2;

    constructor() public {
        value1 = 1;
        value2 = 2;
    }

    function swapNumberLib() public {
        TestLibrary.swapNumber(value1, value2);
    }

    function swapNumber() public {
        value1 = value2;
    }
}


texts: Monax Contract Nodejs Invocation Example

texts: I have setup a Monax development private chain environment using on Ubuntu 16.04. Now looking for an example of how to invoke the Smart Contract deployed on Monax chain. If you could direct a proper example in this regard will be quite helpful.


texts: Convert HTML input in ether to wei to send to smart contract

texts:
I want my clients to fill in a number in ethers instead of Wei (as I don't what them to go through the hassle of putting 18 zeroes in every time.)

I'm trying to do this in the following way in JavaScript, but for some reason, it triggers the transaction, but translates the amount 1-1 into wei (so input 1 gives 1 wei instead of 1000000000000000000 wei.)

$("#BetalenRekeningMI").click(function() {
  contractMI.testmultiinput(web3.toWei($("#bedrag").val(), 'ether'),
                            $("#addressMI").val(), {value: 0},
                            function(err, result) {
                          console.log(err, result);
                            })
});

Here some more details. This is the corresponding HTML (without the comment tags of course:

          <input type="text" name="bedrag" id="bedrag" placeholder="Bedrag in Ether"/>
          <input type="text" name="addressMI" id="addressMI" placeholder="Adres van de leverancier"/>
          <button id="BetalenRekeningMI">Klik hier om te betalen</button>

This is the Solidity function that the JS triggers:

 function testmultiinput(uint256 bedrag, address klant) payable{
        klant.transfer(bedrag);
    }


texts:
Good afternoon all. Been searching around for an answer to this question and can't seem to find the exact solution I need.

I have an ETH account on my Parity node that I want to move to Ethereum Wallet (geth). I have the key file from Parity which contains the JSON of the account in question. However, geth does not like this format for importing accounts and seems to be expecting a keyfile with a plaintext private key.

Specifically, the error I get importing the Parity key file in geth is:

Fatal: Failed to load the private key: encoding/hex: invalid byte: U+007B '{'

Using Parity, how can I decrypt the JSON keyfile to gather the private key for importing into geth? I could not find a command-line option within Parity, nor in the Parity WebGUI, that allows for exporting private keys in plain text.

Thank you in advance.


texts: Can geth and eth share the same accounts and blockchain?

texts:
It appears when I have multiple ethereum clients installed, that they all have their own data, accounts and even their own copy of the blockchain.

Is it possible to share accounts and the blockchain accross multiple clients somehow?


texts: Can a contract reveal hidden info only when someone pays it?

texts:
Can anyone think of a way to store hidden information on a contract and then reveal it only when the contract receives payment?

I'm pretty stumped. Im guessing its impossible?

But if there were a solution, could it involve encryption and oracles?


texts: web3.js getBlock() call pauses after 500th iteration on MacOs

texts:
I am trying to traverse over blocks and get their transaction information like this:

for (var i = 0; i < 1000; i++) {
      var block = web3.eth.getBlock(i);
      console.log( block.number);
}

Problem: I am able to fetch first (525-545)th blocks and then,
web3.eth.getBlock(i) call halts the execution and loop stuck.

It is not about the incoming block because when I start the loop from the block 500th block again it correctly fetches first 500 blocks and halts again.

The interesting thing is, iteration count over loop is not stable. It is always changing between 525-545 and pauses in this range.

I tried to put a delay between requests but that also didn't work.

geth version 1.6.1-stable-021c3c28 and web3.js version ^0.18.4

Is there a limit(such as RPC limit on macOS) for API calls? How could I fix this issue.

Please note that: This issue works perfectly fine on Linux but does not work on macOS.


texts: Feedback on Implementing Merkle Airdrop for Rug Pull Victims

texts:
Summary: Developed a smart contract that enables the GovernorDAO Community to un-rug the CBDAO Rug Pull victims by providing them with a Merkle Distribution Airdrop. Over 1/3 of an already-minted supply of tokens are on the line ($2M value) and I have been tasked with covering the Airdrop (after a developer promised to do so and caught COVID and hasn't been heard from).
Design Specifications: an airdrop to over 3K recipients where claims may be made at a rate of 10% of the eligible amount with an additional 1% available each day until 90 days have elapsed (100%). For each claim < 100%, the forfeited amount is split thusly, 50% burned, 50% rewards pool. Note: the rewards pool is shared amongst those who waited the full 90 days to claim.
Design Specifications: Summary

N of(Recipients, Amount): 3,716
Available on Day 1: 10% of Amount
Daily Reward Available: 1% of Amount
Day 90: 100% Available
Day 100: Airdrop Claiming Terminates

Progress: Smart Contract is 95% complete and may be found here. Pre-configured tests from the original Uniswap Repo passes with MerkleDistributor.sol updates, but it fails when an attempt to move funds anywhere other than account or deployer.
Assistance Requested: (1) An explanation as to how to create the Merkle Root that is referenced in the smart contract and deploy on the blockchain. (2) Assurance that only the account may request a claim and such claims cannot be made on behalf of another (to avoid malicious claims). (3) Logic and bug testing from any devs willing and able to try to break it.
Claims Code Snippet
// SET CLAIM AND SEND FUNDS.
_setClaimed(index);

// TIME SETTINGS
// [P] Start (unix): 1607990400 | Tuesday, December 15th, 2020 @ 12:00AM GMT
uint256 startTime = 1607495500;
// [P] End (unix): 1616630400 | Thursday, March 25th, 2021 @ 12:00AM GMT
uint256 endTime = 1616630400;

// CLAIMS PERIOD
uint256 nowTime = block.timestamp;
uint256 duraTime = nowTime - startTime;
require(nowTime >= startTime, 'MerkleDistributor: Too soon');
require(nowTime <= endTime, 'MerkleDistributor: Too late');

// MAX TIME
uint256 duraDays = duraTime / 86400 >= 90 ? 90 : duraTime / 86400; // divided by the number of seconds per day
require(duraDays <= 100, 'MerkleDistributor: Too late'); // double check days

// AVAILABILITY CALCULATION
uint256 availAmount = amount * (10 + duraDays) / 100;// 10% + 1% daily
require(availAmount <= amount, 'MerkleDistributor: Slow your roll');// do not over-distribute
uint256 forfeitedAmount = amount - availAmount;

// ACCOUNT TRANSFERS
require(IERC20(token).transfer(account, availAmount), 'MerkleDistributor: Transfer to Account failed.');
// [P] Update: include 50% transfer to rewardsPool and 50% burn | 50% of 'forfeitedAmount'
require(IERC20(token).transfer(rewardsPool, forfeitedAmount), 'MerkleDistributor: Transfer to Deployer failed.');


texts: Basically I am looking at controlling the user account creation.  Only super user account shall be allow creating/deleting the user accounts.  Is this possible in Ethereum?


texts: Simple question : Can I send private key via Solidity and an approved contract code?

texts:
I want to make an approved contract using Solidity and place the private key altering the state of a contract, for a certain address owner to obtain.
Can this be done, and how ?


texts: Accessing values inside a returned array

texts:
I am working with truffle and failing to get the actual values from my return:

[ [ { [String: '10'] s: 1, e: 1, c: [Object] },
    { [String: '35'] s: 1, e: 1, c: [Object] },
    { [String: '40'] s: 1, e: 1, c: [Object] },
    { [String: '50'] s: 1, e: 1, c: [Object] },
    { [String: '60'] s: 1, e: 1, c: [Object] } ],
  [ { [String: '20'] s: 1, e: 1, c: [Object] },
    { [String: '35'] s: 1, e: 1, c: [Object] },
    { [String: '40'] s: 1, e: 1, c: [Object] },
    { [String: '50'] s: 1, e: 1, c: [Object] },
    { [String: '60'] s: 1, e: 1, c: [Object] } ] ]

I tried result.valueOf()[0][0].toString() but that didn't do the trick.

However, result.valueOf()[0].toString() is working on the following example:

[ [ { [String: '10'] s: 1, e: 1, c: [Object] } ],
  [ { [String: '20'] s: 1, e: 1, c: [Object] } ] ]

Any help would be appreciated!

EDIT: The goal is to use the values for a test, ideally somehow like that:

 assert.equal(result.valueOf()[0][0].toString(), [10, 35, 40, 50, 60]);
 assert.equal(result.valueOf()[1][0].toString(), [20, 35, 40, 50, 60]);

EDIT2: The values that the contract returns are (uint256[], uint256[])

Cheers!
carbee


texts: How can I distribute an amount of ether between a number of addresses based on percentages?

texts:
full contract code

I have a contract (code above) where ether is bet on either side 0 or side 1. A winning side is determined (payout function), and the amount of ether that a winner will receive is determined by this formula:

(amount wei winner bet/amount of wei in winning pool)*(amt. of wei in winning pool + amt. of wei in losing pool)

The problem is that sometimes the formula will give a value of 0 when run on the contract when it doesn't in real life causing nobody to be paid. What's the best way to distribute the amount of ether that a winner deserves?


texts: How to test contract interactions without pay fee

texts:
I have my contract which interacts with two different exchanges, can i test this interaction without pay fee? Before Deploy to the main net? I know it has Ropsten but it wouldn't work i think, i need to fetch the real order prices.
If i run my local node do I still pay fee? (I am running the exchanges contract functions)