texts: Using distribution function error in Solidity

texts:
I have a simple contract where I implemented a mechanism that sends ETH to contributors. When I call contribute function everything works great, but if I use something like that bulkSend(msg.value / 2) I have an error:

  revert    The transaction has been reverted to the initial state.
  Note: The called function should be payable if you send value and the value you send should be less than your current balance.  Debug the transaction to get more information.

What's wrong?

pragma solidity >=0.4.22 <0.7.0;

contract Test {

    address payable[] public contributors;

    constructor() public {}

    function bulkSend(uint256 amount) public payable {
        uint256 share = amount / contributors.length;
        uint256 length = contributors.length;
        uint256 currentSum = 0;
        for (uint256 i = 0; i < length; i++) {
            require(share > 0);
            currentSum += share;
            require(currentSum <= msg.value);
            contributors[i].transfer(share);
        }
        require(currentSum == msg.value);
    }

    function contribute() public payable {
        contributors.push(msg.sender);
        bulkSend(msg.value);
    }
}


texts: How to add a wallet to your geth account list

texts:
I just created a new account on myetherwallet.com and installed geth on windows.
I opened cmd and typed in 'cd/' and typed 'geth account list'.

In return, I got a warning saying there's no etherbase set and no accounts found as default.

Naturally, I wanted to add my existing account to the list.

So I typed 'geth account update 0x65E6ee5Eb448720E42D10542C5DE11eAaE5e384D'

Then it said

  no etherbase set and no accounts found as default
  unlocking account 0x65E6ee5Eb448720E42D10542C5DE11eAaE5e384D | Attempt 1/3

I typed in the password I typed in on myetherwallet.com when I created my account.

In turn, it said

  'Fatal : Failed to unlock account 0x65E6ee5Eb448720E42D10542C5DE11eAaE5e384D (no keyfor given address or file).

Not sure how to proceed from here... Any help?


texts: How do you refer to a contract own address inside it?

texts:
I am attempting to use 2 contracts together, and I need my 2nd contract to pass his own address to the first contract.

Is there an easy way to do this? Like this.address?

Or should I update my contract own address into a variable?


texts: Understanding economic finality in PoW and PoS

texts:
Before I get into the question I wanted to point out that I am referring to a specific part of a specific article. You don't actually have to read the article to help with the question but it's here if you're interested.
In that article, two flavors of economic finality are described.
The first one seems to describe PoW, where validators lose money if the block they added does not end up in the final chain:

A block can be economically finalized if a sufficient number of validators have signed cryptoeconomic claims of the form "I agree to lose X in all histories where block B is not included". This gives clients assurance that either (i) B is part of the canonical chain, or (ii) validators lost a large amount of money in order to trick them into thinking that this is the case.

I don't quite follow the second item though:

A block can be economically finalized if a sufficient number of validators have signed messages expressing support for block B, and there is a mathematical proof that if some B' != B is also finalized under the same definition then validators lose a large amount of money. If clients see this, and also validate the chain, and validity plus finality is a sufficient condition for precedence in the canonical fork choice rule, then they get an assurance that either (i) B is part of the canonical chain, or (ii) validators lost a large amount of money in making a conflicting chain that was also finalized.

This second description presumably refers to PoS, but this explanation feels very abstract to me. Can somebody explain this to me in different words?


texts: Derived contract not selected by defaut on remix

texts:
I have two simple contracts, a base one (BaseClass.sol):
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.7.0;

abstract contract BaseContract {

    address private immutable wallet;

    constructor(address _wallet) {

        require(_wallet != address(0), "address not set");

        wallet = _wallet;
    }
}

And a contract that derives from the base one by passing the wallet address on the constructor (DerivedClass.sol):
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.7.0;

import "./BaseClass.sol";

contract DerivedContract
    is BaseContract(0x0000000000000000000000000000000000000000) {

    constructor() {}
}

Everything works but on remix the default selected contract is always BaseContract, not DerivedContract.

This is cumbersome because I need to keep needing to switch back to DerivedContract when deploying.
Any way to have DerivedContract set as the default contract when compiling it?
Thanks!


texts: I have a lot of ether wallet . How can i send all my ether to single wallet. I cant to send single to single it will take a lot of time


texts:
The Question:
Currently my balances in Parity are wrong. Is there a way to delete my accounts and their history in parity, such that I can re-import the geth keystore files into Parity, and have their balances retrieved from the network?

Background:
I sent several transactions out when my Parity node was out of sync, so the request was submitted to the network, and recognized, but the balances in my Parity instance remained the same, and every time I launch it, the transaction still have not been processed/acknowledged by the browser, although the account balances have changed. The node is now synced, yet the balances in Parity do not match the actual account balances; some are higher, some are lower.

For awhile this was okay, because I was just selling the tokens, so I could just check my balance on etherscan.io and then send outward. However, I made the BONEHEAD mistake of transferring some ETH to a Parity account of mine. Since the original balance was 0.1, and now it's more like 2.5, I no longer can access the other 2.4 ETH, because there is insufficient funds in the account. Yeah, whoops!

I have kept all of the original geth keystore files for each of these accounts, which are now in Parity. I have tried to delete them from Parity, and then reimport them, yet the account history (txns attempted in Parity), as well as their balance remain what they were previously. How can I clear the Parity browser's incorrect assumptions about my account balances, and have it treat them like newly imported accounts again?

Thank you!


texts: why do ERC223 supporting contracts need to maintain the token list

texts:
I was going through ERC223 and read that contracts which are supporting any erc223 token contract should maintain the list for them so that they can accept only those tokens.

Is that the correct understanding ?

If yes then why can't any contract which are supporting ERC223 can just accept all ERC223 tokens and if someone sents by mistake then provide the provision to withdraw those tokens like using

// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
    return ERC20Interface(tokenAddress).transfer(owner, tokens);
}


texts: Auction project in Solidity: Why do I get "VM error: invalid opcode" for this code?

texts:
I am trying to do an Auction project and this part is bugging me. I can't figure out what is the problem that's causing the following error message: "VM error: invalid opcode.". Even if I do this simple smart contact I get the same error message. So I would like it if someone can figure out what is the problem with the provided smart contract. Thanks!
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.0 < 0.7.0;

contract testing {

    mapping(address => uint256[]) fundsByBidder;
    mapping(uint256 => uint256) newBidToGoods;

    function update(uint256 _goodsId) public payable {
        newBidToGoods[_goodsId] = fundsByBidder[msg.sender][_goodsId] + msg.value;
    }

    function show(uint256 _goodsId) public view returns(uint256) {
        return newBidToGoods[_goodsId];
    }
}


texts: Signing a transaction with uport can't approve as the selected account can't change.How can i change in uport selected account?

texts:
I am developing a dapp with uport verifications but when I go for saving information into ropsten network, a uport signing transaction appears on my screen and I can't approved the transaction.

I have no balance on selected account on uport. but I have balance on others account on ropsten network. how can I change the selected account on mu uport mobile app.


texts: Using an ERC20 contract to create blocks of newly minted tokens

texts:
I am wanting to find out the best method to create a contract that allows for an initial release of 1M tokens (US$5 par value) and then at 98% of hard cap, another 1M tokens is minted and made available for sale. This process would need to be supported in up to 20 new mints.

The issue is this - at each new mint, does the value of the token (if it is traded on an exchange) get released at the original value (US$5 par value) or will they release at the current traded price?

Does anyone have a code example of something similar?


texts:
This may be javascript question, but I am totally out of ideas.

I have a function in solidity code returning a variable:

  function getIdentifier() public view returns (string) {
    return identifier;
  }

I want to simply call this function with web3.js and store result as a variable. But all I can do is console.log the result (I know, I know =/).

Following code console.logs the variable:

contractInstance.methods.getIdentifier().call().then(console.log);

Works fine, but I simply want to store the return of getIdentifier() in a variable x.

None of the following naive code work:

x = contractInstance.methods.getIdentifier();
x = contractInstance.methods.getIdentifier().call();

I am sorry for a dumb question, but I have tried tons of things and it still does not work.

EDIT:
Thanks smarx your code works, but I still would like to keep the variable for later use. Strangely something like this does not work:

var y = "";
contractInstance.methods.getIdentifier().call()
.then(function (x) {
  y = x;
});
console.log(y) // still empty!!! :(


texts: Smart contract works on remix and ganache but not on private chain developed by geth

texts:
The smart contract works well on the ganache and remix but not work on the private chain, even though i use the --testnet

  geth --identity "EDU" --rpccorsdomain "*" --rpc --rpcport "8545"
  --datadir data --allow-insecure-unlock --port "30303" --rpcapi "miner,debug,personal,db,eth,net,web3" --testnet --nodiscover  console

this is how i start the console

  development: {
        host: "127.0.0.1",     // Localhost (default: none)
        port: 8545,            // Standard Ethereum port (default: none)
        network_id: "*",       // Any network (default: none)
       },

this is the config of my truffle

  pragma solidity >=0.4.22 <0.7.0; contract Modify {
      event modified_student(
          address indexed _from,
          bytes32 _data
      );
      event modified_teacher(
          address indexed _from,
          bytes32 _data
      );
      event modified_auth(
          address indexed _from,
          bytes32 _data
      );
      function modify_auth(bytes32 data ) public payable
      {
          emit modified_auth(msg.sender, data);
      }
      function modify_teacher(bytes32 data ) public payable
      {
          emit modified_teacher(msg.sender, data);
      }
      function modify_student(bytes32 data ) public payable
      {
          emit modified_student(msg.sender, data);
      } }

this is the smart contract and I use web3 to call the modify_student function

there suppose to have something in the log but actually it's not.
I suppose that might be a problem with the gas estimation, the gas estimation seems not work. and no matter how many gas i set for the transaction, it will run out all of them. the contract runs well on remix and ganache. I can not find the reason.


texts: Securing intermediate values of state variable

texts:
Consider the voting contract as described here. The flow of the contract is like this:

Create a new contract with three candidates for whom votes are cast.
Votes are cast by users.
Number of votes won by a candidate can be seen at any point in time.

My requirement is as follows:

Create a new contract with n candidates for whom votes are cast.
Votes are cast by a pre-determined user community.
Voting is allowed up to a pre-determined date.
At the end date, the number of votes for each candidate is counted and the winner announced.

Clearly, until the voting is over, the number of votes won by a candidate shouldn't be revealed. However, since the contract state is always available on the blockchain, how can one hide the "intermediate state", i.e. the number of votes won by a candidate, until the "final state", i.e. the position of candidates?

The voting contract code, as available in the link above, is shown here:

pragma solidity ^0.4.11;
// We have to specify what version of compiler this code will compile with

contract Voting {
  /* mapping field below is equivalent to an associative array or hash.
  The key of the mapping is candidate name stored as type bytes32 and value is
  an unsigned integer to store the vote count
  */

  mapping (bytes32 => uint8) public votesReceived;

  /* Solidity doesn't let you pass in an array of strings in the constructor (yet).
  We will use an array of bytes32 instead to store the list of candidates
  */

  bytes32[] public candidateList;

  /* This is the constructor which will be called once when you
  deploy the contract to the blockchain. When we deploy the contract,
  we will pass an array of candidates who will be contesting in the election
  */
  function Voting(bytes32[] candidateNames) {
    candidateList = candidateNames;
  }

  // This function returns the total votes a candidate has received so far
  function totalVotesFor(bytes32 candidate) returns (uint8) {
    if (validCandidate(candidate) == false) throw;
    return votesReceived[candidate];
  }

  // This function increments the vote count for the specified candidate. This
  // is equivalent to casting a vote
  function voteForCandidate(bytes32 candidate) {
    if (validCandidate(candidate) == false) throw;
    votesReceived[candidate] += 1;
  }

  function validCandidate(bytes32 candidate) returns (bool) {
    for(uint i = 0; i < candidateList.length; i++) {
      if (candidateList[i] == candidate) {
        return true;
      }
    }
    return false;
  }
}


texts: Hi I'm planning to setup a private ethereum network. So my doubt is, since my network is private, Is it possible to get real ether whose value can be exchanged for real money? Or private network in only for testing or something like that. I have read that private networks can also be useful for mining.


texts:
This comes happening being some time with me and i'm getting upset about it.
In some terminal, i start geth with:

geth -rpc --mine --fast --cache=1024

And in another terminal i start mine with my GPU with:

ethminer -G --farm-recheck 200

So i get into the console with the third terminal using:

geth attach

There i can list my  two wallets

> eth.accounts
["0x2d8a0028428d556882818d9a8d2d1ed7a0aed609", "0x1657ea92300a544aee12a1b57f7ef2a2f37bbc24"]

And with some time, i can even see some ether comming:

> web3.fromWei(eth.getBalance(eth.coinbase), "ether");
95

But, if a close the first geth (with the -rpcflag), when i restart it, my balance shows 0.
At the Etherscan my account still showing 0 eth.
I tried to make a transaction from my primary account to the second, with something like:

eth.sendTransaction({from:eth.coinbase, to:"0x1657ea92300a544aee12a1b57f7ef2a2f37bbc24", value: web3.toWei(90, "ether")})

But i got the erro that i'm  exceeding gas limit, and sure i'm, 'cause when i aks for my gasLimit, with

> eth.getBlock("latest").gasLimit

I got something near 5060. Some other status of my geth right now:

> net.listening
true
> eth.getBlock("latest").number
20
> net.peerCount
25
> eth.syncing
{
  currentBlock: 3123614,
  highestBlock: 4253828,
  knownStates: 10525102,
  pulledStates: 10519480,
  startingBlock: 0
}

There is almost 2 days that my geth -rpc console still  importing new blocks and states.
How can i make my ether account keeps my balance from every  time i reset the -rpc server? I found here that a genesis.json would limit my gasLimit, but i just find how to initialize a new server with sending the json file, how can i update a existing one?


texts: What is a better way to use whisper to implement a chat room?

texts:
I want to use whisper to implement a chat room in my dapp. I learned about whisper, if you want to realize the function of private chat, you need to know the public key of other people. For a user who has just logged in the chat room, how does he obtain the public keys of other people. One way I currently think of is to store the private keys of the logged-in users in the smart contract, so that the newly logged-in user can obtain the public keys of other users through the smart contract, and then realize private chat. I want to know if there are other better ways to get the private keys of other users.
Hope you can give me some help, thanks!


texts: How do you listen to block changes using web3 (1.0.0) and MetaMask ?

texts: I need to display a message (in my react app) when the block count reaches a particular number. I tried using web3.eth.subscribe but MetaMask provider does not support that. So is there any other way i can listen to block updates in the blockchain (using ganache for dev).


texts: What is the proper way to build and call a specific version of solidity?

texts:
I am getting the following error from solc:

Error: Source file requires different compiler version (current compiler is 0.4.11-develop.2017.6.22+commit.68ef5810.Darwin.appleclang - note that nightly builds are considered to be strictly less than the released version
pragma solidity 0.4.11;
^---------------------^

In order to build solc, I:

cloned the solidity repository,
ran git  checkout v0.4.11 which successfully got the tag/v0.4.11. 3. completed the build process
made sure solc was in my path

solc --version
solc, the solidity compiler commandline interface
Version: 0.4.11-develop.2017.6.22+commit.68ef5810.Darwin.appleclang

So, that is the v0.4.11 release, but the version number has today's date in it. Is that the source of the error?

System is macOS Sierra 10.12.5.


texts: I have just simple website in html on hosting. How to create login with metamask on website? Do I need use server?


texts:
When using the using foo for type syntax, the methods of a type will return an empty tuple instead of the explicit type defined within the library. Why?

Currently using Solc v0.3.2.

Example:

library foo {
    // Should Return a string
    function greet(string storage self) returns (string) {
        return "Hello";
    }
}

contract Greeter {

    using foo for string;
    string name = "lary";

    function say() constant returns (string) {
        return name.greet();
    }
}

Returns:

// Error: Different number of arguments in return statement
// name.greet => type function (string storage pointer) returns ()


texts: Does crypto coins are transferred same as tokens?

texts:
If I understood correctly, when I want send a token using wallet (e.g., ERC20 token), I will:

create a transaction (using send button on my wallet interface) with "to" address containing token contract address (as given in https://etherscan.io/tx/0xa0d13ee62d9013ec0d704abe746e3e0fc1822771b8a039db0926d831971fa157) and the function that I want to invoke (for e.g., transfer(receiver address, #tokens))
the full nodes execute this transaction which invokes the function with given parameters
this completes the transfer of tokens from my wallet address to the receiver wallet address

If this is correct, how does this work for transferring a crypto coins for e.g., Bitcoin or Ether. Thanks for your help to understand these thing better.

Muni


texts: Using parity as Web3 provider running from a Docker container

texts:
I can't seem to be able to create a web3 (http) provider pointing to a parity node, running from a docker container.
I create a repo which should reproduce the problem.

After running docker-compose up the parity starts, but the app fails:

Creating network "dockerweb3_net" with driver "bridge"
Attaching to qa_parity, qa_app
qa_parity | 2018-09-27 07:50:52 UTC Starting Parity-Ethereum/v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0
qa_parity | 2018-09-27 07:50:52 UTC Keys path /root/.local/share/io.parity.ethereum//keys/test
qa_parity | 2018-09-27 07:50:52 UTC DB path /root/.local/share/io.parity.ethereum//chains/test/db/ae90623718e47d66
qa_parity | 2018-09-27 07:50:52 UTC State DB configuration: fast
qa_parity | 2018-09-27 07:50:52 UTC Operating mode: active
qa_parity | 2018-09-27 07:50:52 UTC Configured for Ropsten using Ethash engine

qa_app    | /app/app.js:6
qa_app    |   throw "Can't connect to Ethereum node: qa_parity:8545";

Now if I get a shell to the failing container on the same docker network I can reach parity:

docker run --net dockerweb3_net -it dockerweb3_app /bin/bash

curl --data '{"method":"web3_clientVersion","params":[],"id":1,"jsonrpc":"2.0"}' \
-H "Content-Type: application/json" \
-X POST qa_parity:8545

> {"jsonrpc":"2.0","result":"Parity-Ethereum//v2.0.6-stable-7658d22-20180921/x86_64-linux-gnu/rustc1.29.0","id":1}

Since 8545 is exposed, the parity is also reachable from the host (http://localhost:8545), so the problem must come from when creating the provider.


texts: During a 51% attack, What Can the Attacker Actually Accomplish?

texts:
During an attack on the network, where the attacker has more than 51% of hashing power (or the equivalent of Ether in PoS), what can the attacker do and not do to the chain and the contracts on it?

It is my understanding that they can't fake your signature (as they don't have your private key) and so they can't steal your coins or execute your contracts. So is it only thing they can accomplish limited to a double-spend?


texts: Events not being received in nodejs, using truffle, ganache and metamask

texts:
I'm using web3 1.0, lets say this is my smartcontract:

contract Foo {
    event NewUser(
        address userAddress,
        uint amount
    );

    function addUser() public payable{
        emit NewUser(msg.sender, msg.value);
    }
}

The events get fired in Remix perfectly well.

The problem is when I run a nodejs with express back-end and I try to watch the events with the following piece of code:

contract.events.NewUser({}, function(error, event){
  console.log(event);
})
.on('data', function(event){
  console.log(event); // same results as the optional callback above
})
.on('changed', function(event){
  // remove event from local database
})
.on('error', console.error);

The first log gets called with value null and when the event can't get triggered. Does anyone have any idea what could be the issue?


texts: Deploying a Contract vs. Instantiating a Contract

texts: I apologize for the very basic question but I am a little confused. What is the difference between deploying a contract and instantiating a contract?


texts: What happens if view function calls function that is neither 'view' nor 'pure'?

texts:
currently view is not enforced. Calling a function that is neither 'view' nor 'pure' from within a function that is causes a warning, but compiles.

My question is what is the result from externally calling such a function, and is the result well defined? Does it return the correct result but simply not change state?

for example:

contract Test {
    uint counter = 0;
    function A() public returns (uint256) {
        counter++;
        return counter;
    }

    function B() public view returns (uint256) {
        return A();
    }
}

What happens if I call B() externally? does it for sure return the current counter without consuming gas, just without making a state change to the contract?


texts: Hacking Ethereum implementation for private network

texts:
Note: I do mean hacking, and not cracking. I don’t want to get into people’s Ether, so don’t get over exited with the title.

I am aware of the basic functioning of the Ethereum blockchain and its Smart Contracts technology. However I would like to know if I could just download any Ethereum implementation, create my private network and create my own cryptocurrency, off the main Blockchain. I think I can do it but I read that the purpose is for development, as if I were making “fake” Ether; I actually want to make it for real implementation, but with another name.

Also with that implementation, I would like to be able to programmatically create my own Contracts inside my new Blockchain, so just like Ethereum works right now but with private, independent access and not linked in any way to the current implementation.

Do I have to do how some tutorials point out (https://hackernoon.com/heres-how-i-built-a-private-blockchain-network-and-you-can-too-62ca7db556c0) or is that just for debugging and there is another way? And in case I have to download Geth or any of the sort, which one would be recommended? I already know Python and I would not like to be forced to learn Go if I can use them interchangeably.


texts: What is state-trie pruning and how does it work?

texts: Several sources mention the idea of state-trie pruning.  What is that, and is it currently being implemented on the network?  Is this a manual process or can it be done automatically?  If Ethereum is currently processing 1 GB per month under the current volume, and could grow with greater adoption, can state-trie pruning prevent the size of the ethereum blockchain from becoming unwieldy?  Some sources seem concerned.


texts:
I have a node instance running testrpc on localhost:8545, I'm able to access it when running it from another node instance from the same computer and make web3 calls to it.

const port = (process.env.PORT || 8545);
server.listen(port, function(err, blockchain) {})

I understand with heroku, everything is mapped to port:80

web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// this works fine

web3 = new Web3(new Web3.providers.HttpProvider("http://192.168.1.254:80"));
// this should, but does not work

How do I solve this problem, or what PAAS would help me access a personal testnet running on a remote machine?


texts: Which solidity dev environments support the use of already deployed library contracts?

texts:
So, I'm looking into using libraries in order to prevent re-deployment/re-use of the same code.

I was hoping that I would be able to specify the address of a library in solidity code, using syntax along the lines of

using SomeDeployedLib at 0x1234;

but this doesn't appear to be a possibility yet. Libraries are instead swapped into the generated bytecode by the linker, initially appearing as a placeholder.

So, in which environments can I easily insert the address of an existing library and avoid deploying it again?

Solc command line allows me to do this with something like

solc --optimize --bin MyContract.sol | solc --link --libraries SomeDeployedLib:<address>

so this is one option, but it isn't eactly the most user-friendly of environments to work with.

The Remix IDE supports libraries, but as far as I can tell appears to offer no option to link libraries via an existing address, and instead deploys copies of them every time with your new contract. Not efficient, and not what I'm after.

Parity has a nice UI, but again no option to specify the address of existing libraries, everything is deployed in one go.

Are there any other options?


texts:
Does it cost any gas to cast a bytes32 memory value to uint256? What is the assembly op code for this?

Does it cost more gas to use =, >, <. operators with bytes32 than it does with uint256?

Spreadsheets about gas costs say it cost 3 gas for =, >, < operations, so is that true with all types that support those operators? Or is the gas cost for these operators different depending on the type?

I tested some of these things in remix and got mixed results -- sometimes it cost more gas, sometimes less.

Does it make any sense to cast bytes32 to unint256 for doing an operation like this: require(uint256(myvalue) != 0);

If you know the answers to these, can you please tell me how you know?


texts: Are there any good ethereum developer forums out there?

texts: I'm trying to learn and have been trying to figure out some things that are probably pretty simple and was hoping to find a forum to ask some questions but haven't been able to find one. If anyone knows of a good forum, I would be EXTREMELY grateful! :)


texts: How can I represent decimal values in Solidity?

texts:
I just started writing some solidity and I noticed that there are no decimal values such as double or float.

What do you guys do when you need to return send to a wallet let's say 1.57 ether? Or when you need to calculate 1/2 = 0.5?

I'm very confused - I tried doing something like var a = 0.5; but it gives me an error that says

  Invalid literal value.


texts: Generate Ethereum address from a private key

texts:
My question was first asked on stackoverflow but due lack of privileges I couldn't move it here directly.

I am trying to generate an Ethereum address based on a given private key following this "How are ethereum addresses generated?" and using this Keccak-256 Ethereum implementation. But it show this error:

Warning: openssl_pkey_get_details() expects parameter 1 to be resource, boolean given in /localweb/getethaddress.php on line 15

openssl_pkey_get_private error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
openssl_pkey_get_private error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header
openssl_pkey_get_private error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
openssl_pkey_get_private error:10092010:elliptic curve routines:d2i_ECPrivateKey:EC lib
openssl_pkey_get_private error:100DE08E:elliptic curve routines:OLD_EC_PRIV_DECODE:decode error
openssl_pkey_get_private error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long
openssl_pkey_get_private error:0D068066:asn1 encoding routines:ASN1_CHECK_TLEN:bad object header
openssl_pkey_get_private error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
openssl_pkey_get_private error:0907B00D:PEM

routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib

My implementation:

<?php
    require_once 'keccak256.php';

    // Format the private key as PEM
    $header_private_key = "-----BEGIN EC PRIVATE KEY-----\n";
    $footer_private_key = "\n-----END EC PRIVATE KEY-----";
    //echo hex2bin("1a63b5c735d66d827f40f7d3a257da777cd7997d48bd5d319c36683c0ad3b1de");
    $eth_private_key = $header_private_key . "1a63b5c735d66d827f40f7d3a257da777cd7997d48bd5d319c36683c0ad3b1de" . $footer_private_key;

    // Load private key from a string
    $private_key = openssl_pkey_get_private($eth_private_key);
    var_dump($private_key);
    while ($msg = openssl_error_string())
        echo "openssl_pkey_get_private " . $msg . "
\n";

    // Get the Public key
    $_public_key = openssl_pkey_get_details($private_key)['key'];
    $eth_public_key = openssl_pkey_get_public($_public_key);

    // hash the public key
    $hash_public_key = Keccak256\Keccak256::hash($eth_public_key, 256);;
    $eth_address = '0x' . substr($hash_public_key, -40);

    echo 'Your generated address: ' . $eth_address . '
';
    echo 'Myetherwallet address: 0x47180b59dd8c81f46186900bbd29cbf675b3fbd9';

    /*
        a generated address from Myetherwallet 40: 47180b59dd8c81f46186900bbd29cbf675b3fbd9
        private key 64: 1a63b5c735d66d827f40f7d3a257da777cd7997d48bd5d319c36683c0ad3b1de
    */
?>


texts: How much more it will take for Ethereum wallet to Sync - 2019

texts:
I has been a week when I tried to Sync Ethereum on SSD VPS. Here are the details -

Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             4
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 62
Model name:            Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz
Stepping:              4
CPU MHz:               2200.000
BogoMIPS:              4400.00
Hypervisor vendor:     VMware
Virtualization type:   full
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              25600K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cpuid_fault pti ibrs ibpb stibp fsgsbase tsc_adjust smep arat arch_capabilities

Memory -

              total        used        free      shared  buff/cache   available
Mem:          16040        1174        7237         134        7628       14340
Swap:           974         654         320

Total .ethereum folder size - 140 GB

eth.syncing -

{
  currentBlock: 8907612,
  highestBlock: 8907703,
  knownStates: 75477558,
  pulledStates: 75476506,
  startingBlock: 8904137
}

Last few lines of geth logs -

INFO [11-11|00:14:44.104] Imported new block headers               count=1    elapsed=9.572ms    number=8907938 hash=f24302…d66ebc age=8h19m36s
WARN [11-11|00:14:44.719] Pivot became stale, moving               old=8907809 new=8907874
INFO [11-11|00:14:44.920] Imported new block receipts              count=65   elapsed=199.550ms  number=8907873 hash=ed103f…bf3827 age=8h32m32s size=2.93MiB
INFO [11-11|00:14:47.654] Imported new block headers               count=1    elapsed=9.373ms    number=8907939 hash=a79b7e…6281ef age=8h19m36s
INFO [11-11|00:15:01.027] Imported new block headers               count=1    elapsed=7.654ms    number=8907940 hash=00fa81…6a460e age=8h19m47s
INFO [11-11|00:15:24.354] Imported new block headers               count=1    elapsed=124.532ms  number=8907941 hash=2185b6…89572a age=8h20m7s
INFO [11-11|00:15:27.805] Imported new block headers               count=1    elapsed=19.271ms   number=8907942 hash=758d67…048800 age=8h20m7s
INFO [11-11|00:15:34.629] Imported new block headers               count=1    elapsed=10.442ms   number=8907943 hash=17d7a5…5a7b06 age=8h20m3s

Command used to run geth - geth (without any sync options)

Is something I am Missing here ? Or how much time it should take more ?


texts: Is gas price paid by the transaction sender to the miner, or the miner reward is newly generated?

texts:
A sender of transaction can specify the gas price it is willing to pay for the transaction.

Also, if there are no transactions, miners mine empty blocks and still get rewarded with newly generated ether.

So, if a miner mines a new block with a transaction submitted by some sender, what does the miner get as the reward? Is it newly generated ether, or ether from the senders account?


texts: How would one use stubs for unit testing solidity code?

texts:
Given some contract A, that depends on another contract B, what would be the best way to unit test functions from A without inadvertently testing code from B.

Normally, we could use stubs to return data that is the same every time, but this is cumbersome to do manually with even a moderate amount of code (generate, compile, and deploy the stub).

Is there a framework or library out there yet that has this sort of functionality built in?

Also would be happy to provide a code example if the description above is too abstract; just comment.

I'm using:

mochajs with chai assertions
truffle for a testing framework
ethereumjs-testrpc for test network


texts: Can't create eth accounts on wifi by using ganache-cli@v7.0.0-beta.0

texts:
I was previously getting out of gas error which was resolved by following this issue. Now i installed ganache-cli@v7.0.0-beta.0 . It creates ethereum accounts on localhost if i write the following command;

  ganache-cli

The accounts on local host are as follows. If i use these accounts i didn't get out of gas error.

Ganache CLI v7.0.0-beta.0 (ganache-core: 3.0.0-beta.0)

Available Accounts
==================
(0) 0x83086809b44625886bf2481c5892c1e882f5920c
(1) 0x1870a73b1cb795abb22e19eadfdaf38caef95bf7
(2) 0x2e0cd765b452834b521c93ab50196b024e86d468
(3) 0x9cd2ed6a814c673b523ac66de105f23a9d878538
(4) 0x9450eb5ee9edf0f9d9c5d1703a6c0f9740562762
(5) 0x6ed0d10d0dbc6f56d7df0c94858f80cb358d405e
(6) 0x9126102c8a67f5d6a89701c5ea1bfa764dc4e986
(7) 0xaf7e7565e8c48e12533e68915385f451e1edbaa0
(8) 0x6de462fd093b02d98f07804288e0e877a26655c0
(9) 0x95f999fd73311ed14bfb2318e336d6148d449ceb

Private Keys
==================
(0) 5c4539b82cf105ec2a0f14624ac89f8afef1b57e502ce3536a73b2c195080bb0
(1) b72a92b9bdd61ae616af8c259c53cc8b561371efde43675976edd893298eb5fb
(2) 61ce20461dd2dd6f9c60c075573e66a05228289c73a04fd50579a8567b75ea09
(3) c289c54194c0b7b5fb7352652518c404edfe121fa4be6de09221048f05ba990e
(4) dd53b427292a10ca8d1ab764d64de9d30a3d1f7f1efdb717a287a4100e658f67
(5) f5967273d55c9af91541d3abe8cf5c0ce88b2f5bdfba49e3f86deff9bf85ef85
(6) 8649abe4a2c96e48e766807dd3e5d355151dfbd0b6fdc8cd3d1dcf19ba73dd64
(7) 0a9c79a4e6dc247242ccc8104d47357ad197b5ab1764277964c95625a49a9e4b
(8) 9a8ab7807ca7a34e0eb58f546790ce5b1db8351c5972957eebb542ced3ff7b54
(9) 5acd77d7bd6ddf15db71cdcc7749cfafab1eb179065f5ef5d7416e577cf080cb

HD Wallet
==================
Mnemonic:      install bargain breeze address giggle hurdle save grab network usual obscure wide
Base HD Path:  m/44'/60'/0'/0/{account_index}

Listening on localhost:8545

But now the problem is that i can not find any command for ganache-cli  to create these accounts on the wifi like we create the accounts using ganache application as follows;

Is there any way to link the ganache-cli@v7.0.0-beta.0 to the actual ganache application or is there any command on ganache-cli to create accounts on wifi instead of local host.

My Enviroment:

ganache-cli@v7.0.0-beta.0
npm v6.9.0
Node v10.16.1
ganache application version 2.1.1
Remix appVersion=0.7.7


texts: In examples provided on the Ethereum.org website, there are comments with @param that mention what the specific parameter is used for. Why does it exist?


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

texts:
I'm trying to compile my smart contract with the solidity version 0.5.0. with the code below:

function unbond(address wallet, bytes32 specifier, uint quantity) internal {

    bondage = BondageInterface(coord.getContract("BONDAGE"));
    uint issued = bondage.getDotsIssued(address(this), specifier);

    currentCost = CurrentCostInterface(coord.getContract("CURRENT_COST"));
    uint reserveCost = currentCost._costOfNDots(address(this), specifier, issued + 1 - quantity, quantity - 1);
    FactoryTokenInterface tok = FactoryTokenInterface(curves[specifier]);

    //unbond dots
    bondage.unbond(address(this), specifier, quantity);
    //burn dot backed token
    tok.burnFrom(wallet, quantity);
    //send wallet eth
    wallet.transfer(reserveCost * adapterRate);
}

The transfer function is this: function transfer(address _to, uint256 _value) public returns (bool);

The error I got is this

  TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address".
          wallet.transfer(reserveCost * adapterRate);


texts: Minitng tokens automatically over a regular periods of time

texts:
Is there maybe a way to program a contract to mint a certain amount of tokens over regular periods of time automatically?
Say, I would like a contract to create 1 000 new tokens once a year on Dec., 31st for next 100 years
Many thanks


texts: Ethereum account for HD Wallet key generated with xpub key only using bitcoinj

texts:
Accordingly to the BIP32/BIP44 specification recommendations I generating HD Wallet addresses using bitcoinj library (DeterministicKey instances) with the path like M/44'/60'/0'/0/0 using xpub key only (non-hardened keys can derive child public key without knowing private keys) to use them later for funds receiving operations only. But I was unable to get corresponding Ethereum address using web3j library, as I getting "Private key bytes not available" error (that is of course true).
My code sample for the address generation:
String xpub = "xpub6Df54KC7ti7yvkfDAwsL4QJ1a69GeMM1ChaNqSnGzbpFdxd4PCy1FzdPVftoBYFA4ogmvDUccUbEhGsozE1YkXtQ2YMxAXWKcM8cBxYD6cp";
DeterministicKey extKey = DeterministicKey.deserializeB58(xpub,mainnetParams);
DeterministicKey addrKey = HDKeyDerivation.deriveChildKey(extKey,0);
Credentials credentials = Credentials.create(addrKey.getPrivateKeyAsHex());
System.out.println(credentials.getAddress());

returned keys fully corresponds to the https://iancoleman.io/bip39/ results. The error raises on the addrKey.getPrivateKeyAsHex() call.
Also I tried another way:
System.out.println("address from pub=" + Keys.getAddress(addrKey.getPublicKeyAsHex()));

but in this case the result does not look correct accordingly to https://iancoleman.io/bip39/
Is it possible at all to generate Ethereum address without private key?
Any advice/explanation/link highly appreciated.


texts: What is the best (cheapest) method to store RGB/RGBA pixel data in a smart contract (on ethereum-classic blockchain) with python?

texts:
I would to implement a method to store pixel (RGB/RGBA) in a Smart contract (on ethereum-classic blockchain) from python and with the cheapest method ( when storing and updating pixel data)

I try to find some smart contract example used to store/update picture data ... but can't find a reliable tutorial.

Someone have already done this job ?

PS: What will be the final cost to store a 4K picture (8 847 360 pixels in RGB ) ?


texts: How to subscribe to the txpool / mempool of an external node using go-ethereum client?

texts:
Currently im trying to learn go by rebuild my already existing nodejs application but im facing the issue to not find a resource regarding the usage/ to consume a txpool from a given websocket provider using the go-ethereum go implementation.
So has someone archived this and could give me a hint how to archive it?


texts: Why failed transactions have higher fees?

texts:
Liquidating some tokens on EtherDelta.

Some of the transactions are not successful - they have higher fees than transactions that are successful.

What is the reason for that?


texts:
I have an application which is talking to my Smart Contract through GETH RPC.

In order to do so, I need to run my own node and sync it with mainnet.

The problem start when I need to upgrade my GETH. During the upgrade, I will need to bring down GETH. And when GETH is downed (even for 1 min), it will take hell lots of time to get back in sync.

I don't know how long my GETH can run without an upgrade. Any best practice?


texts: Sending an array of addresses and amount to be paid to a contract

texts: I need to pay 50+ addresses each with different amounts of ether. Right now im doing it by looping through an array on my front end and calling the contract function each time with the address and its corresponding amount which leads to around 50 metamask popups. Is it at all possible to pass an array with the addresses and amounts to the contract and let it all happen in 1 transaction.


texts: Doubt with ethereum-input-data-decoder when decoding a variable uint256

texts:
the input data of the variable uint256 is "22092018" but when using ethereum-input-data-decoder I return "BN: 15118f2". Instead of getting "BN: 15118f2" with the decoder, have the original value of the transaction data entry "22092018".

Code:

const InputDataDecoder = require('ethereum-input-data-decoder');
const decoder = new InputDataDecoder(`${__dirname}/abi.json`);

const data = `0x070ec83b000000000000000000000.......;

const result = decoder.decodeData(data);

console.log(result);


texts:
I would like to develop a program that sends ETH. But I don't want to rely on an exchange such at bittrix or poloniex, as this causes delay (approving time), hassle (confirmation E-Mail), and often even additional costs (withdrawal fee).

Using a wallet, I can avoid these disadvantages. If I understand it correctly, even "online" wallets such as MyEtherWallet do not have these disadvantages.

Is there a (online) wallet offering a (REST) API? Or am I missing something and using a wallet is a stupid idea? How would you do it otherwise?


texts: If a function calls another function in another contract, where is the called function executed?

texts: When a contract calls a function in another contract, is the called function executed in the same EVM as the caller function, in another EVM on the same node or in another random node?


texts: Contract variables and struct variables, The difference?

texts:
I am new to Solidity, I completed a tutorial from medium (3 parts) and I wanted to start my own project.

In this project I want to create a BaseClient contract, but I got confused about how the data is manipulated inside the contract. Considering the ClientBase contract references a bank client in the real world, how can I proceed in order to make a right contract?

I made these samples to illustrate my confusion: where is the client Data supposed to be?

contract ClientBase is Ownership,Account {

    struct ClientBase {
        uint  cin;
        Account[]  accounts;
        address ClientAddress;

    }

    function ClientBase() {

    }
}

or

contract ClientBase is Ownership,Account {

     uint  cin;
     Account[]  accounts;
     address ClientAddress;

     function ClientBase() {

     }
}


texts:
I've been using web3.js to facilitate the creation of a decentralized app.  A major problem I've run into is the lack of support that the web3.js has for supporting a 'struct'.  As a C++ developer, I'm at a bit at a loss of how I should continue..

For example:

    struct Pet {
    address owner;
    uint256 price;
}

    function getAdopters() public view returns (Pet[16]) {
    return pets;
}

Gives me nothing useful.  I would appreciate any guidance on how to solve this problem.

And in app.js

 markAdopted: function(adopters, account) {
var adoptionInstance;

App.contracts.Adoption.deployed().then(function(instance) {
  adoptionInstance = instance;

  return adoptionInstance.getAdopters.call();
}).then(function(adopters) {
  for (i = 0; i < adopters.length; i++) {
    if (adopters[i] !== '0x0000000000000000000000000000000000000000') {
        $('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);
        var loc = document.getElementById('owned-by');
        loc.innerHTML += adopters[i];

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

},

Which throws the following error in the Chrome console:

invalid solidity type!: tuple[16]


texts: is it possible to mine two transaction from same account with different nonce for one block?

texts:
I have a question about double spend attack on ethereum

I heard that double spend attack is prevented by Nonce

and we can send transactions with different nonce it can be validate

but this situation I thought always two transaction is mined by different blocks

I Want to know is possible to contain two transaction(with different none) for one block

and so if possible, how can be validated by miner? (their state is same state)


texts: How to check do I remember password from ethereum wallet at Mist?

texts: I've installed mist and considered that I don't remember the password from wallet that attached to it. Which operation should I launch to start brutforcing the password?


texts: Uniswap transaction fails with TransferHelper: TRANSFER_FROM_FAILED

texts:
I am trying to send a transaction using the Etherscan write contract tool at the following address:
https://kovan.etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#writeContract
The method I wish to use is:
swapExactTokensForToken
And the parameters are:
amountIn: 100000000000000000 (0.1 ETH)
amountOutMin: 1400000000000000000
path: [0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0x25e1474170c4c0aa64fa98123bdc8db49d7802fa]
To: destination address
timestamp: 1602450476

I have tried that, but the transaction fails with an error 'TransferHelper: TRANSFER_FROM_FAILED'.
https://kovan.etherscan.io/tx/0x311805561520f7502befe6e1de6b49e85b9292314ac7a50c0b9fae18c84d8530
I had a look at the code fro TransferHelper.sol but I cannot find the problem.
Can someone explain why this fails?


texts: Verifying if a user actually owns the address

texts:
Web3js frontend with Vue, .NET Core with Nethereum at the back.

  The key target for this functionality is to sign a message at the frontend, send the signature and the address to the backend to validate that he actually owns that address.

  The problem is that I keep ending up with varying address results. This definitely means that some part of my code is wrong. Anyone can spot the problem? <3

For the purpose of development testing, I've added the raw message as part of the API for now.

Frontend

              // Modern dapp browsers...
              if (window.ethereum) {
                  // Propagate Web3
                  window.web3 = new Web3(ethereum);
                  await window.ethereum.enable();
                  window.ethereum.autoRefreshOnNetworkChange = false;

                  // Obtain the user accounts
                  let authMsg = 'This is a Nozomi auth message';
                  let accounts = await window.web3.eth.getAccounts();

                  // Ensure that the user is holding the wallet/s by asking him to unlock his
                  // account with a random message.
                  // https://ethereum.stackexchange.com/questions/48489/how-to-prove-that-a-user-owns-their-public-key-for-free=
                  if (accounts != null && accounts.length > 0) {
                      // https://stackoverflow.com/questions/37576685/using-async-await-with-a-foreach-loop
                      // await Promise.all(accounts.map(async (account) => {
                      // }));

                      let shaMsg = window.web3.utils.sha3(authMsg);
                      let signed = await window.web3.eth.accounts.sign(accounts[0], shaMsg,
                          function (err, sig) {
                              console.dir("Signature: " + sig);
                              this.$buefy.notification.open({
                                  duration: 5000,
                                  message: `There was an error signing the validation request.`,
                                  position: 'is-bottom-right',
                                  type: 'is-danger',
                                  hasIcon: true
                              });
                          });

                      console.dir("User signed data: ");
                      console.dir(signed);

                      // Validate the signed object on server side and provide an auth
                      let result = await axios({
                          method: 'post',
                          headers: { "Content-Type": "application/json"},
                          url: '/api/auth/ethauth',
                          data: {
                              "claimerAddress": accounts[0],
                              "signature": signed.signature,
                              "rawMessage": authMsg
                          }
                      }).then(function (response) {
                          console.log(response);
                      }).catch(function (error) {
                          console.log(error);
                      });

                      console.dir("result: " + result);
                  }
              }

Backend

    public bool ValidateOwner(ValidateOwnerQuery request)
    {
        // Null Checks
        var addrValidator = new AddressUtil();
        if (request == null || string.IsNullOrEmpty(request.RawMessage) || string.IsNullOrEmpty(request.Signature)
            || addrValidator.IsAnEmptyAddress(request.ClaimerAddress)
            || !addrValidator.IsValidEthereumAddressHexFormat(request.ClaimerAddress))
            return false;

        // Check for validity
        var signer = new EthereumMessageSigner();

        var resultantAddr = signer.EncodeUTF8AndEcRecover(request.RawMessage, request.Signature);
        return !addrValidator.IsAnEmptyAddress(resultantAddr) && resultantAddr.Equals(request.ClaimerAddress);
    }


texts: How does ethereum plan to fix crypto kitties issue?

texts:
Transactions are pretty much halted on ethereum due to cryptokittes.

Is there any intermediate solutions?

Recently I managed to send ethereum with only 9 gas price.

Why did the congestion go away? What happened?


texts: What is the proper way to store timestamp in blockchain?

texts:
I am trying to store the timestamp in the blockchain using block.timestamp or now. But that keeps throwing warning as

Use of "block.timestamp": "block.timestamp" can be influenced by
miners to a certain degree. That means that a miner can "choose" the
block.timestamp, to a certain degree, to change the outcome of a
transaction in the mined block.

What is the proper way to store timestamps? Is it good practice?


texts: Why is the Ethereum Virtual Machine designed as a stack based language?

texts:
I heard that Ethereum is about to change into a flavor of Web Assembly (a register-based language, eWASM).
Web Assembly is register-based, which means they are faster.

So why is Ethereum using a stack-based language so far?
What advantage does it have being based on a stack-based language or
are there any other special reasons?


texts: Storing complex data types in Eternal Storage

texts:
I've been reading into strategies for writing upgradeable contracts. A pattern that has come up numerous times is to seperate your contracts business logic from its storage so that upgrades can occur without loss of data (Writing upgradeable contracts in solidity, Upgradeable solidity contract design).

In this article, its said that the eternal storage is a "a simple and extensible way to store any kind of data from simple values, to arrays and complex object type data." However, given the provided storage contract and mock User contract below, I'm having a hard time understanding the best way to move the User storage into the EternalStorage contract given that it contains things like arrays, mappings, structs, etc. Any thoughts/suggestions?

pragma solidity ^0.4.24;

contract UserRegistry {
  struct User {
      address addr;
      uint points;
      address[] friendsList;
      mapping(address => bool) friends;
  }

  mapping(address => User) users;
  mapping(address => mapping(address => uint)) public gamesPlayedTogether; // user address => (friendAddress => games played together)

  function createUser() public {
      User memory user = User(msg.sender, 0, new address[](0));
      users[msg.sender] = user;
  }

  // Various other business logic
}

contract Storage {

  mapping(bytes32 => uint256)    private uIntStorage;
  mapping(bytes32 => string)     private stringStorage;
  mapping(bytes32 => address)    private addressStorage;
  mapping(bytes32 => bytes)      private bytesStorage;
  mapping(bytes32 => bool)       private boolStorage;
  mapping(bytes32 => int256)     private intStorage;

  function getAddress(bytes32 _key) public view returns (address) {
      return addressStorage[_key];
  }

  function getUint(bytes32 _key) public view returns (uint) {
      return uIntStorage[_key];
  }

  function getString(bytes32 _key) public view returns (string) {
      return stringStorage[_key];
  }

  function getBytes(bytes32 _key) public view returns (bytes) {
      return bytesStorage[_key];
  }

  function getBool(bytes32 _key) public view returns (bool) {
      return boolStorage[_key];
  }

  function getInt(bytes32 _key) public view returns (int) {
      return intStorage[_key];
  }

  function setAddress(bytes32 _key, address _value) public {
      addressStorage[_key] = _value;
  }

  function setUint(bytes32 _key, uint _value) public {
      uIntStorage[_key] = _value;
  }

  function setString(bytes32 _key, string _value) public {
      stringStorage[_key] = _value;
  }

  function setBytes(bytes32 _key, bytes _value) public {
      bytesStorage[_key] = _value;
  }

  function setBool(bytes32 _key, bool _value) public {
      boolStorage[_key] = _value;
  }

  function setInt(bytes32 _key, int _value) public {
      intStorage[_key] = _value;
  }
}


texts: I need to know how to set a maximum buy limit per wallet

texts: Yeah so I'm creating a eth token and I need to find a way that buyer have a purchasable maximum limit. Can anybody help me with that ? Can't find answer thanks a lot.


texts:
I'm putting together an ether/erc20 token wallet in a chrome extension but would like to follow best practices with regards to private key security.

I'm using localstorage to handle login and its contents are as follows

Localstorage (no account):
    (empty)

Localstorage (signed out):
    password hash
    encrypted private key

Localstorage( signed in):
    password hash
    decrypted private key
    expiry timestamp for decrypted private key

is there anything intrinsically dangerous about this?
I'm using npm packages web3v1 (beta) and crypto-js


texts: How are Ether balances stored on the Ethereum blockchain

texts:
My understanding of Bitcoin is that balances are not stored but are instead calculated by summing all in and out transactions.

Are Ether balances calculated in the same way or are they stored somewhere on the blockchain?


texts: Question on initial sync and Freezer (SSD and HDD)

texts:
I've kicked off a fresh fast sync of Geth v1.9.2 and  after 3 weeks it's still pulling states (state trie).

As per the documentation you can use the Freezer with a HDD as it references old data so my setup is 1 x SSD (7500 IOPS) for the main chain and 1 x HDD (500 IOPS) for the freezer.

My question is during the initial sync should I move the Freezer data to the SSD and then move it back to the HDD? The reasoning is that syncing is just taking so long compared to v1.8.x which took only 4-5 days to complete with the same hardware and im concerned this may be an issue.

Appreciate any input on this.


texts: Using `recoverPersonalSignature` from `eth-sig-util` to verify message signed with go-ethereum's `crypto` package

texts:
I am using https://godoc.org/github.com/ethereum/go-ethereum/crypto#Sign to sign an arbitrary message and trying to recover the signer address using sigUtil.recoverPersonalSignature(https://www.npmjs.com/package/eth-sig-util#recoverpersonalsignature-msgparams). This doesn't return the correct address.

Example - Signing a message:

msg := "testmsg"
msgHash := crypto.Keccak256Hash([]byte(msg))
sigBytes, err := crypto.Sign(msgHash.Bytes(), privKey)
if err != nil {
        // handle error
}
sig := hexutil.Encode(sigBytes)

Signature recovery using https://www.npmjs.com/package/eth-sig-util#recoverpersonalsignature-msgparams, where ctx.request.body.msg and ctx.request.body.sig are the message and signatures respectively obtained from a http request body:

address = sigUtil.recoverPersonalSignature({data: ctx.request.body.msg, sig: ctx.request.body.sig});

What am I missing here? What might be the correct way to solve this?


texts: Trying to send 295 NGC from my ether wallet to hitbit and getting the following error message

texts: Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 467680000000000 and got: 0.


texts: Geth syncing, how to keep on par with the network in syncronized blocks

texts:
I am trying to get data from the last block via my own local node. I do this by calling the RPC API on my node.
the issue I have is that the node is not fully synchronized and is never fully synchronized, it always lags behind the main net. and my use case is to try and get the latest transactions from the latest block.
I understand that --fast sync, which I am running right now, is not as synchronization-centric as the sync mode. But I want to know if there is a way to fully synchronize with the network.
that is probably possible since I can get the latest block data from an RPC provider on the internet but that happens to be limited in the request number.


texts: How can I get a mnemonic phrase from a private key?

texts: I have a private key for my wallet and also a keystore for it. I want to use it in MEWConnect. Is there a way to get a mnemonic phrase from a private key?


texts: Why doesn't Solidity throw an error for overflows?

texts:
It seems like there are going to be a lot of people that forget to check for integer overflows in Solidity.

I am wondering if there is a reason why Solidity doesn't throw errors for integer overflows like Python or most other programming languages?


texts: How do I make it possible so that my contract will accept USDC tokens

texts: this will be done as a fee for entry to a raffle. Is this done through interfacing the USDC contract or by interfacing the ERC20 contract?


texts: How to integrate simple wallet on website

texts:
I couldn't find the answer to my question anywhere else so I'll explain it here hoping someone will answer.

I would need to integrate a pretty simple, but of course secure, wallet on my website. That wallet is not supposed to be used as a main wallet by people nor for higher sums.
Basically, I just need to check if someone has a sufficient balance to bid on something, and if that's the fact, be able to bid. As soon as the bid runs out, it would be great to also be able to take that eth automatically (therefore, being able to freezethe ETH used to bid would be nice).

Does someone know if there is any API/Service that would be able to provide this, or how I can find a skillful developer for this (and about what time effort we're probably talking here)?


texts: Hyperledger Vs Ethereum for supply chain management?

texts: Which is the best blockchain development platform (Hyperledger/Ethereum) for supply chain management?


texts: How to set solidity compiler to Mist wallet

texts:
I'm trying to create contract in Mist wallet, but it says:

Source file requires different compiler version (current compiler is 0.4.24

What should I do to write on 0.4.25 in Mist wallet?


texts: Empty/null address handling in truffle pet shop tutorial

texts:
I am trying out the Truffle Pet Shop tutorial and it seems to be working all well except for a small issue.

My solidity function getAdopters() returns an address[16]

function getAdopters() public view returns (address[16]) {
  return adopters;
}

and on my client side I use the following function (as per the tutorial)

App.contracts.Adoption.deployed().then(function(instance) {
  adoptionInstance = instance;
  return adoptionInstance.getAdopters.call();
}).then(function(adopters) {
  for(i = 0; i < adopters.length; i++) {
    if(adopters[i] !== '0x0000000000000000000000000000000000000000') {
      $('.panel-pet').eq(i).find('button').text('Success').attr('disabled', true);
    }
  }

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

My issue lies on what's returned by the getAdopters call.
The empty address is not '0x0000000000000000000000000000000000000000' but 0x0 for the first address and 0x for the rest of them.

Of course I change the loop to check for either of them to see if the address is empty.

But why does it not return a proper standardised empty address for all of them ? Is this the correct way to check for empty addresses ?


texts: When the ETH node receive a new block ,which will be verified?

texts: I know that when a node receives a transaction, it can verify the RLP format, transaction signature, gas and account nonce value, but I don't know when the node receives a new block, whether will it verify the validity of every transaction in the block?If the node just verify block nonce  (hash difficulty) ,Can the mining node forge a transaction in the new block, although it is as difficult as it is to find a real block?


texts: Importing a ethereum brain wallet into the Mist wallet

texts: After creating a ethereum brain wallet, how can you import this into the MIST wallet?


texts:
I had worked with geth, but getting lots of errors like last 1000+ blocks not syncing, so I have decided to switch to parity.

I was following One-line Binary Installer, but was hit by:

  /bin/sh: 1: Syntax error: "(" unexpected

and if I use:

bash https://raw.githubusercontent.com/ethcore/scripts/master/install-deps.sh -L

I get:

  /bin/sh: 1: cannot open https://raw.githubusercontent.com/ethcore/scripts/master/install-deps.sh:
  No such file

Secondly , I tried  using docker,but the line cargo run --release is giving:

  failed to parse manifest at /home/pr.singh/parity/Cargo.toml
  Caused by:   could not parse input as TOML Cargo.toml:51:9 expected a
  key but found an empty string Cargo.toml:51:9-51:10 expected ., but
  found '

What steps do I need to follow. I have worked with geth, and I have downloaded almost all blockchain data (around 1000 blocks left). How can I switch to parity?


texts: Connecting an Ethereum account with a Twitter user

texts:
Is this a sensible flow for verifying that an Ethereum account is controlled by the same person as a Twitter account?

User logs in to my site with Twitter
I get an auth token back from the Twitter API
I perform a web3js transaction on the client in which I store the hashed auth token in the smart contract in a mapping of addresses to hashed tokens
After the transaction has finished, I send the auth token and contract address to my backend API. The backend queries the blockchain and verifies that the mapping in the smart contract contains the right hashed token for the right address.
Now I know the two are connected, I store the Twitter username and Ethereum address off-chain in a database.


texts: Compare byte32 Keccak256 to the same Keccak256 stored in a byte32 array

texts:
I want my function to be able to accept an array of Hashed secrets as a parameter and since solidity doesn't allow for strings, I had to use a byte32[].

The string parameter is an intake for the user's secret which I am hashing with Keccak256 which should convert it to a byte32 value.

Since (or so I think) the hashed secret string is a byte32 and so is the hashed secret stored in the first element of the byte32 array, the assertion should evaluate to true when comparing them

Test:

it("Checking secrets", function() {
    return myContract.deployed().then(function(instance){
      contract = instance;
      return contract.test.call("hello", ["1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8"])
      .then(function(testVals){
        assert.equal(testVals[0].valueOf(), testVals[1][0].valueOf())
      })
  });
});

Function:

function test(string val1, bytes32[] val2) public returns(bytes32, bytes32[]){
        return(keccak256(val1), val2);
    }

Result:

AssertionError: expected '0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8' to equal '0x3163386166663935303638356332656434626333313734663334373232383762'


texts: How can I count ETH active Wallets and how can I count ETH deployed Smart Contracts?

texts:
I am doing a research and I would need to know the following info:

Total number of Wallet Addresses
Total number of "Active" Wallet Addresses
Total number of Deployed Smart Contracts (is it a subset of the above?)

So far I have I have:

Nothing for point #1 (I have a top account counts (Etherscan - Accounts) which tells me

  A total of more than > 1999999 accounts found (100,384,776.592 Ether)

and If I click on the link it re-addresses me to Ethereum Unique addresses growth rate charts chart Etherscan - Unique Adresses which shows

  37,503,645 unique addresses

does it means that there are 37.5 M addresses? are these inclusive of Smart Contracts?

Point # 2: I have found this site bitinfocharts.com and I was wondering how the "active wallet is "defined"... I am guessing it counts the ethereum addresses that have a daily transaction... no? ideas?
Point # 3: The only source I have is Etherscan... I am confuse if the Unique addresses includes Smart Contracts and how to estimate/calculate the total number of Smart Contracts (I can only find the "verified" ones Etherscan - Verified Contracts

I have actually found this post ethereum.stackexchange.com/questions/8648/… but the suggested links for Accounts and Smart Contracts provide e with the same result... ideas?

Any help/resource would be much appreciated.


texts: Truffle: Error: The contract code couldn't be stored, please check your gas amount

texts:
I am unsure why I keep getting this error:

Using network 'development'.

Running migration: 2_deploy_contracts.js
  Deploying Token...
  ... 0x02f042faec7c36c74bb0df346ccda5339ea653eb55c79996a3af81a9be055992
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.

I am simply trying to deploy the standard ERC20 example from Consensys.

From what I understand this error occurs when a function is abstract, but I can't seem to find any of those, unless I get my definition of abstract wrong.

The ProToken contract inherits from Token one, which just follows ERC20 standards, what could be wrong ?

contract ProToken is Token {

    mapping (address => uint256) balances;
    mapping (address => mapping (address => uint256)) allowed;
    uint256 constant MAX_UINT256 = 2**256 - 1;

    function transfer(address _to, uint256 _value) returns (bool success) {
        require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]);
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        }
        Transfer(_from, _to, _value);
        return true;
    }

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

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

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

contract Token {
    /// total amount of tokens
    uint256 public totalSupply;

    /// @param _owner The address from which the balance will be retrieved
    /// @return The balance
    function balanceOf(address _owner) public constant returns (uint256 balance);

    /// @notice send `_value` token to `_to` from `msg.sender`
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transfer(address _to, uint256 _value) returns (bool success);

    /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
    /// @param _from The address of the sender
    /// @param _to The address of the recipient
    /// @param _value The amount of token to be transferred
    /// @return Whether the transfer was successful or not
    function transferFrom(address _from, address _to, uint256 _value) returns (bool success);

    /// @notice `msg.sender` approves `_spender` to spend `_value` tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @param _value The amount of tokens to be approved for transfer
    /// @return Whether the approval was successful or not
    function approve(address _spender, uint256 _value) returns (bool success);

    /// @param _owner The address of the account owning tokens
    /// @param _spender The address of the account able to transfer the tokens
    /// @return Amount of remaining tokens allowed to spent
    function allowance(address _owner, address _spender) constant returns (uint256 remaining);

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


texts:
I send ETHER from Livecoin ,Etherscan confirm transaction but Ether did reach Myetherwallet.

Livecoin and Etherscan shows that transaction successful.
What should Ido for recover my ether?


texts: How to generate an Ethereum "brain wallet" in Javascript?

texts: Namely, enter string -> get private key?


texts: Create Mnemonic using react-native and BIP39 is not working

texts: I tried to generate mnemonic for my react native application using Both BIP39 and react-native-Bip39 and it is working fine in the simulator but as soon as I try to generate a mnemonic on a physical device it is failing with a console error that say that it is only supported on browser such as chrome or Firefox, is there another library, a fix or another way to make this library run on react native?


texts: In Geth\crypto I found the default implementation of ECC curve (secp256k1). I would like to change it to secp256r1 curve for my private network. In normal circumstances, all I need to change is the curve parameters, which I found it in Geth\crypto\secp256k1\curve.go. I also found native implementation at Geth\crypto\secp256k1\libsecp256k1 so I am not confident by changing curve parameters in curve.go is suffice. Could someone please point me to the right direction


texts: Cannot connect to Parity from browser UI

texts:
I am not able to connect to Parity via the browser UI. I have tried multiple times with different tokens generated by running the command parity signer new-token on the node where parity is running. But the response in the browser is always the same:

Unable to make a connection to the Parity Secure API. To update your secure token or to generate a new one, run parity signer new-token and supply the token below

On the node console, I see the following message, every time with different numbers on the first line. The first number is always less than the second one:

Received old authentication request. (1486765366 vs 1486765433)
Unauthorized connection to Signer API blocked.

Parity version: Parity/v1.6.0-nightly-afa1edb-20170125/x86_64-linux-gnu/rustc1.14.0

Any help is greatly appreciated.


texts: eth.getBalance(, ) returns "Error: missing trie node"

texts: I have used --gcmode=archive to download all the state tries and eth.syncing returns false meaning my node is in sync. When I execute eth.getBalance for blocks closer to the current block I obtain the correct value but for older blocks I get "Error: missing trie node". Is there any other way of obtaining balance of an account in all the blocks from the genesis block?


texts:
I am working on rent agreement and I have a situation here

One landlord can have multiple properties
every property have different details (property details, values)

now I want to link property details to property id also want to link  id's to landlord address.


texts: myContractInstance.balanceOf(gnoAccount) is not working in node js web3

texts:
I'm trying to deploy a smart contract through NodeJS using web3, but the myContractInstance.balanceOf(gnoAccount) function is not working
 Here is my code:

var Web3 = require('web3');
// Connect to a geth server over JSON-RPC

var web3 = new Web3();

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

web3.eth.getAccounts()
.then(console.log);

web3.eth.getBlock(
    "pending",
function (error, block) {
    if (error) {
        console.error(error);
    } else {
        console.log(block.transactions.length);
    }
})

web3.eth.getCoinbase(
    function(error, result){
    if (error) {
        console.error(error);
    } else {
        console.log(result);
    }
 })
var abi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"standard","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"decimalUnits","type":"uint8"},{"name":"tokenSymbol","type":"string"}],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"}];

//console.log(abi);

var myContractInstance = new web3.eth.Contract(abi, contractAddress);
var gnoAccount = "0x4*****************************************45"; // coinsbase address
var amount = 0.1; /* tokens you want to send */
var destination = "0x5*****************************************f6"; //destination address
var actbal = myContractInstance.balanceOf(gnoAccount);
console.log(actbal);

Please help anyone to solve this error.


texts: (Re)create account from a keystore (?) file

texts:
Noob. Sorry :-(

I have a keystore file that I'm confident represents an account I'd like to retain/use. It's unclear how I can recreate (or reinstantiate) this account within a fresh Ethereum (node) deployment.

I'd like to reuse this because I used it with the Rinkeby faucet to request some Ether.

I thought I should be able to use 'geth account import' but:

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

The account begins : 3df6... and I have the password ;-)

The keystore file is JSON:

{
  "address": "3df6...",
  "crypto": {
    "cipher": "aes-128-ctr",
    "ciphertext": "...",
    "cipherparams": {
      "iv": "..."
    },
    "kdf": "scrypt",
    "kdfparams": {
      "dklen": 32,
      "n": 262144,
      "p": 1,
      "r": 8,
      "salt": "..."
    },
    "mac": "..."
  },
  "id": "..",
  "version": 3
}

I would appreciate guidance on how I may recreate it. I assume success would be, from within the console being able to see this account enumerate by personal.

Or am I missing something(s)?

OK, progress:

docker run \
--rm \
--interactive \
--net=host \
--tty \
--volume=$PWD/data-dir:/root \
--volume=$PWD/backups/.rinkeby/keystore:/keystore \
ethereum/client-go \
  --datadir=/root/.rinkeby \
  --keystore=/keystore \
  account list
INFO [05-22|21:38:35] Maximum peer count                       ETH=25 LES=0 total=25
Account #0: {3df6...} keystore:///keystore/TC--2018-00-00T00-00-00.000000000Z--3df6...

That's the account and it appears to be legitimate so, my new question is how do I import this so that I may use it when attaching this console to my node?


texts: As we know, in every function call we can add {from: "address, value:5, gass: 420000}. I wondered who provides these capabilities? Is it Solidity, VM or web3.


texts:
I use web3 to get a transaction (Ropsten testnet):

web3.eth.getTransaction("0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b")

I get the following fields: blockHash, blockNumber, from, gas, gasPrice, hash, input

There are missing fields if I compare to etherscan:
    https://ropsten.etherscan.io/tx/0xea73781d8cb2dcd73ab5c7e863a2c3e2e94f99b92e4e2b9f9316be38f151ef3b

How do I access to the other fields: "Gas Used By Txn", "Gas Price" (at the tx time), "Nonce" and, more specifically, the field "To" ?


texts:
I was referring to multisig smart contract posted at below URL:
https://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol

However, I am getting confused with some of the parameters to be passed in the contract.

For Example, I am not getting properly what needs to be passed in place of bytes32 _operation  in the function hasConfirmed.

Could someone help me out of it.? You can suggest me sample data to be passed for the parameters in each function. Any video link where anyone has worked with this contract can be helpful too(where they have worked with parameters too).

NOTE: I am using online solidity compiler(Remix - Solidity IDE)


texts: Is it possible to use a solidity library inside another?

texts:
I am trying to use a solidity library inside another. The minimal code would be something like this:

The deepest library: SLib.sol

pragma solidity ^0.4.18;

library SLib {
  struct SCtx {
    uint a;
  }

  function init(SCtx storage self, uint _a) public
  {
    self.a = _a;
  }

  function getA(SCtx storage self) public view returns (uint)
  {
    return self.a;
  }
}

Then TLib.sol uses the previous one:

pragma solidity ^0.4.18;

import "./SLib.sol";

library TLib {
  using SLib for SLib.SCtx;

  struct TCtx {
    SLib.SCtx s;
  }

  function init(TCtx storage self, uint _a) public
  {
    self.s.init(_a);
  }

  function getA(TCtx storage self) public view returns (uint) {
    return self.s.getA();
  }
}

Then some contract to use them TInterface.sol:

pragma solidity ^0.4.18;

import "./TLib.sol";

contract TInterface {
  using TLib for TLib.TCtx;
  TLib.TCtx t;

  function TInterface(uint _a) public {
    t.init(_a);
  }

  function getA() public view returns (uint) {
    return t.getA();
  }
}

In Truffle I can't even link these guys. In 2_deploy_libraries.js:

var TLib = artifacts.require("./TLib.sol");
var SLib = artifacts.require("./SLib.sol");
var TInterface = artifacts.require("./TInterface.sol");

module.exports = function(deployer) {
  deployer.deploy(SLib);
  deployer.deploy(TLib);
  deployer.link(SLib, TLib);
  deployer.link(TLib, TInterface);
};

Returns:

  Deploying SLib...
  ... 0xe0317d15a3eac...
  SLib: 0x8e4c131b37383e431b9cd0635d3cf9f3f628edae
  Deploying TLib...
  Linking SLib to TLib
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: TLib contains unresolved libraries. You must deploy and link the following libraries before you can deploy a new version of TLib: SLib
    at /usr/l...:/~/truffle-contract/contract.js:371:1
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Is doing this even allowed? And if yes, what is the right way to link and use it?


texts: What do the 3 different peer numbers represent in Parity?

texts: My peer numbers in Parity are quite consistently at 0/25/25. What does each one of those numbers represent?


texts: Logs from Web3.js application and Smart Contract

texts:
I would like to know where are the logs printed when I use "console.log(x)" in a web3 app. I am using Geth and Truffle to deploy smart contracts.

For example, from pet-shop tutorial, if I wanna see a log with the petId when a pet is adopted, where is it printed?


texts:
when i want open PRIVET NETWORK on METAMASK it wont open.
i try it in two PC on same local ethernet


texts:
Is there a way to read a deployed contract's bytecode from leveldb? From what I understand, within each account in the state tree, there exists the nonce, the balance, the codehash, and the storage root. Does the codehash point to the location in leveldb where the contract bytecode is stored?

And is it correct to say that contract bytecode stored in leveldb is only the body portion of the contract and not the init/constructor bytecode?


texts: eth mainnet syncing took 2 weeks or more and still syncing

texts:
I have a node created via AWS but it has been trying to sync for 2 weeks
t2.xlarge running on efs, efs is running on max io and i am using the geth client v.1.9.13
the node state is as below
eth.syncing
{
currentBlock: 10676059,
highestBlock: 10676172,
knownStates: 445749597,
pulledStates: 445749204,
startingBlock: 10622772
}

anyway to speed up the syncing? i tried to manually add peers as i read that it would help to speedup.
but no matter how many i add the admin.peers.length remains at 16.
my config has set to MaxPeers=50 and set as  fastsync.


texts: How to listen to events generated by an existing contract in web3 1.x.x?

texts:
Currently I'm unable to find a working solution. Let's say I have the following smartcontract:

contract Manufacturer {
    event LogNewOrder(string order);

    string[] public orders;

    function addOrder(string newOrder) public {
        orders.push(newOrder);
        emit LogNewOrder(newOrder);

        return;
    }
}

If a third party calls the method addOrder(newOrder), the manufacturer should be informed about, because he must perform things. What is the best method with web3 to listen to events? If I do something like this:

instance.events.allEvents({ fromBlock: 0 })
.on('data', function(event){
    console.log(event);
})
.on('changed', function(event){
    console.log(event);
})
.on('error', console.error);

then nothing happens.


texts:
I need to upload 8Tb data from Ubuntu server to IPFS.

Does it possible, I mean does IPFS has limits?
Does this data will be online if my server down?
Who really host files?
Does owners of https://gateway.ipfs.io/ipfs/.... reject public access to file?


texts:
I am learning Serpent with pyethereum in Spyder (so I have a running log of what I have tried and learned), but I am stuck in translating standard features of Serpent (such as pretty_compile) from python.

For example, how do I pretty_compile the standard multiply by 2 contract?

import serpent
from ethereum import tester, utils, abi

# Initialize tester blockchain
s = tester.state()

serpent_code = '''
def double(x):
    return(x*2)
'''

c = s.abi_contract(serpent_code) # Usual compiling

Is there a pretty_compile argument of abi_contract, or perhaps of print? I would very much like to see the opcodes for more complicated contracts within pyethereum.


texts: Truffle migrate: store deployed contract address in variable

texts:
How can I store the address of a deployed contract into a variable of another contract, e.g. using a placeholder?

contract One{
   function One(){
   }
}

contract Two{
   address oneAdd = "Put Contract One address here automatically?!";
   function Two(){
   }
}

Is that possible by editing the migration file of truffle?


texts:
I am trying to create a smart contract for public tenders. I have a condition: bidders cannot see others' offers before tender ends. The contract accepts bids via a function.
I have two major problems: first hiding the argument of the function because it shows the bidder's offer. And I want to store it privately in Ethereum.
Do I have a chance to implement such a protocol in Ethereum? If not, what is your opinion about minimizing non-solidity part of the project.


texts: Can a contract execute multiple signed transactions as one?

texts:
Say multiple signed transactions have been created and signed by multiple different accounts with web3.py or similar, is there any way to get them executed as a single transaction in Ethereum so they all go together or none of them? Ideally something like they're all passed as parameters to a contract method, which then executes them all together, and keeping the signers so that they can transfer their own tokens etc.
How do they do it with flash loans?


texts: Parity RPC Port Redirecting to UI Interface

texts:
It seems that whenever I run Parity and I bring up :8545 in a web browser (locally or on the public net), it redirects to :8180 OR simply gives me an error.  In this case, I get the Parity UI styling saying:

404 Not Found
Your homepage is not available when Trusted Signer is disabled.

You can still access dapps by writing a correct address, though. Re-enable Signer to get your homepage back.

What I am expecting is the "normal" weird error I would get if I ran geth and looked at port 8545 in a browser.  Text gobbledegook that I could re-create and post if you need the details.

But what I really want to be able to do is execute commands via the RPC interface across the public internet.  Is there another, better way that I should be going about this?


texts: How to 'personal_sign' with Mist browser

texts:
I can use

web3.currentProvider.sendAsync({
  method: 'personal_sign',
  params: [msg, address],
  from: address,
}, (err, res) => {});

and Metamask will prompt the user to sign the given message.

In Mist, I get and error (TypeError: Cannot read property 'id' of undefined) thrown from here:

EthereumProvider._addResponseCallback (<anonymous>:1097:42)
at EthereumProvider.send (<anonymous>:1146:14)

Is this simply not possible with the Provider from Mist?
Or am I missing something?


texts: How to check if the call to another contract returned successfully?

texts:
I want to call contract A in contract B, like this:

contract  A{
    uint 256 a;
    function set(uint _a){
           require(a > 100);
           a = _a;

    }

}

contract B{
   function callA(){
   A a = A(the_addr_of_A);
   a.set(100);
   }
}

But how can I ensure a.set(100); is done correctly?

Since I have a require statement require(a > 100) in contract A, a.set(100) will not work, can contract B notice that?


texts: Multiple transactions with same nonce, pending ones makes me crazy rest is ok, but why?

texts: I am playing with smart contracts in code, sending/receiving transactions to/from it. Some transactions with lower gasPrice are stuck in a pending state. However, having same nonce with a higher gasPrice passed. Pending ones still pending and seems to be pending forever. How can I clear those or when will they discard, is there an amount of time to wait them to be discarded?


texts:
How would you map a changing variable from web3 to react.js component?
Example:

class App extends Component {
  constructor(props){
    super(props);
    this.state = {
      blockNumber: web3.eth.blockNumber,
    }
  }

  render() {
    return(
      {this.state.blockNumber}
    )
  }
}

What would be the best practice without using setTimeout/requestAnimationFrame /setInterval


texts: How to tell where in blockchain you currently are while syncing?

texts:
I am using geth fast sync 1024 and I was wondering how you tell which block you are currently on or what the numbers mean as it continues to sync.

Is 'processed=6650309' the block chain I am currently on?

That doesn't make a lot of sense to me if that is the block since that would be a block in excess of the current last block chain which sits at around 4056450 at the time of writing this question.

Also, I occasionally see it 'hang up' for minutes at a time and then it seems to push through and then start working again.

I do have a SSD and an OK processor, it's an older gen core I5 3570K.  I am just wondering if the rare excessive hang ups mean it is taking longer to process that specific block chain.

It seems like most new state entries process within milliseconds.

Does the processing of blocks in the chain occur sequentially in fast sync mode?

Cheers,
John


texts: Ethereum JavaScript console account authentication error

texts:
I am trying to run my first contract, but I am getting this error when using my dev testnet account.

Error: authentication needed: password or unlock undefined

I am using geth to run JS console using this command

geth attach

What should I do to use authenticate my account?

Thanks in advance!


texts: What are the ways to call a smart contract function during development?

texts:
What are the ways to call a smart contract function during development using Truffle simulated VM with a GUI interface (like Remix or EtherScan offer)?

I know I could use CLI options like Truffle and Open Zeppelin SDK. I also could develop unit tests, but I think it is productive to use a GUI to execute some tests during development.

Obs.: I do not have a GUI in my application.

Thank you


texts: My Windows drive is almost full. As I actually have two drives, I want to move the blockchain from the default location to the second drive. How can I do it?


texts: safe way to allow users to deposit ETH to an address

texts:
I'm new to this and I want to simply allow users to deposit ETH to an address (not a contract).

I was wondering what is a safe way to do this? for example using the code below on client side i can simply create transaction and open up metamask for user to confirm it

        web3.eth.sendTransaction({
        to: add,
        from: web3.eth.accounts[0],
        value: web3.toWei(depositInput.value, "ether")
    }, (err, res) => {
        if (err != null) {
            console.error(err);
        } else {
            console.log("success, ", res);
        }
    });

and then send the depositInput.value to server side and add it to user's account.

but i don't think this would b a safe way to do this (safe in terms of users being able to modify the code)

I would appreciate some help :)


texts: Contract throwing VM exception: Invalid Opcode

texts:
pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

    contract DieselPrice is usingOraclize {
        event one(string description);
        event newDieselPrice(string price);

        function DieselPrice() {
            update(); // first check at contract creation
        }

        function __callback(bytes32 myid, string result) {
            require(msg.sender != oraclize_cbAddress()); // Note: better approach
            newDieselPrice(result);
            //DieselPriceUSD = parseInt(result, 2); // let's save it as $ cents
            // do something with the USD Diesel price
        }

        function update() payable {
            one("Oraclize query was sent, standing by for the answer..");
            oraclize_query("URL", "xml(https://www.fueleconomy.gov/ws/rest/fuelprices).fuelPrices.diesel");
        }

    }


texts:
Is it possible to square root 50 or should I use 7.071067.

I'm very new in programming and I also understand that it's possible in all other languages, but I'm not able to see where the limitations are.


texts: How to separate functions in evm bytecode?

texts:
I want to build the control-flow-graph (CFG) from the bytecode of a smart-contract (assuming it is obtained by compiling a Solidity source file). This CFG should also distinguish the different methods of the smart contract.

Is there a way to do so?


texts: Difference between unoptimized and optimized solidity code

texts:
I am trying to find a source on what the difference is between optimized and unoptimized code. My main question is what the unoptimized compiler does, especially in the sense of calling the SSTORE opcode.

Let's say I have this:

contract A{
    uint8 mem1;
    uint8 mem2;

    function store(uint8 store1, uint8 store2){
        mem1=store1;
        mem2=store2;
    }
}

When I would compile this in a "dumb" way I would call SSTORE twice to store both variables. However, to optimize this I would allocate the first 8 bits of an uint256 (SSTORE always stores uint256's) to mem1 and the second 8 bits to mem2. Like this, I only have to call SSTORE once per transaction. However, this might result in a slight overhead in other code the contract may have since we need to extract the right bits. SSTORE takes 20k gas when saving a non-zero value, so optimizing this code saves 20k gas.

Does the unoptimized compiler, when compiling above code, call SSTORE twice or once? I know I can check this myself by compiling and reading the OPCODES, but I'd like to find a source on what both compilers should do.


texts: Would it be better to use `throw` instead of `return false`?

texts:
My goal is to carry out some simple function but the user should be aware if the call fails. An example simple function could be seen here.

Instead of return false, I want to use throw. Would their effect be the same on the function's flow? And which one uses less gas?

Overall, which one might be more motivated to use?