texts: What are the most important potential attack vectors on oracles?

texts: Specifically, with my question I want to target Oracelize.it as arguably the most "state of the art" oracle service. This specification is done in order to exclude trivial attacks in the potential answer.


texts: Among every tutorial/real world example I have yet to come across anyone using the int datatype, I almost thought there wasn't one existing.. Is there a specific reason for uint's uncontested dominance?


texts: Just lost a million blocks after downloading Mist

texts: Any idea why, after downloading Mist, I lost ~1mio blocks as the lead block. Was at 3.2mio when I was syncing (at 2264479) and now, after firing up Mist, it shows best block at ~2.3mio. Any thoughts, answers for my issue? Any help would be greatly appreciated (and sorry about the vernacular). Cheers.


texts: Could ethereum be used to bypass Internet censorship?

texts: AFAIK ethereum is a decentralized platform run programs on computers all over the world, so is it possible to write a program to help bypass Internet censorship? for example, if I'm in China, I can connect to a computer in USA as a proxy to visit some blocked websites?


texts: Consolidating "dust transactions" in account-based coins like Ethereum?

texts:
Suppose I have a marketplace where 100 buyers deposit 1 ETH each into 100 unique addresses and I know I will end up sending all 100 ETH to 1 vendor. Since the coins are originating from 100 ETH addresses (accounts) I would incur an extremely high transaction fee (1 transaction fee per address * 100 addresses = 100 transaction fees).
Does it make sense to send all 100 ETH to "one address" (account) when gas fees are low or using longer confirmation times in order to reduce my gas costs? If not, what strategy can be used to reduce miner/transaction fees in this case?


texts: Import and polymorphism is one contract or more?

texts:
If I have this contract:

contract HelloWorld{
...
}

and this one

import "./HelloWorld.sol";
contract HelloUniverse is HelloWorld{
...
}

and I deploy it, will it create 2 different contract and 2 different contract addresses or how will it be stored on ethereum blockchain? Thank you.


texts: How can I declare a string value more than 20 bytes in Solidity?

texts: I'd like to declare a string value more than 20 bytes in Solidity. I use address type, but it only contains 20bytes. Could you tell me how to solve the problem?


texts:
I am trying to install Ganache on my windows 8.1 machine.

I downloaded the Ganache.appx from the official Ganach website.

I furthermore installed the Windows 10 SDK.

As pointed out in the documentation:

  Before building, create the ./certs directory with the following
  files:

  ./certs/cert.pfx

Which I created together in a folder:

However, now I am stuck how to install ganache. Any suggestions for the next steps?

I appreciate your replies!


texts:
I have .js file, where the contract has to call five times by passing rand as parameter. But rand has been overwritten and only the fifth random value is passed to the contract five times:

for(var i=0;i<5;i++){
    var rand =Math.random();
    contractt.deployed().then(function(instance){
    var instancee =instance;
         return instancee.add(rand,{from:wallet,gas:4000000});
        }).then(function(result) {
            console.log('result='+result);
        })
   })
}

I tried using setTimeout() as below:

 for(var i=0;i<5;i++){
    setTimeout(()=>{
    var rand =Math.random();
    contractt.deployed().then(function(instance){
    var instancee =instance;
         return instancee.add(rand,{from:wallet,gas:4000000});
        }).then(function(result) {
            console.log('result='+result);
        })
   })
  },1000);
}

However, I still obtain the same result.


texts: Should I create a new address for each transaction?

texts: It's my understanding, when using bitcoin, it's advisable to generate a new address for every transaction. Is this also the case for Ethereum, and if so, how do I do this with Mist?


texts: How does betting on a block work in Casper?

texts:
Betting on a block is betting money that effectively says something like:

"I believe that this block has at least a 60% chance of being true."

Q1. Once a bet is made, is it possible to change the bet?

My guess is not, so that initially validators should bet small and eventually they all converge and agree.  (Part of Casper is proving this convergence?)

Q2. If a validator has a deposit of 100 ETH (for example), when they make a 10% bet do they put 10 ETH at risk?

Q3. If so, what happens if a validator realizes a mistake and wants to switch and bet 100% on another block?  Presumably the 10 ETH will be lost leaving the validator with 90 ETH left for betting.  Is that correct or does the validator need to put up another 10 ETH deposit?  To bet 100% on another block, does the validator put 90 ETH or 100 ETH at risk?


texts: Is there a tool that generates a PDF version of a transaction?

texts:
Etherscan provides a nice UI for viewing what happened in an Ethereum transaction, including internal contract state updates.

Is there a tool or an API that takes an Etherscan link, or an Ethereum transaction hash, and returns a PDF document?


texts: How to get the historical block mining information

texts:
I am still new to ethereum. How I can get the getWork information for an old block?

as an example, how to get the block header hash pow, seedhash and target for block 1000,000?

eth_getWork retrieve such information for the current block not for an old block.

Thanks in advance


texts: Truffle test fails to call the base function, wants the override

texts:
I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter.

I have these two pairs of base/override functions:

Base:

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

Override:

    function approve(address _spender, uint _value, bytes _data) public returns (bool) {
        require(_spender != address(this));
        super.approve(_spender, _value);
        require(_spender.call(_data));
        return true;
}

Base:

    function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
        allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
        Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
        return true;
    }

Override:

    function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
        require(_spender != address(this));
        super.increaseApproval(_spender, _addedValue);
        require(_spender.call(_data));
        return true;
    }

Unit test:

    it ("Test increasing allowance", async () => {
        // First, transfer 1000 coins from owner to user1
        await instance.transfer(user1Address, 1000, {from: ownerAddress});
        // Allow owner to spend 420 tokens from user1 balance
        await instance.approve(ownerAddress, 420, { from: user1Address });
        // Now increase that approval by 47 tokens
        // THE ERROR HAPPENS AT THIS LINE
        await instance.increaseApproval(ownerAddress, 47, { from: user1Address });
        // Check owner's allowance for spending user1's tokens - should be 467
        const allowance = instance.allowance(user1Address, ownerAddress);

        assert.equal(allowance, 467);
    });

When in unint test I make a call to approve with two arguments, it works fine, but when I make a call to increaseApproval with two arguments, it throws the following error:

  Error: Invalid number of arguments to Solidity function
        at Object.InvalidNumberOfSolidityArgs (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:25:1)
        at SolidityFunction.validateArgs (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:74:1)
        at SolidityFunction.toPayload (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:90:1)
        at SolidityFunction.sendTransaction (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:163:1)
        at SolidityFunction.execute (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:256:1)
        at /Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:202:1
        at /Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:155:1
        at process._tickCallback (internal/process/next_tick.js:109:7)

But if I call it with three arguments (as in its override) it works fine.

Any ideas why approve can be called as the base function (with 2 arguments) but increaseApproval fails with two arguments and wants three (as in the override)

The actual code is here: https://github.com/path-foundation/path-token/blob/master/contracts/PathToken.sol

And the unit tests are here: https://github.com/path-foundation/path-token/blob/master/test/TestPathToken.js


texts: Ethereum token transaction taking too much time to confirm

texts:
I was transacting an ethereum token CRO crypto coin out of wallet. There was 3 fees options. I chose fees for slow transaction time. And it told the transaction should confirm in 30 minutes.

But now the transaction is pending for almost a day and half.

Transaction details : https://etherscan.io/tx/0x1b0529985b20b871627202b7c9c393c3933e63f0537c9d836d00fa82d7da601f

Please provide me some insight on this and is there any way to reverse the transaction or increase the fees just as in bitcoin network.

Thanks in advance


texts: I sent a transaction at 2 Gwei over standard rate as shown by ETHGASSTATION. So it said 22, so I used 24. The average wait was 3 blocks or 46 seconds. Its been pending for 20 minutes.


texts: Where does Ethereum store EOAs and public keys?

texts:
I am currently having a hard time finding actual reliable concrete sources for an answer to the question what information exactly is stored on the ledger and what is not.

Specifically, Ethereum knows Externally Owned Accounts (EOAs) and Contract Accounts. Now: When I create a new account, what is stored where and when?

As far as I understand, I create my account as a "wallet" locally (e.g. using geth account new). Within this wallet, all information needed (i.e. my keypair etc) is stored locally.

Still, if I am to send Ether from my account to another, I will need to sign the respective transaction using my private key. Accordingly, any miner will need to verify said transaction's signature using my public key (as stated in the yellow paper in Section 6), which hence needs to be published somehow.

The Ethereum yellow paper states that an account's state is "not stored on the blockchain" but is stored in the "state database", which is (as far as I understand) computed by every node from the history of transactions. Still, I cant find any mention of where an account's associated keypair is stored. Can't be only in my local wallet...

Hence the question(s):
- How is a wallets public key published in the Ethereum network?
- How do I retrieve the public key for an account?
- What data for an account is actually written to the ledger and when?

Can anyone point me to the solution of this?


texts:
I'm new to solidity. I am trying to access all elements in my Applicant struct. In my Donate function if the donor does not specify an organization to donate to, then the amount will be split across all organizations within applicants. I have looked online and apparently it is a bad idea to iterate through a mapping due to the high gas cost. How else can I achieve my goal then?

    pragma solidity ^0.4.2;

contract DonationContract
{
    address owner;

    struct Applicant
    {
        address Org;
        string Name;
        string OrgType;
        string Number;
        string Email;
        uint256 Wallet;
        uint256 DonationFunds;
        bool approved;
    }

    constructor() public
    {
        owner = msg.sender;
        facilitators[msg.sender] = true;
    }

    mapping (address => Applicant) public applicants;

    mapping(address => bool) facilitators;

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

    modifier OnlyFacilitator()
    {
        require(facilitators[msg.sender] == true);
        _;
    }

     modifier Approved(address Org)
    {
        require(applicants[Org].approved == true);
        _;
    }

    function approve(address Org) OnlyFacilitator public
    {
        applicants[Org].approved = true;
    }

      function Donate(uint256 amount, address Org) Approved(Org)  public
    {
        if(Org==0)
        {
            //Split donation amount amongst all applicants donationfunds
        }
        else
        applicants[Org].DonationFunds += amount;

        if(applicants[Org].DonationFunds >= 10000)
        {
            applicants[Org].DonationFunds -=10000;
            applicants[Org].Wallet += 10000;
        }
    }

     function addFacilitator(address _addr) Owner public
    {
        facilitators[_addr] = true;
    }
}


texts: Access to public variable from other contract

texts:
Unable to access to public variable in Test.sol contract from other contract. How to do it?

Test.sol contract

pragma solidity ^0.4.18;

contract Test {
    uint256 public val = 256;
}

My attemps to access variable:

pragma solidity ^0.4.18;

import "./Test.sol";

contract Other {

    address testAddress;

    function setAddress(address _address) {
        testAddress = _address;
    }

    function getVal() public returns (uint256) {
        return Test(testAddress).val;
    }
}

Thanks!


texts: I can't find a way to open a dapp/enter url in Mist browser (v0.7.1). Do I need to download any special build, build it from master, or is there a switch for this?


texts:
How to participate to Gnosis pre-sale using geth javascript console?

In gnosis official blog is described how to do it using parity but there's no information on how to do it using geth.


texts: How to implement a watching wallet for thousands/millions of addresses

texts: I need to check for customers' deposits and need to scan for receiving transactions for those addresses for Ether and in next step ERC-20 tokens. What's the most efficient way to do this with go-ethereum?


texts: Will a non-programmer be able to participate in 'mining' Casper?

texts: I have very limited programming skills.  Basically, I am a layperson.  Will I be able to participate in bonding ('mining') Casper?  Or will participation in Casper be limited to professionals?


texts: web3py - Sending a transaction to a payable contract function

texts:
I have deployed a smart contract dthat contains a payable function fundit(address _to). Now I am trying to use a Contract object to send ether to the function:

tx_hash = instance.fundit.sendTransaction(instance2.address, {"from": w3.eth.accounts[0], "value": 1})

However, I am receiving the following error:

'Contract' object has no attribute 'fundit'

How can I solve this?


texts:
I'm using Geth to set up a private ethereum network and this is the command:

$ geth --identity "MyTestNode" --datadir "SomeDir" init genesis.json --rpc --rpcaddr "localhost" --rpcport "8000" --rpccorsdomain "*" --port "30303" --nodiscover --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 1900 --nat "any" console

But I'm getting that -rpc is provided but not defined and I don't know if everything else is correct.


texts: Is Solidity creating an implicit getter for a nested contract that is created?

texts:
Is Solidity creating an implicit getter or not for a nested contract that is created?

Example:

contract Foo {
   ....
}

contract Bar {
    Foo public foo;

   Bar() {
        foo = new Foo();
   }
}

When trying this out using Truffle, it tells me that Bar.foo() is not part of the ABI.

Am I doing something wrong, or is foo() just not being created by the Solidity compiler?
(I'd expect it to return the address of the created Foo() contract)


texts:
I have a consortium chain (I have access to all machines where the nodes are running, but can't stop or restart them), and want to monitor what's happening on a high level. Similar to what ganache does:

Does geth offer something like this?
(I know I can subscribe to events from web3.js and the likes, this is about any existing solutions available)


texts: With the rising Ether price to $9, doesn't this mean gas costs more?

texts: With the increase in the ether price, doesn't gas cost more, hence higher price to execute a contract? What is the current gas price today to execute a typical contract or send a transaction?


texts: Compilation Eror: One contract accessing the variable of another contract

texts:
I am trying to compile two contracts. I am getting 'balance' variable error in "HoneyPotCollect.sol" contract. Is balance not a global contract variable? Somebody please guide me how to correct my error.
//HoneyPot.sol
    pragma solidity ^0.5.0;
      contract HoneyPot {
      mapping (address => uint) public balances;

      constructor() payable public {
        put();
      }

      function put() payable public {
        balances[msg.sender] = msg.value; // msg.sender here is the address from the sender
      }

      function get() public {
         (bool success,) = msg.sender.call.value(balances[msg.sender])("");
          success = false;
          //revert();

        balances[msg.sender] = 0;
      }

  function() external {
    revert();
  }
}

//HoneyPotCollect contract
pragma solidity ^0.5.0;

import './HoneyPot.sol';

contract HoneyPotCollect {
  HoneyPot public honeypot;

  constructor(address _honeypot) public {

    honeypot = HoneyPot(_honeypot);
  }

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

  function collect() payable public {
    honeypot.put.value(msg.value)();
    honeypot.get();
  }

  function () external payable  {
    if (honeypot.balance >= msg.value) {
      honeypot.get();
    }
  }
}

Following is my error message:

$ solc HoneyPotCollect.sol
HoneyPotCollect.sol:19:9: Error: Member "balance" not found or not
visible after argument-dependent lookup in contract HoneyPot. Use
"address(honeypot).balance" to access this address member.
if (honeypot.balance >= msg.value) {
    ^--------------^


texts:
I'm familiar with smart contracts development. Although, every time I developed something, I used traditional ether. For the sake of simplicity, let's assume this contract.

pragma solidity ^0.5.0;

contract  Example {

    constructor () public {}

    function () external payable {}

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

    function withdraw() public {
        msg.sender.transfer(address(this).balance);
    }
}

How do I take this exact contract and simply allow it to do exactly the same, but using DAI instead? Please be practical, I read a lot of theory stuff already, I'm just looking to the actual code on how to do this.


texts:
I'm getting this error in Firefox when running a dApp:

Error: NetworkError when attempting to fetch resource.
Stack trace:
InvalidResponse@http://localhost:8081/bundle.js line 995 > eval:38:16
RequestManager.prototype.sendAsync/<@http://localhost:8081/bundle.js line 7645 > eval:86:29
MetamaskInpageProvider/self.sendAsync/<@moz-extension://bb21b38e-ca5a-6847-afb3-0e13f721de3f/scripts/inpage.js:168:7
[136]</StreamProvider.prototype._onResponse/<@moz-extension://bb21b38e-ca5a-6847-afb3-0e13f721de3f/scripts/inpage.js:8222:5

Anyone seen this? If not - any ideas on how to debug it?


texts: is there a platform for hosting APIs similar to AWS Lambda, only decentralized?

texts: I'm looking for a platform that enables to place serverless code for Dapps, without cloud services - so that app can remain completely centralized.


texts: How do I retrieve the Voted events from TheDAO?

texts: This question was asked by @Pablo Yabo in the comment section of the question How can I view The DAO proposals including the current voting status?.


texts: How to download source code ( In solidity ) of already existing smart contracts on ethereum blockchain?

texts:
We are working on a project which requires smart contract source codes for analysis in ethereum blockchain.

Can anyone suggest us how to download the source codes( In solidity) of various smart contracts already existing on the blockchain?

We tried getting the source code of smart contracts from etherscan.io. But we were able to get only about ~5000 smart contracts using an api key ( which are available under 'verified contracts' category).

Also, we were able to find out that some people were able to get ~20000 contracts way back in 2016. We need much more than 5000 contracts. Are we missing some obvious solutions? Can you suggest any other solutions.
Thanks.


texts: Truffle - test - how to get more than 10 accounts?

texts:
I want to test gas limits of the block.

Currently in my tests:

console.log(accounts);
console.log(accounts.length);

I have 10 accounts, what to do if I want more?

Related: https://github.com/trufflesuite/truffle/issues/771


texts: How Self Sovereign Identity works in Blockchain?

texts:
Today i have read about Self Sovereign Identity. It has 10 principle to hold the individuals identity. Really it is such a nice concept. When in near future it is fully implemented it will solve lots of problems.

But as a newbie my question is how it works? For example i want to store my driving licence with the help of Self Sovereign Identity in Blockchain. So that later i can use the hash function of my driving licence (as in Blockchain every data is stored as hash function) whenever i need it. But my question is, how can the minors come to know my driving licence is valid one and i didnot staor fake licence.

I think my question is related to Self Sovereign Identity.


texts:
Can I use my Mist ETH address to receive SNT? And if so, how can I see SNT in my Mist wallet? When I bought Bancor I had to add a Bancor address to watch the token in order to see/access my Bancor balance, yet I can't find an SNT address to use to watch the token.
Thanks


texts: testrpc How do I force development accounts to be unlocked?

texts:
Using Truffle and testrpc.

I am launching testrpc via testrpc --port 8545 --unlock 0

But when I run truffle migrate I get

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: authentication needed: password or unlock

My deploy script looks like

const Turnip = artifacts.require('./Turnip.sol')

module.exports = (deployer, network, accounts) => {
  const superuser = accounts[0]
  console.log('Deploying to network', network, 'from', superuser)

  deployer.then(() => {
    Turnip.new({ from: superuser })
  })
}

All the docs I've read say that testrpc's default accounts ought to be unlocked unless I specify --secure, but this does not appear to be true.

How do I force a test/development account to be unlocked?


texts: How do I close web3 such that mocha tests exit properly?

texts:
I'm writing a simple NodeJS (Node 9.4.0) server that's using web3 (1 beta) to interact with Ethereum.

I've created a simple utility web3 as follows:

const Web3 = require('web3')

const url = process.env.WEB3_PROVIDER_URL || 'ws://localhost:8546'
const web3 = new Web3(Web3.givenProvider || url)

module.exports = web3

I've written a trivial mocha (4.0) test as follows

const { expect } = require('chai')
const web3 = require('../../../src/utils/web3')

describe('web3', () => {
  it('exists', () => {
    expect(web3).to.exist
  })
})

The test passes fine but mocha never exists unless I add the --exit flag.

How can I close or otherwise cleanup web3 after my test so mocha exists correctly without the use of the --exit flag?


texts:
I am trying to understand how https://solidity.readthedocs.io/en/v0.7.2/internals/layout_in_memory.html works.
function test(uint a) public {
   uint test1 = 20;
   uint[1] testArr;
   testArr[0] = 20;
}

Question 1) where is test1 is stored ? I saw the article which states that all the local variables are stored in memory and not in stack. is this correct ?
Question 2) could you write assembly code with mload of how to get test1 and testArr[0] from memory since I don't understand how solidity explains memory layout. I'd really appreciate this.


texts: Pass parameters into Solidity Constructor from Truffle CONSOLE

texts:
How do we pass in constructor parameters to a contract that we want to test? I understand that the initial contract deployment occurs in the migrations file, but if, for testing/debugging purposes, we want to deploy and instantiate the contract in the Truffle Console, how do we do so? How about in our testing files?

Per instance, say our ExampleContract.sol file is:

contract ExampleContract { function ExampleContract(uint256 my_param){} })

And our 2_deploy_contracts.js file has this line at the top, but doesn't deploy the contract :

var ExampleContract = artifacts.require("./ExampleContract.sol");

We open a Truffle Ganache console & then migrate our stuff in:

truffle console --network ganache

migrate --compile-all

Now, we have the contract's information (including its address) stored in ExampleContract, but how can we then instantiate it with parameters we wish to pass into its constructor? What is the equivalent of the deployer.deploy object in migrations that we may pass parameters into?


texts:
I am not familiar with at all with token transfers on the ETH platform, so if someone knowledgable could answer my questions, it would be greatly appreciated. A few hours ago I initiated a transfer from my Android Eidoo wallet to a trading account (an exchange). The Tx is showing in Etherscan. When refreshing the Etherscan Tx page, on the "Estimated Confirmation Duration" line, it has been showing different estimated times in minutes. It has shown 12, 9, 8, 4, 2 minutes. Then now it's back to 9 minutes.

In the wallet, when I submitted the transfer, I let the default setting at "Normal" for the "gas" speed. There are 3 "gas speed" settings in the wallet: Slow, Normal and High.

I have initiated the transfer about 15 hours ago, and it is still showing as "Pending" in the wallet and on the Etherscan page. The token transfer is : ZIL (ERC20 compatible)

The Etherscan Tx id can be seen here:

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

Why is it taking so long to get confirmed ? What's going on ?

In the future, what "gas setting" can I use in the Wallet to speed up the transaction?

If I ever wish to have a transfer done, let's say within 30 minutes, what should I do ?

Also, can someone can give me a rough estimate on how long (in hours) it still going to take for this transaction to be processeed (confirmed) on the network? Thank you all for answering my questions.


texts:
I am trying to use the encrypted ethereum private key created by myetherwallet within my application. Everytime I need to send money, I will input my password so that my application can decrypt it and send money when required. But I need to know how can I decrypt it using the key(password) I used to create the account.

I am trying to see if anyone know what encryption (encryption method) does myetherwallet is using?


texts: Solidity state variable resets to default inside function

texts:
For this project, I am coding smart contracts for Ethereum using Solidity.

In the following code, the variable numCertificates should initially be 1. Nonetheless, newCertificateId is 0 when assigned. According to the debugger (I'm using remix.ethereum.org), for some reason, numCertificates becomes 0 as soon as the line where newCertificateId is assigned is reached.

I have played around with remix a lot, and according to it, numCertificates is 1 until exactly the aforementioned line is reached. Also, I think that if I modify numCertificates in another function, the variable stays the same as before.

My attempts at trying to figure this out lead me to believe that when I access numCertificates, I am not accessing the public state variable but something else.

Why does this code have this problem and how can it be solved?

pragma solidity ^0.4.21;

contract MyToken {

    struct Certificate {
      uint64 certificateId;
      uint64 meterId;

      uint32 timestamp;
      uint48 value;
      address[] owners;

      mapping (address => uint48) ownershipSplit;

      bool burned;
    }

    mapping (uint64 => Certificate) public certificates;
    uint64 numCertificates = 1;

    function MyToken() public {
      // ... irrelevant stuff
    }

    function produceCertificate(
      uint64 meterId,
      uint32 timestamp,
      uint48 value,
      address owner
      ) public {
        // Create the certificate in memory
        numCertificates;// only for debbuging
        Certificate storage newCertificate = constructCertificate(meterId, timestamp, carbonMitigationValue, owner);
        uint64 newCertificateId = numCertificates;
        newCertificate.certificateId = newCertificateId;

        // Save the certificate
        certificates[newCertificateId] = newCertificate;
        numCertificates++;
    }

    function constructCertificate(
      uint64 meterId,
      uint32 timestamp,
      uint48 value,
      address owner
      ) internal returns (Certificate storage newCertificate) {
        newCertificate.meterId = meterId;
        newCertificate.timestamp = timestamp;
        newCertificate.value = value;

        newCertificate.owners.push(owner);
        newCertificate.ownershipSplit[owner] = value;

        newCertificate.burned = false; // by default new certificates are fresh

        return newCertificate;
    }
}


texts:
I have two geth nodes and I want to run 1 swarm node on each node.

I made a boot node for the two swarm nodes to communicate with each other.

I run the first swarm node with the following command and it runs fine

  ~/go/bin/swarm --bzzaccount $BZZKEY --datadir node1/ --ens-api '' --bootnodes 'enode://67bea43dc6a907956ef4b766e5f80bd8647f6136575bb393ab1ab569eb6396c1773e8d4d30b0642b02eeba2783b5e75bbe53861ef076793149fd31563eb07cb5@127.0.0.1:30910'

Then I run the second swarm node with the following command and it give the following error.

  ~/go/bin/swarm --bzzaccount $BZZKEY2 --datadir node2/ --ens-api '' --bzzport 7012 --bootnodes 'enode://67bea43dc6a907956ef4b766e5f80bd8647f6136575bb393ab1ab569eb6396c1773e8d4d30b0642b02eeba2783b5e75bbe53861ef076793149fd31563eb07cb5@127.0.0.1:30910'

Error

  Fatal: Error starting protocol stack: listen udp :30399: bind: address already in use

What do I need to fix this?


texts:
I want to have a clean install of the turbo ethereum C++ clients and command line tools without any GUI dependencies (Qt, etc.) - How to build C++ Ethereum without GUI/Qt?

I see AlethZero and AlethOne are pulling them in, but how can I tell the build process to exclude all GUI applications?

Are there any ways to configure cmake to only build CLI tools or any specific make targets I should know about?


texts: How to access wallet if password is lost

texts:
Hi I have deposited a bit of ether in Parity. I must have copied wrongly the password. Any other ways to access my Ether. I appreciate any help.

Thank you.


texts: Is it possible to filter pendingTransactions?

texts:
To get a list of the pending transactions that my node is aware of I can easily call the eth_pendingTransactions jRPC call. This will give a big list of pending transactions, which all need parsing to find the pending transactions I care about by the client.

Is it possible pre-filter the transactions? Would eth_newpendingtransactionfilter be any help https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newpendingtransactionfilter ? I can't seem to understand how this is related to pending transactions.


texts: Send LP tokens to a payable function using truffle console

texts:
I am trying to stake the LP tokens that I got after adding liquidity in pancakeswap contract function. I can see the LP tokens in my metamask wallet as well. Now I cant understand how will send some of these tokens to this staking payable function. What will be the command.
  // Stake tokens to SmartChef
    function deposit() public payable {
        PoolInfo storage pool = poolInfo[0];
        UserInfo storage user = userInfo[msg.sender];

        require (user.amount.add(msg.value) <= limitAmount, 'exceed the top');
        require (!user.inBlackList, 'in black list');

        updatePool(0);
        if (user.amount > 0) {
            uint256 pending = user.amount.mul(pool.accCakePerShare).div(1e12).sub(user.rewardDebt);
            if(pending > 0) {
                rewardToken.safeTransfer(address(msg.sender), pending);
            }
        }
        if(msg.value > 0) {
            IWBNB(WBNB).deposit{value: msg.value}();
            assert(IWBNB(WBNB).transfer(address(this), msg.value));
            user.amount = user.amount.add(msg.value);
        }
        user.rewardDebt = user.amount.mul(pool.accCakePerShare).div(1e12);

        emit Deposit(msg.sender, msg.value);
    }

I have tried maham.deposit({from:'my address',value:1000}) in console but it doesnt work


texts: Contract not Compiling: Undeclared identifier

texts:
I am just playing around on testnet w/ code snippets ...

What am I doing wrong?


texts: Invalid type for argument in function call for array

texts:
I am currently a beginner to solidity programming. However, I am getting an error when I try to send an array for an argument for a function.
constructor() {
    addQuestion('Is this a question?', ['Yes', 'No']);
}

function addQuestion(string memory _title, string[] memory _answers) private {
    ...
}

I am getting an error that implicit conversion from 'string memory[2] memory' to 'string memory[] memory' requested


texts: How to determine transaction fees using web3.py

texts: I am using web3py to transfer tokens and ether. I need to track the transaction fees for each transaction. Given a transaction hash, how do I determine the total fee paid?


texts: Web3 | Encrypt and Decrypt Owner PrivateKey

texts:
I create raw transaction and sign with owner privatekey to send transaction. For now, owner privateKey is just simply stored to variable but this is not safety so I want to encrypt or decrypt the owner privateKey in my javascript code. I'm also wondering that the way of get owner PrivateKey safely in my client code not to expose in plain text or binary or everything hacker can recognize.
Is there a function supported by WEB3 right now? How do you guys dealing with this problem if someone who's developing a service like me?

I know this is not a technical question but I want to get an idea how to access it. Thanks.


texts: How to pay transaction costs for other people

texts:
I'm currently building a feature where users can exchange their ERC20 token for a that can be used within our DApp. This therefore requires a transaction from the user to us (their ERC20 token to us), and then we credit their account on the DApp with the app credits, in a ratio of 1:1. The issue is how are we able to do the transaction between them and us, without it costing them any ETH?

Is there a way for us to pay this transaction for the user?

Upon further reading, it seems this isn't possible with Ethereum. It seems that the only person that can pay the transaction fees is the person sending the transaction. It also seems that this is something that the Ethereum community would like to address in Serenity.

Thanks


texts: Any coding games made for learning how to build out ethereum smart contracts?

texts: I recently saw this for learning how to code smart contracts on EOS: https://battles.eos.io but was wondering is there something similar in Ethereum where one can play a game to learn smart contract development for Eth?


texts: Transfer an ERC721 Token from another contract

texts:
I'm getting a revert when trying to transfer a token from another contract, I'm calling the function from an Auctions contract, for example, when the max bidder claims the reward they get the token but I'm getting a revert because of the msg.sender since it changes to the address of the Auctions contract.

This is the current function of the Auctions contract:

function withdraw(uint256 _auctionId) public {
    AuctionData storage auction = auctions[_auctionId];
    require(!auction.isOpen);

    uint256 payout;

    if(msg.sender == auction.owner) {
        payout = auction.maxBid;
        auction.maxBid = 0;
    }

    // We ensure the msg.sender isn't the max bidder nor the owner.
    // If the address is the owner that would evaluate to true two times (above and this one)
    // and 'payout' wouldn't be correct.
    // If msg.sender didn't bid then the payout will be 0 anyhow.
    if(msg.sender != auction.maxBidder && msg.sender != auction.owner) {
        payout = auction.bids[msg.sender];
        auction.bids[msg.sender] = 0;
    }

    if(msg.sender == auction.maxBidder) {
        // Manually sends the token from owner to maxBidder.
        // CToken(ctoken).transferTokenTo(auction.owner, msg.sender, auction.horse);
        delete auction.maxBidder;
    }

    msg.sender.transfer(payout);

    emit Withdraw(msg.sender, payout);
}

The relevant part is the if(msg.sender == auction.maxBidder) {}

The Token contract only calls approve / safeTransferFrom from OpenZeppelin's contract.

So, what are my options here to avoid this revert / maintain the msg.sender to the address that sent the transaction and not the contract?

Edit: Token contract

pragma solidity ^0.4.2;

import "./ERC721Token.sol";
import "./CryptofieldBase.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

contract CToken is ERC721Token {
    using SafeMath for uint256;

    uint256 stallionsAvailable = 168;
    uint256 maresAvailable = 379;
    uint256 coltsAvailable = 230;
    uint256 filliesAvailable =  334;

    // Variable for enumeration.
    address[] addresses;
    address cryptofieldBase;

    constructor(address _cryptofieldBase) ERC721Token("CToken", "CT") public {
        cryptofieldBase = _cryptofieldBase;
    }

    /* @dev Returns an array of ids of horses owned by '_from' */
    function getOwnedTokens(address _from) public view returns(uint256[]) {
        return super.getOwnedTokens(_from);
    }

    function createHorse(address _owner, string _hash) public payable {
        require(stallionsAvailable > 0);

        uint256 tokenId = addresses.push(_owner) - 1;

        _mint(_owner, tokenId);
        CryptofieldBase(cryptofieldBase).buyHorse(_owner, _hash);

        stallionsAvailable = stallionsAvailable.sub(1);
    }

    function transferTokenTo(address _from, address _to, uint256 _tokenId) public {
        safeTransferFrom(_from, _to, _tokenId);
    }

    function ownerOfToken(uint256 _tokenId) public view returns(address) {
        return ownerOf(_tokenId);
    }

    function approveAddress(address _to, uint256 _tokenId) public {
        approve(_to, _tokenId);
    }

    /*
    @dev Transfer a token of '_from' to '_to'
    */
    function tokenSold(address _from, address _to, uint256 _tokenId) public {
        safeTransferFrom(_from, _to, _tokenId);
        CryptofieldBase(cryptofieldBase).horseSold(_tokenId);
    }
}


texts:
I'm trying to create a smart contract for a basic raffle system where the user deposits funds to the contract and then a user is picked and the winner is sent the ether from the contract, I've got everything working apart from invoking a request to the user to deposit Ether to the contract and am wondering how I would perform this.

In short, I'm trying to create a function whereby the user can enter a number of Ether that they to deposit and the contract will accept it.

Thanks


texts:
I'm new at ethereum.

I understand that UserOwned Account have public and private keys.
But I can't see when and where they are generated ?

I know the key-pair is generated offline, but when exactly ? and How ? I mean the blockchain uses the elliptic curve cryptographie, ECC 265, so, how does the user know that he has to generate a pair of keys for the 265 curve?


texts: Why DARPA wants secure messaging based on blockchain

texts:
DARPA (US Defense Advanced Research Projects Agency) has released a Request for Proposal for a Secure Messaging Platform using a blockchain framework.

The following is the Objective paragraph from DARPA's call for proposal:

  OBJECTIVE: Create a secure messaging and transaction platform that separates the message creation, from the transfer (transport) and reception of the message using a decentralized messaging backbone to allow anyone anywhere the ability to send a secure message or conduct other transactions across multiple channels traceable in a decentralized ledger.

The request for proposal is available in full, here:
DARPA Call for Proposal for Secure Messaging Platform.

Why are contemporary secure messaging platforms like TextSecure, Cryptocat, XMPP/OTR, Bitmessaging and so many more NOT enough?

What do these contemporary solutions lack, as the Secure Messaging Scorecard suggests many applications have all these features?

What does blockchain provide when it comes to Secure Messaging and why it is necessary?

How can Military Interdepartmental Purchase Requests (MIPR) be implmented using the secure ledger or blockchain?

In particular, this paragraph of the proposal is not making sense to me

The messaging platform would act as the transport for a cyptographically sound record of all transactions whether they be MIPRs, contracts, troop movements or intelligence. Troops on the ground in denied communications environments would have a way to securely communicate back to HQ and DoD back office executives could rest assured that their logistics system is efficient, timely and safe from hackers. The benefits are broad and could even be applied to domains such as space. With crowded skies it’s important to maintain situational awareness of all satellites and those concerned with space situational awareness/telemetry or air traffic control could instantly share data between nations using a separate but equivalent ledger implementation thus removing questions as to the authenticity and integrity of the data.

What does transport mean here?
How does blockchain help troops communicate in denied communication environment?
I am also not clear about the argument on situational awareness of satellites and how does blockchain enable sharing data between nations.

Simple answers would really help me and others like me. Thanks


texts: I've forget my presale password and i'm trying to recover it with pyethrecover

texts:
Can someone help me please?
I'm using pyethrecover and i've got this bug when i'm trying to bruteforce with some password :


texts:
I create a struct array and map it to an address:

contract MyContract
{
    struct something {
        bytes32 test1;
        bytes32 test2;
        bytes32 test3;
    }

    mapping (address => Something[]) public stuff;
}

In the app I try to use the automatically created getter function like this:

let sender = web3.eth.accounts[0];

console.log(contract.stuff(sender))

It kicks back this error:

inpage.js:14246 Uncaught Error: Invalid number of arguments to Solidity function
    at Object.InvalidNumberOfSolidityArgs (inpage.js:14246)
    at c.validateArgs (inpage.js:14246)
    at c.toPayload (inpage.js:14246)
    at c.call (inpage.js:14246)
    at c.execute (inpage.js:14246)
    at addStuff (index.js:30)
    at HTMLButtonElement.onclick ((index):53)

What does the "stuff" getter function need? If i change the mapping to this:

mapping (address => Something) public stuff;

I can call it just fine. Do I need to pass it test1, test2, and test3?


texts: Etherscan "Write Contract" Tab - what is it for?

texts:
What is the purpose of the Write Contract Tab in Etherscan?

For example, if you look up the QTUM Token Contract on Etherscan (https://bit.ly/2IsddkT) and then tap on the Write Contract TAB, you have before you all of that contract's Functions:

-approve

-transferFrom()

-transfer

etc.

And I mean they're not just simply listed there, you can actually interact with them, input values into them, etc.

Why?

Are you actually able to execute all of these functions? Meaning, perform the transferring of Tokens from some person's account to your account for example?

I assume - and hope - the answer for this is "no", but am I right or wrong about that?

Cause it certainly seems its about to let you do this:
-it lets you connect your account to that contract via MetaMask,
-it then lets you set values - like how many Tokens you want to transfer to your own account, etc.

I mean I haven't actually pulled the trigger on executing any of the available functions (I don't wanna risk throwing away ETHER or "experimentation") - but its certainly didn't look like it was going to stop me from doing so.

So, what's going on here? What's the point of having this Tab, and this ability to "write" to the contract?


texts: Can you force your smart contract to only process transactions in separate blocks

texts:
I am working on a smart contract and trying to come up with ways through which I can make sure that each transaction sent to my Ethereum smart contract is only processed as part of separate block, that does not contain any other transaction related to my smart contract. Based on my own understanding and research on the subject, I believe that won't be technically possible as depending on network traffic, it is completely possible that multiple transactions for my smart contract are processed as part of the same block.
Do you think there's any way around it - or not possible at all.


texts: Is there any simple explanation to multisig wallets?

texts:
I read on ConsenSys and Ethereum MultiSigWallet. I got that "The purpose of multisig wallets is to increase security by requiring multiple parties to agree on transactions before execution. Transactions can be executed only when confirmed by a predefined number of owners"

Could any one provide a nice explanation to the two terms with simple application ?


texts: Unable to transfer ERC20 tokens from a contract

texts:
I'm having trouble getting a solidity contract method to transfer ERC20 tokens from address A to B assuming B has called approve outside the contract and setup sufficient allowance for A. The allowance value prints fine inside the contract but the transferFrom fails. I'm missing something in how the ownership and signatures are set up. I do have a workaround where the same transferFrom works outside the contract but I'd like to do it inside.

I set up a sample repo with truffle tests and an issue to describe the problem further:

https://github.com/PulseBlockchain/oz-sample-app/issues/1

This is an excerpt from a larger project where I have a similar problem.

It looks similar to this question, ERC20 approve and transferFrom from a contract, except I'm doing approve outside and want the contract to just do transferFrom. It looks like there is a way to do transfer from a contract like this Open Zeppelin CrowdSale contract does and which I have working in my project. I like to be able to do either transfer or transferFrom from my own contract and like to better understand ownership and signature rules around it.


texts: How is the address of an Ethereum contract computed?  What use cases are there for knowing a contract's address in advance?


texts: Truffle test: "Cannot read property 'gasUsed' of null" error. Truffle migrate works fine

texts:
Whenever I try and do truffle test I get the error

Cannot read property 'gasUsed' of null

But truffle migrate --reset works fine

More confusingly, to rule out something in one of my tests that is causing the problem, I have deleted everything from the tests folder. So- to my understanding- if there is nothing in the tests folder, truffle test should do the exact same thing as truffle migrate?! Is there some separate configuration the tests are referring to that could be causing this?


texts: Possible to get enum length / count in solidity contract?

texts:
Is it possible to access the length of an enum in solidity?
E.g.

pragma solidity >=0.4.16 <0.6.0;

contract test {
    enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }

    function move(uint8 _actionChoice) public {
        require (_actionChoice < ActionChoices.length);
        //....
    }

}


texts: How to specify the gas when deploying a new contract in Mist?

texts: When I send transactions to my contract, the wallet tells me that the gas runs out, so how can I specify the gas amount when deploy a new contract?


texts: Is it safe to share my signed transaction publicly?

texts:
If someone got hold of my Ethereum signed transaction, is my wallet still safe?
Can they extract the raw transaction from the signed transaction to get my private key?


texts: What is "a public key under ECIES", and how to get it?

texts:
I read the JSONRPC document of Parity these days.

And I want to encrypt my message with the public key and private key of the accounts in Parity.

I found a JSONRPC in this web parity_encryptMessage

But it refers that

  "Encrypt some data with a public key under ECIES."

And one of its parameters is

  "Hash - Public EC key generated with secp256k1 curve, truncated to the
  last 64 bytes."

I can't understand it. I don't know how to get it. It generate by Parity or it should generate by myself? Please give me some advice. Thanks a lot~


texts: Metamask shows "ALERT: Transaction Error. Exception thrown in contract code" but transaction succeeds without error

texts:
I've been testing my dapp and I noticed when I updated my contracts Metamask started to throw an error for one of the contracts we made a slight change to.
Metamask says the tx will fail and the contract will throw an error - but it doesn't. There is no error on the contract and everything works smoothly.
Metamask shows this: "ALERT: Transaction Error. Exception thrown in contract code."
A few times we've been able to remove the message by restarting our dev environment and metamask. But its not working this time.
Again - the submitted transaction is going through fine without any reverts or errors.
So... why is metamask showing this error message and how do we fix it?
edit: I've submitted multiple tx's when metamask shows this error and none of them have errored out. Basically just ignoring its message, but why is it happening.
Also testing the same contract with same input as our dapp uses  in remix throws no errors. So...something is screwed up somewhere but not sure what


texts: Differing values of liquidity tokens in Uniswap, when using the same formula

texts:
I implemented the logic of the uniswap protocol on my blockchain using uniswap v2 whitepaper. To check if its working, I am comparing it with real examples of creating liquidity. I come across examples of calculating the creation of a liquidity pool with different results, which are described by the sminted = √(xdeposited · ydeposited) formula. Here are some of them:
Correct calculation for example Uniswap V2: COIN 11 :
10000000e18 * 1900e18 = 19000000000e36
sqrt(19000000000e36) - 1000 = 137840487520902217678559

Incorrect calculation for the Uniswap V2: USDT 2 example:
sqrt(1.103511e18 * 0.005e18) - 1000 = 74280245364 // but in the transaction itself, the number of pool shares is 74280245364

Also, here are some more correct and incorrect calculations: USDT-HUB incorrect, correct, incorrect, incorrect, correct, incorrect.
Could I have missed something in the calculations?


texts: How to convert a bytes to string in Solidity?

texts:
I want to convert a bytes of length, say n, to a string in Solidity.

bytes memory ret = new bytes(3);
ret[0] = 0x41; // A
ret[1] = 0x42; // B
ret[2] = 0x43; // C
return string(ret); // results in ""

Doesn't work.

I get the empty string as result.

Any suggestions?


texts:
I have a global variable foo that I'd like people to be able to increment in a shared fashion.

int foo;
function addToFoo(int value) public {
   foo += value
}

Im concerned that if this function could fail due to reentracy.

for example: lets assume foo is currently equal to 1, then if user A calls addToFoo(1) and user B calls addToFoo(2) then ideally I'd like foo to be 3.
However, if user A and B make their calls at almost the exact same time then I'm concerned that foo could equal 1 or 2 instead of 3, due to both grabbing the same starting value of foo.

So my question is what is the best practice to ensure that the foo is always 3?

Can I use a mutex and loop while the mutex is in use or will this burn too much gas?

Should I just revert when foo is in use? That doest seem great.

Or should I have a queue where people add their values to the queue and then later I can loop through the whole queue and do all the summations? If I go with this solution then I'd have to break up the loop some how to ensure that it can scale to millions of additions.

None of these solutions seem great...

Any help would be great thanks!


texts:
I have a rather large list of accounts (HD wallets) I want to sweep into one.

They've all been imported into geth, and all have the same password.

I wrote a script to do this in node but get this error:

Error: Insufficient funds for gas * price + value

Here is the node script:

//web3
var Web3 = require('web3');
var web3 = new Web3();

//starting index... main account is 0... don't sweep that one ^.^
var startSweep = 1;

//account shell
var accounts = [];

//transaction cost... i think?
var gas = 21000;

//geth stuff
var sys = require('util');
var exec = require('child_process').execSync;
function puts(error, stdout, stderr) { sys.puts(stdout) };

//connect to node
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

//get accounts
var accounts = web3.eth.accounts;

//set default account for gas
web3.eth.defaultAccount = accounts[0];

//loop through accounts and sweep balances
for(var x = startSweep; x<accounts.length; x++){
    //get current account balance
    var balance = web3.eth.getBalance(accounts[x]);

    //if balance is greater than 0 lets transfer...
    if(balance > gas){
        //command to unlock account
        var execCommand = 'geth --exec "personal.unlockAccount(eth.accounts['+x+'], \'password\', 1000)" attach';
        console.log(execCommand);

        //execute command
        exec(execCommand, puts);
        console.log(' Unlocked account ' + accounts[x] + ' with a balance of ' + balance + '! ' + 'TRANSFERING!');
        var transaction = {
            "to" : accounts[0],
            "from" : accounts[x],
            "value" : balance - gas,
            "gas": gas
        };

        //send transaction
        web3.eth.sendTransaction(transaction);
        console.log('Sent transaction from : '+ accounts[x]);
    }
}

I read that the cost of a transaction was 21000, but I get that error.... So I just kept bumping the gas up until I received the error:

Error: Exceeds block gas limit

So I guess I'm doing something wrong. Any suggestions?


texts: How does MetaMask save our mnemonic phrase? Is it safe enough?

texts: How does MetaMask save our mnemonic phrase? Is it saved in browser local storage? Does it encrypt our mnemonic phrase?


texts: Transaction confirmed but wallet is on 0ETH and nothing happens

texts:
I'm using Bitcoin Core for like 2 years now and I'm used that when a transaction is confirmed on the blockchain it appears in my wallet but this is not the case with my newly created ETH wallet.

Here is a link to the transaction: https://etherscan.io/tx/0xbf77f2a4311d904540607850b3e621fe872cdbea4f91c45705b49ab0e38c25ab

Screenshot of the wallet:
http://take.ms/WJ1Bb

Thanks in advance.


texts:
Is this the current difficulty formula for Ethereum?
block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**((block.number // 100000) - 2))
What is the current value in place of 100000
Thank you


texts: How are non state changing smart contract functions executed?

texts:
I have a few questions about non state changing smart contract functions.
Say I have a smart contract deployed with a function that takes an input "num" and returns a value 10 * num. I presume this costs gas, but how is this function executed? Is it executed by a node/client like geth?
State doesn't change but is there a record of this transaction recorded on the blockchain?


texts:
I have a couple of questions.
First:
So, In a function, i created memory array. I want to pass this memory by reference to another function..
function test2() public returns(uint  a) {
        uint[2] memory gio;
        gio[0] = 100;
        gio[1] = 200;
        test3(gio);
        return gio[0];
    }

    function test3(uint[2] storage arr) private returns (uint) {
        arr[0] = 35;
    }

This doesn't work and says:

Invalid type for argument in function call. Invalid implicit
conversion from uint256[2] memory to uint256[2] storage pointer
requested. test3(gio); ^-^

Is it not possible ?
Second
internal and private functions are the only types of functions that can receive parameters as reference types, right ? since public and external functions being called could be dependent on another application, so another app can't pass parameters as references. Agreed ?
Third.
string test;

    function test2() public returns(uint  a) {
        test = " awesome ";
        test3(test);
        return 10;
    }

    function test3(string storage str) private  {
        str = " changed ";
    }

Why does calling test2 result in:

TypeError: Type literal_string " changed " is not implicitly
convertible to expected type string storage pointer. str = " changed
"; ^---------^


texts: How does the Ethereum Homestead difficulty adjustment algorithm work?

texts:
From From EIP 2, the Homestead difficulty adjustment algorithm is:

    block_diff = parent_diff + parent_diff // 2048 *
      max(1 - (block_timestamp - parent_timestamp) // 10, -99) +
      int(2**((block.number // 100000) - 2))

  where // is the integer division operator, eg. 6 // 2 = 3, 7 // 2 = 3, 8 // 2 = 4.

How does this work?

(This question was prompted by the question What was the first block mined with Homestead?)

Other related Q&As:

How is the Mining Difficulty calculated on Ethereum?
What is the measured distribution of block times since Homestead?


texts:
Testing it out :

Creating new account via "Create new account manually", it shows the phrase in the end, copy it to txt.

Deleting Account1, Creating new account via "Recover from phrase" - pasting the phrase = it created a different Account2 with different address.

Now, I can delete and re-create Account2 with this phrase, but not Account1.

Whats the deal here?


texts: How to enable vi mode in geth console? (readline's inputrc not honored)

texts:
Does the geth console input prompt use the standard readline library?

For apps that do, setting in ~/.inputrc:

set editing-mode vi

enables vi mode on the command prompt. For example, try

$ python
input()

with and without the above ~/.inputrc.

Geth Geth/v1.4.5-stable-a269a713/linux/go1.6.2 does not seem to honor the .inputrc setting. Missing feature (or bug)?


texts:
I created a paperwallet with myetherwallet a while ago. I tried to scan my private key with coinomi inorder to swipe the wallet, but I got an error: "There was a problem scanning: unsupported address"

my address looks as follows: (not an exact copy, but the + signs and the quanity of letters/digits are the same)

U2HGjk6Lhgf76hkl7KK890hgRRjkl097jjggujgf97khdhJ778Kw+pbH08jg7b8Ytt55G+hJhG755jkl8kkgFK55HJkkg8qrL54MGFkoFFDeK775JJL4333HHKKLPP99

The address looks strange to me, as I thought it should be 64 letters and numbers.
Is this an encrypted key? Is the key corrupt, or most likely do I have no clue what I'm doing???

Thanks for your help


texts: Contract: Get address as input and send address to another contract

texts:
Hey guys I'm curious about an idea i was having earlier. I am a total beginner so bare with me ;)
I want to create a contract that basically just sends ether to another contract. BUT the user should be able to input another address. This address and the ether will then be sent to another contract.

So in example User B sends a specific amount of Ether to Contract1. He also inputs another address he owns. Then, Contract1 sends the whole amount of Ether to Contract2, exporting the input address as well. I only want to get this far for now.

Is this even possible? And if so, can somebody write some example code? I can't find an address input option in the solidity documentation.

I'm not familiar with solidity so I'm just 'learning by doing' as they say.. :)

Thanks for your help!


texts: Uncaught TypeError: Cannot read property 'method' of undefined

texts:
I've been trying to run the following code:

$(document).ready(function(){

  var myContract;

  function startApp() {
    myContract = new web3.eth.Contract(crowdsaleABI,
    "0xfA6eeb8558c548B742E3745716aAEF04139a8d97");
  }

  function displayPrice() {
    myContract.methods.tokenPrice().call((err, result) => {
    console.log(web3.utils.fromWei(result, "ether"))});
  }

  window.addEventListener('load', function() {

    // Checking if Web3 has been injected by the browser
    (Mist/MetaMask)
    if (typeof web3 !== 'undefined') {
      // Use Mist/MetaMask's provider
      web3 = new Web3(web3.currentProvider);
      document.write("You are connected to MetaMask");
    } else {
      // Handle the case where the user doesn't have web3.
      document.write("You are not connected to MetaMask");
      web3 = new Web3(new
      Web3.providers.HttpProvider("HTTP://127.0.0.1:7545"));
    }
    // Now you can start your app & access web3js freely:
    startApp();

  });

 console.log("Hello World");
 displayPrice();

});

However, I've been getting the following errors:

Uncaught TypeError: Cannot read property 'methods' of undefined
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child

Particularly, first error is stopping me from doing any progress.
I'm running web3 1.0.0-beta.34 (checked using npm ls web3).


texts:
I created a paper wallet for my Ether a few weeks back, and have (stupidly) lost the JSON file that was created during the creation of that wallet. At the time I did not think that I needed that particular file, as I thought that like Bitcoin, only the public and private keys were essential. I do have access to both my public and private keys for my Ether paper wallet, and I'm now attempting to transfer Ether from that wallet to an exchange (i.e. Coinbase).

I've been attempting to create a new keyfile by following the advice in this post, but have been unsuccessful (When I attempt to run the "geth account import "c:\filename.txt" the console returns: "failed to load the private key - unexpected EOF").

At this point, I'm either trying to transfer funds out of my Ether wallet using only my public and private keys --or-- I'm attempting to create a new keyfile that will assist me in transferring said funds. It probably goes without saying that I'm pretty new to cryptocurrency, so advice given in layman would be greatly appreciated!


texts:
I have tried googling it as well as finding it here.

Many people here talk about it, but what actually is a DAG?


texts: How to detect nested mapping value existing

texts: I have mapping of mappings mapping(address => mapping(bytes32 => address)). How to detect that second-level mapping exists?


texts: Connect pyethapp to testrpc - Is there an equivalent to `geth attach` in pyethapp?

texts:
I have an instance of testrpc running:

testrpc -a 1000

when using geth, I'd do this:

geth attach rpc:http://localhost:8545

to link to it.

I have pyethapp installed and would like to do something similar - is this possible?

Looking through the code there is an rpc_client.py file that states:

""" A simple way of interacting to a ethereum node through JSON RPC commands. """

I interpret this as a means to connect to my testrpc simulated node, but I can't figure out which functions to use....

How do you connect to a testrpc simulated node using pyethapp?


texts: Scalability of a scientific computing proof of work token

texts:
Say I want to create a contract that rewards miners with an ERC20 token for discovering solutions to a certain mathematical problem where the following points apply:

The problem is well defined and with some moderate effort, one could write some solidity code that can verify solutions to the problem
There are many valid solutions to the problem
The solutions are valuable to mathematicians interested in the problem
Some solutions are bigger in terms of data size than others
Some solutions are more interesting than others but all solutions should be kept around for research purposes

As a more concrete example, say I wanted to re-implement prime coin using a Ethereum token (I'll call it PrimeToken). (I am not interested in doing this specifically, but it serves as a good enough example):

uint256 public lastNumber = 1;

function proofOfWork(uint256 number){
    if (number <= lastNumber) throw; //Always have to find a new prime number bigger than the last
    if (!isPrime(number)) throw; // Verify solution is valid
    //If it is valid, reward the miner and set the last solution as the submitted one
    lastNumber = number;
    balanceOf[msg.sender] += number - lastNumber;
}

As bigger and bigger prime numbers are discovered, the uint256 would overflow and I would have to change this to a bytes array to handle very large numbers, and implement some way of handling the byte array like a bigint. Assume I did this from the start and were competent with doing so.

My question is, how does this scale? What happens as the submitted byte array gets larger?

Will the miners submitting prime number solutions have to pay more and more ether (in gas fees) to get their PrimeTokens as the IsPrime() function takes more processing power to verify for larger numbers?
Is there a similar fee for the size of the data submitted?
Is there a limit to the size of the data submitted?
Will the blockchain become bloated with the large data storage requirements for the large numbers?
How do mathematicians interested in prime numbers find the previously submitted solutions? Can they just use a block explorer?
Are there any ways I could mitigate these scalability problems?


texts: What are the differences between Hyperledger Burrow and Ethereum?

texts:
What are the main differences for these two platforms (I know that Burrow runs EVM style smart contracts in a permissioned environment. Does that mean Burrow supports all the different smart contract languages as Ethereum does? What consensus algorithm is Burrow using? Ethereum uses Ether for transaction fees, what does Burrow use?)?

Thanks for answering.


texts: contract address returning as null value

texts:
I am trying to create a factory contract and storing the smart contract address in an array but when I trying to retrieve the value, it always gives null value. Please find the contracts that I have used below.

pragma solidity ^0.4.7;

contract ContractTest {
    bytes32 public Name;

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

pragma solidity ^0.4.7;
import './ContractTest.sol';

contract FactoryTest{
    address[2] newContracts;

    function createContract (bytes32 name) {
        address newContract = new ContractTest(name);
        newContracts[0]=newContract;
    }
        function getContract() returns(address) {
          return newContracts[0];
        }
}


texts: mapping to a mapping? or mapping to a struct

texts:
Is it possible to do something similar to the below?  Currently when compiling it will throw an error saying that "Name has to refer to a struct, enum or contract".  I also have a "working?" solution further below but I am unsure which would be the proper way.

mapping(address => uint256) shelf;
mapping (address => shelf) bookcase;

The idea being that an address would point to a bookcase which goes to a shelf which goes to an int (number of books).

The below works fine so far for setting the value for the shelf.  The problem in this version is that I can not make bookcase public and can't figure out how to create a getter.

struct shelf
{
  mapping(address => uint256) shelves;
}
mapping (address => shelves) bookcase;
bookcase[msg.sender] = shelf();
//shelf_address is argument from the function this code is in
bookcase[msg.sender].shelves[shelf_address] = 1;

Thanks for the pointers.


texts: Is it possible to copy the internal storage of a smart contract to a new contract?

texts:
Assume that I want to implement my own version of a suicide contract function with extended functionality. More specifically, I want to copy the internal storage state of the contract to a new contract address before I invalidate it. For example, I may have a mapping that stores users' tokens and I would like this information to be available in the new contract. I know that the delegatecall function can allow access to the contract's storage to other contract but what if I want to kill the initial contract.

One way that I thought this can be done is by adding a function in the contract like the following, where I explicitly write which data I want to be copied using the call function:

pragma solidity ^0.4.2;

contract Sample {
    uint public data;

    function setData(uint data_){
        data = data_;
    }

    function mySuicide(address newContract) {
        newContract.call(bytes4(sha3("setData(uint256)")), _n);
        suicide(newContract);
    }
}

contract NewContract {
    uint public data;

    function setData(uint data_){
        data = data_;
    }
}

However, the above example is simple as it is passing just a simple number.

So my questions are:

Will I be able to copy a more complex structure such as a mapping (address => address) without exceptions being thrown because of gas limit?
Is there any other more general approach?
Is it possible to make this copy of data off-chain?


texts:
The following code works, that is, I can call add(2,3) and then get(2,0) returns 3:

pragma solidity ^0.4.10;

contract Bar {
    struct Foo{
        uint x;
    }
    mapping(uint => Foo[]) foo;

    function add(uint id, uint _x) public {
        foo[id].push(Foo(_x));
    }

    function get(uint id, uint index) view public returns(uint){
        return foo[id][index].x;
    }
}

This code does not work, that is, I call add(0xB139e6071772FAdC0e1Ad79C63415a2866fD447F,3), and then get(0xB139e6071772FAdC0e1Ad79C63415a2866fD447F,0) returns 0:

pragma solidity ^0.4.10;

contract Bar {
    struct Foo{
        uint x;
    }
    mapping(address => Foo[]) foo;

    function add(address id, uint _x) public {
        foo[id].push(Foo(_x));
    }

    function get(address id, uint index) view public returns(uint){
        return foo[id][index].x;
    }
}

The only difference is that the uint type has been swapped with the address type in a couple of spots.


texts: Web3J: callback to retreive public struct

texts:
I am trying to access data stored in a contract from web3. I have managed to do so with a custom get function, however from what I have read online, every public variable has a built in get and set function created by Solidity. I also understood that it has somethign to do with callbacks, but I am not sure how to implement it in my js code. Here is what I have done to get my data so far:

Solidity Contract

contract OrganizationObject {

    struct organizationDetails {
        string name;
        string vat;
        string headquarterAddress;
    }

    organizationDetails public details;

    address[] public staff;

    function OrganizationObject (string name, string vat, string headquarterAddress){
        details.name = name;
        details.vat = vat;
        details.headquarterAddress = headquarterAddress;
    }

    function getDetails() public constant returns (bytes32[], string, string, string){
        return (order, details.name, details.vat, details.headquarterAddress);
    }

    function addStaff(address x){
        staff.push(x);
    }
}

web3

app.post('/api/getOrganisationDetails', stormpath.authenticationRequired, function(req, res){
    var rawString = req.user.customData;
    var stringJson = JSON.stringify(rawString);
    var customData = JSON.parse(stringJson);
    var web3 = new Web3();

    web3.setProvider(new web3.providers.HttpProvider(customData.ethereum_provider));
    var address = req.body.address;

    // creation of contract object
    var MyContract = web3.eth.contract(abi.abiOrganisationObject).at(address);
    var details = MyContract.getDetails();
    console.log(details);
    res.end(details).status(200);
});

I think the better solution would be to use the getter function from solidity, I have tried like this:

app.post('/api/getOrganisationDetails', stormpath.authenticationRequired, function(req, res){
    var rawString = req.user.customData;
    var stringJson = JSON.stringify(rawString);
    var customData = JSON.parse(stringJson);
    var web3 = new Web3();

    web3.setProvider(new web3.providers.HttpProvider(customData.ethereum_provider));
    var address = req.body.address;

    // creation of contract object
    var MyContract = web3.eth.contract(abi.abiOrganisationObject).at(address);
    var details = MyContract.details();
    console.log(details);
    res.end(details).status(200);
});

But it seems to want an argument in the MyContract.details(), which i assume is a callback. What should I do to be able to access the data stored inside MyContract.details ?


texts: Is running a ethereum node necessary to deploy contracts with JSON RPC?

texts:
everybody, I'm currently trying to learn how to automatically deploy a smart contract to the Ethereum blockchain and I heard of the JSON RPC way of doing that. There are the eth_sendTransaction and the eth_getTransactionReceipt that I think will be used at some point. Although, I didn't figure out how the transactions are signed. If someone could help me with any info I'll be very thankful.

But the main question is: Is it necessary to run an Ethereum node to automatically deploy and interact with smart contracts? This information wasn't very clear to me as a beginner. If it is necessary, is there any other way that I wouldn't need to run one node?

Thank you, guys!


texts: Where can I find the block that contains most recent state of contract's memory/storage?

texts:
I am considering trying to use or implementing some form of light Ethereum node that only needs access the most recent version of data stored in smart contract storage on the blockchain and trying to only download pertinent blocks. In this consideration, I am looking for more information about how a contract's memory is kept. I imagine that the initial state of all of a contracts persistent variables is stored in the same block that the contract is mined into.

Is there a way to know the block number/block data that contains the transaction that causes the change in state (most recent version) of this persistent contract storage?


texts: sending messages to a contract using geth

texts:
I have a working system for minting tokens and transferring them as follows -

> addrtoken.balanceOf(eth.accounts[0])
33333250
> addrtoken.balanceOf(eth.accounts[1])
50

I want to test the buyTokens function. The function uses msg.value and I am unsure how to test that. Here is the func below. Is there a way to send the msg.value in geth?

 // fallback function to buy tokens
 function () payable {
   buyTokens(msg.sender);
 }

  /**
   * Low level token purchse function
    * @param beneficiary will recieve the tokens.
   */
  function buyTokens(address beneficiary) payable whenNotPaused {
    require(beneficiary != 0x0);
  require(validPurchase());

uint256 weiAmount = msg.value;
// update weiRaised
weiRaised = weiRaised.add(weiAmount);
// compute amount of tokens created
uint256 tokens = weiAmount.mul(rate);

token.mint(beneficiary, tokens);
TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);
forwardFunds();
}


texts: Refill Ether to account after token transfer

texts: During token creation and token transfer some ethers are used as gas. What is the most efficient way to refill an account with the same amount of ether? So that it doesn't run out of funds(ether). I'm using a web3 version-1. Any suggestions are welcome.


texts: Whitelist.sol - Getting the array of whitelisted addresses

texts:
I am writing a token that inherits from Whitelist.sol. I would like to write a function that returns an array of addresses that are whitelisted.

It must be something along the lines of

function getWhitelistedUsers() public onlyOwner returns (address[]) {

    address[] memory whitelistedUsers = Roles[ROLE_WHITELISTED].bearer.keys();
    return whitelistedUsers;
}

but I am not sure I am on the right path. Can somebody help?


texts: Using web3.js in a react redux saga app - uncaught at check call error

texts:
I am trying to use Web3.js (Ethereum JavaScript API) in a ReactJS app with Redux / Saga.

This is my GetWeb3 function:

const GetWeb3 = () =>
  new Promise((resolve, reject) => {
    window.addEventListener("load", () => {
      let web3 = window.web3;
      const alreadyInjected = typeof web3 !== "undefined";
      if (alreadyInjected) {
        web3 = new Web3(web3.currentProvider);
        console.log("Injected web3 detected.");
        resolve(web3);
      } else {
        const provider = new Web3.providers.HttpProvider("http://127.0.0.1:7545");
        web3 = new Web3(provider);
        console.log("No web3 instance injected, using Local web3.");
        resolve(web3);
      }
    });
  });

export default GetWeb3;

and I am trying to use this inside a saga like this:

import { call, put } from "redux-saga/effects";
import truffleContract from "truffle-contract";

import GetWeb3 from "../../../Utils/GetWeb3";
import SimpleStorageContract from "../../../Data/SimpleStorageContract.json";

import { loadWeb3Done, loadWeb3Error } from "./Web3.actionCreators";

export function* loadWeb3(action) {
  try {
    const web3 = yield call(GetWeb3());
    const accounts = yield call(web3.eth.getAccounts());

    console.log('accounts', accounts);

    const contract = truffleContract(SimpleStorageContract);
    contract.setProvider(web3.currentProvider);
    const instance = yield call(contract.deployed());

    yield put(
      loadWeb3Done({
        web3,
        accounts,
        contract: instance
      })
    );
  } catch (e) {
    yield put(loadWeb3Error(e));
  }
}

When my app runs with the above, I am seeing this error:

  index.js:2178 uncaught at check call: argument [object Promise] is not
  a function
  stack_frame_overlay_proxy_console @ index.js:2178

  GetWeb3.js:14 Injected web3 detected.

and I am not seeing the console log of accounts.

Any ideas what I might be doing wrong here?


texts: I deposited $ into Coinbase from my bank account, however the money hasn't cleared yet and it will only be available in 7 days. Do I get the price of ETH BTC LTC when I clicked 'BUY' (although it hasn't cleared) or when the money is in my Coinbase account?


texts:
With this code:

pragma solidity ^0.4.0;

contract Test {
    string word = "Hi Guys";

    function getWord() constant returns(string) {
        return word;
    }

   function resetWord() returns(string) {
       word="Hi Guys again";
        return("Hi Guys again");
    }
}

With function getWord() i got "Hi Guys" in the bottom window of Remix.
But with function resetWord i doesn't get text on the bottom window of Remix.
What i get is:

  transact to browser/test.sol:Test.resetWord pending ...  [vm]
  from:0xca3...a733c, to:browser/test.sol:Test.resetWord()
  0x0dc...97caf, value:0 wei, data:0x1f2...09393, 0 logs,
  hash:0xaea...bad80

and i don't see "Hi Guys again".
The content of variable word is correctly update.

Why? Can anyone tell me why?

Thanks in advance.


texts: Can I change the comments in a contract and still pass Etherscan verification?

texts:
Suppose that you have a contract, someone audited it, and you would like to use that specific version for compilation and deployment to Ethereum.
Now, you want to verify the source code on Etherscan, but say that you want to modify one or more comments before you verify the source code for the first time. Would Etherscan still be able to pass the verification or not?
I know that changing just one character in a contract changes the metadata hash, but I'm not sure whether Etherscan checks for that.


texts:
Here's a problem. There's a contract with array of struct items. I need to for loop over every item in another contract.

pragma solidity ^0.4.4;
import 'common/Object.sol';
import 'token/Recipient.sol';

contract Congress is Object, Recipient {
...
    /**
     * @dev Archive of all member proposals
     */
    Proposal[] public proposals;

    /**
     * @dev Count of proposals in archive
     */
    function numProposals() constant returns (uint256)
    { return proposals.length; }

    struct Proposal {
        address recipient;
        uint256 amount;
        string  description;
        uint256 votingDeadline;
        bool    executed;
        bool    proposalPassed;
        uint256 numberOfVotes;
        int256  currentResult;
        bytes32 proposalHash;
        Vote[]  votes;
        mapping(address => bool) voted;
    }

  ...
}

and in other contract I need to do something like this

pragma solidity ^0.4.4;
import './Lesson.sol';
import 'foundation/Congress.sol';

contract Lesson_6 is Lesson {
    function Lesson_6(address _dealer, uint _reward)
             Lesson(_dealer, _reward) {}

    function execute(Congress _congress) {
        for(uint i = 0; i < _congress.numProposals(); ++i) {
            if(_congress.proposals[i].proposalPassed) {  // <-- here's the problem
                passed(msg.sender);
                break;
            }
        }
    }
}

Compiler says Error: Indexed expression has to be a type, mapping or array (is function (uint256) constant external returns (address,uint256,inaccessible dynamic type,uint256,bool,bool,uint256,int256,bytes32))

How can I solve this? Thanks


texts: Tokens transferred to contract by mistake

texts: I transferred some tokens to this contract 0xd0507b66A2d4C4593a54B0fa45cBAaAC2Bb04CEA and the creator of this contract is 0x102f8471d87d3Ef344af9Bd5c0845ca0A7a1d397, and I was wondering how to get my tokens transferred back to me? Any help much appreciated. x


texts: Contract design on querying list with certain outcome - O(n) issue

texts:
I need to query a list of Campaign from smart contract to display on my dapp.
It would be easily done in a traditional database (we have did this in the past using traditional db but now we want to migrate it to blokchain) but i am unaware of how this can be done efficiently in blockchain.

Obviously, I can't be afford to looping each of the campaign address,
follow by loop the detail inside (it would be total disaster if i have let say 10k campaign). I am trying to make use of event log.

However, I still think that watching over 10,000 address in event log for each event needed (and keep increasing) and processing it in server after retrieval at a same time would be an issue with web3.

Any expert have been working on similar issue. Would appreciate if you could give some hint on this.

Note: The actual retrieval result list and filtering is far complicated than below (with our existing structure on traditional db) but I need to get some initial idea on how to approach this.

The data of campaign list to get back as follow.

[
    {
        campaignName: "string", (note that campaignName can be updated)
        minimumContribution: "int",
        campaignContributionWithMostContributionName: "string",
        campaignContributionWithMostContributorUserCount: "int",
        compaignContributorTotalUserCount: "int"
    }
]

Contract sample

contract CampaignFactory {
    address[] public deployedCampaigns;

    function createCampaign(uint minimum) public {
        address newCampaign = new Campaign(campaignName, minimum, msg.sender);
        deployedCampaigns.push(newCampaign);
    }

    function getDeployedCampaigns() public view returns (address[]) {
        return deployedCampaigns;
    }
}

contract Campaign {
    bytes32[] public contributionNameList;

    event UserContribution(address indexed _owner, bytes32 indexed _outcome, uint _tokenAmount);
    event CampaignContributionAdded(bytes32 indexed _id);

    function Campaign(string campaignName, uint minimum, address creator) public {
        manager = creator;
        minimumContribution = minimum;
    }

    function setCampaignName(string _campaignName) public {
        campaignName = _campaignName;
    }

    function addCampaignContribution(bytes32 contributionName) {
        ...
        emit CampaignContributionAdded(contributionName);
    }

    function addUserContribution(uint tokenAmount, bytes32 contributionName) {
        ...
        emit UserContribution(msg.sender, contributionName, tokenAmount);
    }
}


texts: How does .transfer get ether into a testrpc account?

texts:
I'm running the CrowdFunding example from the Solidity docs and wondering why the ether balance doesn't increase correctly after running checkGoalReached in the code below:

function checkGoalReached(uint campaignID) returns (bool reached) {
        Campaign storage c = campaigns[campaignID];
        if (c.amount < c.fundingGoal)
            return false;
        uint amount = c.amount;
        c.amount = 0;
        c.beneficiary.transfer(amount);
        return true;
    }

Before I run this function, I checked the balance of the 2nd account in my testrpc via web3.eth.getBalance(web3.eth.accounts[1]) and the result is

{ [String: '100000000000000000000'] s: 1, e: 20, c: [ 1000000 ] }

After running checkGoalReached a transaction posts in testrpc but after running getBalance again, this is the result:

{ [String: '100000000000000016000'] s: 1, e: 20, c: [ 1000000, 16000 ] }

Why doesn't the original 1,000,000 ether increase to 1,016,000 but rather creates a 2nd element in the balance?


texts: What is the simplest way to allow a contract to pay for gas?

texts:
EIP86 and abstraction discussion is exciting for the future, but what are the things we could change first, to allow a contract to pay for gas?

For example, for the withdraw transactions on BabyZoE, they claimed to solve this issue with cryptoeconomics -- I think here the intended recipient instead hands over the zero-knowledge proof (of coins being transferred to himself) to a user who does have sufficient gas, and this user then submits the proof to the contract, and gets a little reward.

However, this isn't possible in all circumstances, and malicious users could just refuse to submit the proofs, very easily and lazily DoSing the contract.

So in the meantime, before the metropolis hardfork and introduction of EIP86, what would be the minimum possible changes that would allow contracts to pay for gas?


texts: Can't run Parity: "Failed to create lock file, the process cannot access the file because it is being used by another process"

texts:
trying to run parity, I get the following  error:

Client  service error: Client(Database("IO error: Failed  to create lock file:        C:\\Users\\mjensen01\AppData\\Local\\Parity\\Ethereum\\chains\\ethereum\\db\\906a34e69aec8c0d\\overlayrecent\\db/LOCK:  The process cannot access the file because  it is being used by another process.\r\n"))

I ran the windows  executable from here:  https://github.com/paritytech/parity/releases, then navigated to the directory where  it got installed, and put in parity --warp, as explained here:  https://github.com/paritytech/parity/wiki/Getting-Synced.  It seems there are some instructions missing?  ...


texts: Building ethminer on Win7 using CMake & VS2015

texts:
I'm trying to build ethminer on a windows box and am Visual Studio 2015 fails. The steps that I take are the following:

Download ethminer/cpp-ethereum and install dependencies using the command line prompt with Administrator privileges:

git clone https://github.com/Genoil/cpp-ethereum.git
cd extdep
getstuff.bat

So far, so good, now I create (I've struggled a bit with CMake) the Visual Studio 2015 project solution files using CMake:

mkdir build
cd build
cmake.exe -DBUNDLE=cudaminer -G "Visual Studio 14 2015 Win64" ..

Everything seems okay (the solution files are generated) but when I try to build from VS I get a large number of errors:

Severity    Code    Description Project File    Line    Suppression State
Error   C2206   'swap': typedef cannot be used for function definition (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)  devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  21
Error   C2988   unrecognizable template declaration/definition (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)  devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  35
Error   C2059   syntax error: ')' (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)   devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  35
Error   C2065   '_Ty': undeclared identifier (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)    devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  50
Error   C2923   'std::is_nothrow_move_constructible': '_Ty' is not a valid template type argument for parameter '_Ty' (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)   devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  50
Error   C2923   'std::is_nothrow_move_assignable': '_Ty' is not a valid template type argument for parameter '_Ty' (compiling source file C:Ethereum-Miner\cpp-ethereum\libdevcore\Common.cpp)  devcore C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility  50

Also, I can't seem to find the compiler configuration details (it seems like the CXX compiler is not being used).


texts: Truffle does not work - could not find suitable configuration file

texts:
I have searched some answers here and on google as well but none of them actually apply to my case.

I tried on console and power shell to run truffle migrate but I keep getting

could not find suitable configuration file

I saw that sometimes renaming the truffle-config.js is also an option but I just don't find this file on my computer even after running

npm install --force -g truffle

Any ideas of what could that be?


texts:
I tried the following in the console:

web3.shh.post({topics: ["a"], payload: "0x847a786376", ttl: "0x1E", workToProve: "0x9" })

var f = web3.shh.filter({topics: ["a"]})

f.get()

  [{
  expiry: 0,
  from: "0x0",
  hash: "0x31fd2b2a2103ba67951aed1d00b726bd666a60f5387f171be99b3518c10bece2",
  payload: "0x847a786376",
  sent: 1480886520,
  to: "0x0",
  topics: [],
  ttl: 30,
  workProved: 0
  }]

web3.shh.getMessages("a")

  TypeError: Cannot access member 'map' of undefined
  at web3.js:3839:19
  at web3.js:4939:28
  at map ()
  at web3.js:4938:12
  at web3.js:4964:18
  at web3.js:4989:23
  at :1:1

What is the mistake with the getMessages command? why it is throwing such an error?


texts:
Looking at my Parity UI at the moment and finding out I have two issues when moving my UKG to another address.

it says the Parity UI is not connected to any peers, but i have a perfectly working internet connection. How can I resolve this?

When making a transfer at some point it asks me to select a local key. I can't find any.

Hope you can help me out. Much appreciated.
BR Ralph


texts:
When we call a contract method, what will be the gas limit?

Is there any other gas limit besides the block gas limit?  If there are any others, can we manually set the gas limit when we call a method?


texts: Identity valuation using smart contracts

texts:
Hi I'm currently exploring whether it makes sense to build a platform which would use a blockchain to verify a user and the data that they would add to the platform.

Very simple example would be around people's ideas, so if you were to upload a meme for example the meme generator could say memes 1-3 a free to view, 4 has a viewing cost of 0.003 eth and if another user wanted to forward the generated meme the cost would be 0.006 eth.

From an efficiency standpoint would it make sense to build this all in ethereum, build part of it ( verification and smart contract)  into ethereum  whilst the rest would be in a normal database or would the most efficient test case to be to build it using a normal database entirely?

If it doesn't make sense to use the identity capabilities of a blockchain for idea protection and monetisation what are the major flaws in my initial thinking?


texts:
I was wondering...

Will Constantinople hard fork surely replace the current fork?

Is there any chance that the Constantinople fork and the current one will co-exist?

If so, any replay attack protection was designed?

Thanks


texts: Will i need a front end framework like React, while using web3 to build Decentralized Applications?


texts: Possible to store the blockchain in a different directory?

texts:
I'm running geth on Linux within a Chromebook. The blockchain is being stored within ~/.ethereum, along with other important files. Problem is, the storage capacity on my Chromebook is quite limited so it is difficult to keep the data under the user directory.

I have an SD card where I'd like to save the blockchain while keeping the geth installation in the home directory and local to the computer. How can I do this? I don't believe this has to do with --datadir (that's just for the keystore, right?). Any guidance or documentation is helpful, since I basically can't sync with the network with my limited storage as is. Thanks!


texts: How to deploy A contract created by another contract in the browser?

texts:
Hey I am making a smart contract that create another smart contracts. Organization.sol create Session.sol . When I create a session using createdSession function I got it's address and I already had the abi. Now I need to deploy the contract from the browser(to use function like take_feedback or seeResult). Could anyone tell me how please.
I run my contract in localhost using truffle develop command and MetaMask.

Solidity code

pragma solidity 0.5.0;
//Session

contract Session {

      address public creator;  // The address of parent Organization

      string sessionName;
      string description;
      uint startTime;
      uint endTime;
      address[] lecturer;
      address[] attendes;

      int[] result;
      mapping(address => int) public attendes_feedback; //institution boardMembers
      modifier onTime(uint _startTime){
            require(now < _startTime);
            _;
      }
      constructor (string memory _sessionName, string memory _description, uint _startTime,uint _endTime,address[] memory   _lecturer,address[] memory  _attendes) public onTime(_startTime){

              sessionName =  _sessionName;
              description = _description;
              startTime = _startTime;
              endTime = _endTime;
              attendes = _attendes;
              lecturer = _lecturer;
              initAttendes(attendes);
      }

    function initAttendes(address[] memory _attendes) private{
           for(uint i=0 ; i < _attendes.length ; i++){
            attendes_feedback[_attendes[i]] = -1;
        }
    }

    function Time() public view returns (bool){
       return (now >=  startTime  && now <= endTime);
     }

    modifier checkTime(){
        require(Time());
        _;
      }
    function take_feedback(address _voter,uint8 _feedback)  public checkTime {
          require(attendes_feedback[_voter] != 0);
          attendes_feedback[_voter] = _feedback;
          result[_feedback]++;
    }

  function seeResult() public view returns(int[] memory){
          return result;
  }

 }

contract Organization {

     address creator;
     event sessionnCreated(string name,address sessionAddress ,address creator);

     /*  modifier onlyCreator(){
        require(msg.sender == creator);
        _;
    } */
     function createdSession(
      string memory _sessionName,
      string memory _description,
      uint _startTime,
      uint _endTime,
      address[] memory _lecturer,
      address[] memory _attendes
     ) public   returns(address) {

        Session sessionAddress = new Session(_sessionName , _description , _startTime , _endTime, _lecturer,_attendes );
        emit sessionnCreated(_sessionName,address(sessionAddress),creator);
        return address(sessionAddress);
     }
}

Web3js Code

    initSession: async function(_address) {
            var abi = web3.eth.contract(SessionArtifact.abi);
            var session = abi.at(_address);
            alert("your session is created!!")
             /*Deploy Contract here!*/
               //need to deploy contract first before calling functions
            /*Call  function */
            await session.take_feedback('0xa8ff46045fa2c6a0af361819b62126e1b0ec8909', 5).send({ from: this.account });

        },


texts:
This is a simple contract that has a function input_data(bytes data) and a simple fallback function that passes msg.data to function input_data.

contract test_input_data{

address owner;

event log_input_data(address result);

constructor() public{

    owner = msg.sender;
}

function input_data(bytes data) public payable{

    address n = address(keccak256(data));

    emit log_input_data(n);

}

function() public payable{
    input_data(msg.data);
}}

The contract logs the hashed data converted to an address variable.
Why when I call input_data(data = 1), the log is different than when I do a transaction to the contract (so calling the fallback) attaching data=1 to the transaction?

Here is an example:
input_data(data = 1)    log = 0x057beebb9be2ac30c6410aa38d4f3fbe41dcffd2
fallback() = 1          log = 0xdcc703c0e500b653ca82273b7bfad8045d85a470

used:metamask, remix, rinkeby testnet, myetherwallet.
Thanks!


texts:
I've heard that Ethereum mining is ASIC resistant since it requires memory-hard hashing algorithms. However, why can't miners buy large DRAM and devote the memory to ASIC mining? What prevents miners from making an ASIC paired with large DRAM?

Thanks in advance.