texts: Truffle test: Problem with understanding the test

texts:
I am trying to understand the test provided at:
Tutorial
("Test balance after deposit", function() {
        return SimpleBank.deployed().then(function(instance) {
            sb = instance;
            return sb.deposit({ from: accounts[0], value: web3.utils.toWei('10', 'ether') });
        })

The smart contract code is given below:
contract SimpleBank{
   uint public transactions;
   mapping (address=>uint) balances;

   function deposit() public payable{
      balances [msg.sender] +=msg.value;
      transactions++;
   }
}

The test invokes :
sb.deposit({ from: account[0], value:  web3.utils.toWei('10', 'ether') });

To which account the ‘10’ ether is going from account[0]? What is the purpose of 'transactions' state variable?


texts: Metamask issue with payable transactions using Truffle and Web3

texts:
Hope everyone's doing well.

For the past few days I've been having issues with a payable function which I know is definitely working. How do I know it's working? Ether gets sent successfully on Remix.

The following code is from a section of my contract:

function payRent()
public
payable
onlyTenant
inState(State.Started)
equalValue   {
        landlord.transfer(msg.value);
        paidrents.push(PaidRent({
        id : paidrents.length + 1,
        value : msg.value
        }));   }

Assume that landlord is an address which was previously stated within the contract.

I have also included the fallback payable function:

  //fallback payable
  function() public payable{}

The above functions work perfectly with Remix.
I have created a React Application which would call this function and use the Metamask as the web3 provider.
Within the function I use the return section as so:

return rentalAgreementInstance.payRent.sendTransaction({from: accounts[0], value: this.state.web3.toWei(this.state.rent, "ether"), gas:30000})

Instance has been properly initialized.

This is set to activate on a button click.

Everytime the button is clicked, Metamask provides me with a popup to confirm the transaction with the proper value defined.
Now the issue arises once confirm is clicked.

The transaction gets completed, but no ether is deducted from the sender account, and no ether is received by the receiving account.

I assume I may be calling it incorrectly within the web3 return function of react.

If any more relevant details are required please let me know.

Some help would really be appreciated. Thank you all!


texts: How to do batch transaction in Ethereum using web3j

texts: I want to do batch transaction using the web3j,So how can I do it? Is there any way or feature web3J provides


texts:
The main purpose of this code is to add an array of users in mapping. there are certain users who play a video game and are on a certain level now level will be considered as a mapping index and on these level, there will be an array of users. Now the main purpose of taking an array of users is because there can be multiple users on the same level. I just started learning solidity so there might be some logical mistakes in the code can anyone help me and explain to me with this code?

pragma solidity ^0.4.24;

 contract game
 {

     struct users
     {
         string name;
         uint level;
         uint score;
     }

     mapping(uint => users[]) mulusers;

     function addusers (string _name, uint _level, uint _score) public {

         users memory use= users(_name,_level,_score);
     }

     function getusers (uint _level) public view returns (string)
     {
        uint index= mulusers[_level].length;
         for(uint i=0; i<index; i++)
         {
           return mulusers[_level].users[i].name;    //remix is showing an error
         }
     }
 }


texts: If i do Ethereum Hard Fork to build DApp - Does it need to be on Ethereum or could be a separate blockchain system? If we build a separate blockchain system, what is the advantage of hard-forking from ethereum?


texts: How to create a time window in solidity .. so that you will allow a function call for example with in 2 hours .. I know timers do not exist in solidity so how do I only allow a function to be called within a certain period of time


texts:
I want to become a smart contract auditor. I will report all the vulnerabilities which I have explored while auditing smart contracts.

Is there any platform available to learn how to audit smart contracts?

Is there any platform which will allow me to audit smart contracts developed by others?

Is there any platform where senior auditor share their experience and publish the vulnerabilities that they have found while auditing smart contracts?


texts: Is there any way to subscribe to contract event without creating filter?

texts:
I developed contract with couple of events. It was tested using local geth node and working as expected. Now I want to deploy it and decided to use infura.io as public node provider.

Here I faced show stopping issue: infura provides only limited set or RPC calls and newFilter isn't included in this list. I see that while subscribing to events on my contract first web3 sends eth_newFilter call that failed.

I suspect that I can safely remove filter statement from my contract definition:

 this.contract.logWinner({fromBlock:'latest'}).watch(this.onWinner.bind(this));

and replace it with

this.contract.logWinner({}).watch(this.onWinner.bind(this));

but newFilter function still calling and crashed app.

My question: could I avoid somehow calling for eth.newfilter?


texts: Getting Error: registerDeed is not a function

texts:
I am receiving the error: deedrepository.registerDeed()

  TypeError: 'registerDeed' is not a function
      at :1:1

when trying to call the function registerDeed from and geth --dev console terminal window.

This is the contract I deployed https://github.com/conwise18/MasteringEthereum/blob/develop/code/auction_dapp/backend/contracts/DeedRepository.sol

by using web3.deploy.

I have also created the contract in remix and it works fine,

any help as to why the function is unable to be called in my console ?

using: deedrepository.registerDeed()

I have tried calling the function with the parameters as well and I'm receiving the same error.

thanks in advance !


texts: Does EIP 134 allow a variants on PoS where everything is at stake?

texts:
EIP 134 allows a transaction to specify which chain it is occur on.  In its original inception, this would be accomplished by specifying a recent block of the desired chain and a number 0-255 that specifies how far after this block the transaction can be used.

It seems this could be used to improve this double-or-nothing version of a sstaking scheme: A staker publishing a block, to prove his stake, could be required to include a transaction that drains his stake (acceptance of his block will later return 2x his stake).  This transaction can be used by other stakers to claim staked funds (at 1x the rate).

The problem with this that EIP 134 fixes is that, without EIP 134, a staker's transaction to drain his stake can be used by other stakers on forks that he's not betting against (staking is too risky).  EIP 134 allows that this transaction can be specified to only be used immediately following a specific parent block (only at the location of the fork).

Does this work?  Could a variable PoS scheme potentially be made from this double(or more)-or-nothing staking scheme?


texts: How to decide the amount of ether you need for your app?

texts:
Let say I am building a contract which works like a coins/mark point system. I know that when we deploy the contract we need ether. And the transaction will happen which then needs gas for the fee. The gas will be extracted from the ether that the account has right?

The gas is said to be consistent but the number of transaction cannot be predicted. It can be few or huge so how we calculate the ether we need in first place? (I am asking this in case you build an app then release to customer, how you should set up the ether amount and make sure later it not runs out)

Anyone with experience in DApp development out there please help explains how should we allocate ether in first place? And what to do when the ether runs out?

Many thanks


texts: Smart Contract - How to Copy or Clone it?

texts:
All - Could someone tell me if it is possible to copy or obtain a smart contract code that has been proven to work on the blockchain in the past. I have a block number and the smart contract address, so how do I obtain the exact code and files used in that contract?
Thanks


texts:
How do you recover the EC public key from a VRS style signature in python?

I am trying to setup some encryption between two parties via ECIES, but I first wanted to obtain the public key via recovery from a transaction. The following is an example transaction from my geth console I've been working with.

eth.getTransaction("0x912b33e09311a72b988af66918abcd53f43831688c7acb6b44870c491f073dab")
{
  blockHash: "0xfdc5a1c9e1a0dcdfb2b9884919b79157a04eb15b0b58c91131e957f2803f8195",
  blockNumber: 100449,
  from: "0xc6f4f527587ea4a03aa85e0322783592367c1b9a",
  gas: 100000,
  gasPrice: 18000000000,
  hash: "0x912b33e09311a72b988af66918abcd53f43831688c7acb6b44870c491f073dab",
  input: "0x",
  nonce: 21,
  r: "0xab90122dc4e4bbdbb14ef22ad3ae21aecc19a1c90a9c8989c68b26cc782ff303",
  s: "0x36e5f275147049d3afd5d33b735cc9313d2c1aad3ab401aefdce678128e2f1d0",
  to: "0xa593094cebb06bf34df7311845c2a34996b52324",
  transactionIndex: 0,
  v: "0x1c",
  value: 1000000000000
}
web3.sha3(eth.getRawTransaction("0x912b33e09311a72b988af66918abcd53f43831688c7acb6b44870c491f073dab"),{encoding:'hex'})
"0x912b33e09311a72b988af66918abcd53f43831688c7acb6b44870c491f073dab"

From the transaction above, I have the raw material for the signature (e.g., V, R, S) and the sender (i.e., "from" field) which I can use to verify the address.

I'm trying to do this in python.

sender = "0xc6f4f527587ea4a03aa85e0322783592367c1b9a"
hash = "0x912b33e09311a72b988af66918abcd53f43831688c7acb6b44870c491f073dab"
r = "0xab90122dc4e4bbdbb14ef22ad3ae21aecc19a1c90a9c8989c68b26cc782ff303"
s ="0x36e5f275147049d3afd5d33b735cc9313d2c1aad3ab401aefdce678128e2f1d0"
v = "0x1c"
import bitcoin
import ethereum.keys #for a good sha3 implementation
from rlp.utils import decode_hex, encode_hex
rawhash = decode_hex(hash[2:]) # omit the 0x
vrs = (int(v[2:],16),int(r[2:],16),int(s[2:],16)) # omit the 0x and convert to integers based on base16 (hex)
rec_pub = bitcoin.ecdsa_raw_recover(rawhash,vrs) ## Trouble line!
enc_rec_pub = bitcoin.encode_pubkey(rec_pub,"bin")
rec_address = encode_hex(ethereum.keys.sha3(enc_rec_pub[1:]))[24:]
if rec_address == sender[2:]:
    print "[+++] The address was recovered from the public key! :-)"
else:
    print "[-] This address is not the same :-("

The ecdsa_raw_recover never results in the correct value. I've opened up the keyfile to verify the public/private key and the following line never results in the correct value.

rec_pub = bitcoin.ecdsa_raw_recover(rawhash,vrs)

Is there some aspect to this that I am missing or a better recommendation on how to achieve this?
Thanks in advance!


texts:
I have a private blockchain deployed on one machine and Mist & Ethereum Wallet on another machine. Both the machines are connected through RPC. I have made a simple smart contract which adds two numbers.

I submit a transaction through Mist which gets sent to the blockchain.

Suppose, my inputs are 4 & 5, where are these inputs stored in the blockchain? Where is the output stored? Can I access these logs?


texts: Can I recover MEW private key with password?

texts:
I feel desperate. I lost my private key and keystore file. Are my tokens stuck in the wallet forever?

Can I recover the private key only with password? Or can any hard wallet be connected with the wallet with password?


texts: value.forEach is not a function on web3 send

texts:
I try to call a smart contract method in my web page, this is my following code:

this.miniVaultContract.methods.addDocument("0x00aaff","0x00aaff","0x00aaff",["0x00aaff", "0x00aaff", "0x00aaff"],[1, 2, 3],4,2,3,1)
.send({
    from: this.selectedAccount //My Metamask address
}).on('error', error => {
    alert("An error has occured when adding your document (ERR: " + error + ")");
    return;
});

My smart contract looks like this:

function addDocument(
    bytes32 documentId, bytes32 title, bytes32 description, bytes32[] keywords, uint[] ratings, uint documentType, uint startDate, uint endDate, uint duration
)
    public
    returns (bool)
{
    /* my code */
}

When I try to call the method, I get the following error:

  Unhandled Rejection (TypeError): value.forEach is not a function

I thought maybe it has to do with the array in the parameters, but I can't seem to find any documentation about that in web3.

Any ideas on what could go wrong here?


texts: How smart contract different than programs-package?

texts:
I was reading about the smart contract and I'm able to create the smart contract but I didn't know why the smart contract is used? When I did search on google about this, I understood following -

New language 'solidity' used for creating the smart contract.
A smart contract is secure and can't be updated after deploying.
A smart contract is nothing but a set of functions which automates the process.
After deploying it into the blockchain network, will get the address of that contract. By importing this address, we can able to access its methods.
A smart contract doesn't store the data, We need to create the logic accordingly to store the data in DB.

But wait, we can achieve above same points using the set of programs called 'packages'. Why not we use the following -

Create one package which has all set of functions. (the same we've written in the smart contract using solidity)
We can make this package as private. (Only some organization have access to this)
We can add the extra security layer so that malicious user does not have the access to that code.

lastly, my main concern is why the smart contract is used? despite we can implement the same logic using the package (as described above)


texts: Can a "forward" smart contract forward the received ether to another "forward" smart contract which forwards it to an address?

texts:
I am pretty new to solidity. I am trying to create a smart contract which deploys another smart contract and transfers ether to the newly created contract when a payment greater than 0.01 ether is made to the parent contract. The deployment goes through, but when i try to send ether to the parent contract, i keep getting the "out of gas" error. Can someone please let me know what might be the issue?

Thanks!

pragma solidity ^0.4.8;

contract Bakery {
    address[] public contracts;
    address public ContractAddress;

    event LogForwarded(address indexed sender, uint amount);
    event LogFlushed(address indexed sender, uint amount);

    function() payable external {
        emit LogForwarded(msg.sender, msg.value);
        if(msg.value > 0.001 ether) {
            Cookie c = new Cookie();
            contracts.push(c);
            address(c).transfer(msg.value);
        }
    }
}

contract Cookie {
    address public destinationAddress;

    event LogForwarded(address indexed sender, uint amount);
    event LogFlushed(address indexed sender, uint amount);

    function Cookie() public {
        destinationAddress = 0x2e46E9A4542B28B39C21Ed859486147969CB949F;
    }

    function() payable external {
        emit LogForwarded(msg.sender, msg.value);
        destinationAddress.transfer(msg.value);
    }

    function flush() public {
        emit LogFlushed(msg.sender, address(this).balance);
        destinationAddress.transfer(address(this).balance);
    }
}


texts: Mocha assertions not returning correctly on assert.equal with BN

texts:
Is this an issue with deep matching/object identity?

AssertionError: expected <BN: 204fce5e3e25026110000000> to equal <BN: 204fce5e3e25026110000000>

It seems strange that chai.should seems to work fine with the same vars:

// works
supplyCap.should.be.bignumber.equal(_cap);

// doesn't work
assert.equal(supplyCap, _cap);


texts: Is it possible to create a smart contract that makes other smart contracts

texts: I am wondering if I could make a smart contract that makes other smart contracts when prompted to. For example, I send a transaction to smart contract A telling it to make smart contract B. And smart contract B has my original wallet as the owner.


texts: How to prove root chain (Ethereum) NFT ownership from L2 (Polygon/Matic) Contract

texts:
I'm building a system that allows a user to "claim" a ERC1155 NFT on Polygon/Matic if they own a certain ERC1155 NFT on the root network (ethereum). My current solution works off-chain, by authenticating root-network ownership via a website signature request and then transferring the token on Matic if the signature passes.
Since it is off-chain, there are race conditions in validating ownership. Is there an on-chain way to validate root-network NFT ownership from a Polygon/Matic contract? Any solution without race conditions is on the table.


texts: Cant Retrieve the values of Structure fields (i.e. text boxes) through Remix IDE

texts:
I am giving the values to structure field through Remix IDE, then I am putting ‘0’ as the index of people array, then I click transact and then I click call, but Remix does not show me the value I gave as input to the structure fields (encircled in blue box).
However, previously it worked:
Understanding array of structure
The code is:

    pragma solidity 0.5.4;
    contract MyContractOwnerAddr {
        uint256 public peopleCount = 0;
        mapping(uint => Person) public people;

        address owner;

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

        struct Person {
            uint _id;
            string _firstName;
            string _lastName;
        }

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

        function addPerson(
            string memory _firstName,
            string memory _lastName)
            public
            onlyOwner
        {
            incrementCount();
            people[peopleCount] = Person(peopleCount, _firstName, _lastName);
        }

        function incrementCount() internal {
            peopleCount += 1;
        }
    }

Some body please guide me.

Zulfi.


texts: Can not Open Ethereum Wallet on Window 10

texts: I did trying install soft Ethereum wallet on windows 10, But I can't open the program. It looks like the picture below. Help me pls, Thank everyone.


texts: Can solidity manage and process blob,clob or xml objects?

texts:
Understand that one should limit blockchain only to transactions information that needs to be decentralised and not file storage related objects. However, if one needs to process some xml objects before putting it on the blockchain, how should one do it? In the dapp tier itself?

Nathan Aw


texts: Finding the address of the proxied to address of a proxy

texts:
This smart contract (https://etherscan.io/address/0x4fabb145d64652a948d72533023f6e7a623c7c53#code) is a proxy. You can tell this by clicking on 'Read as Proxy'.
However, when one looks at the 'Read Contract' tab and one clicks on the implementation data item, it reports the implementation address as 0x.
I notice in the code that the implementation function is not public, so I suppose that's why it's not returning a value, but then...
Question: How does Etherscan know that the contract is a proxy and what fourbyte code does it use to query the proxied-to address?


texts: Is their any API available that gets me the price of Eth in USD for example at a particular blocknumber?


texts: web3 python convert addresses from transaction log topics

texts:
I'm trying to get the to and from address from the logs in a transaction.
In my example, the log entry is for a Transfer(address,address,uint256).
The resulting topics[1] and [2] return the addresses, but in a long format:
0x0000000000000000000000002dbbbebef9915110dac11a89ca986ba6051d0972
How do I convert this to a regular address? Eg:
0x2dbbbebef9915110dac11a89ca986ba6051d0972


texts: Why is one geth peer using TCP port 2743?

texts:
All my other peers look like this (admin.peers)
  remoteAddress: xx.xx.xx.xx:30303

But one peer looks like this:
  remoteAddress: xx.xx.xx.xx:2743

(This port is listed as 'murx protocol', which I have never heard of)


texts: Is it possible to delete an ERC-20 token contract?

texts:
Is it possible, that someone creates a new token on Ethereum let it be XYZ, an ERC-20 token.
Can he later call a destructor func that will wipe off all funds from all people that are using that system?
Or could he redirect all money to his account?


texts:
I have been watching these videos:

'Kent Barton & Alex Gluchowski ~ Scaling With Zero Knowledge'
https://www.youtube.com/watch?time_continue=1&v=aEqhjpjoaEA

Scalable blockchains as data layers | Vitalik Buterin
https://www.youtube.com/watch?v=mOm47gBMfg8

After watching this video:

Friday Afternoon - May 10 - Main Stage Session - #EtherealNY2019
https://youtu.be/ccqAoM9AsXs?t=13087

(The chat between John Walpert and Paul Brody from EY).

In the middle of watching the technical video, the following question came to me:

Are the benefits of ZKPs:

a. Enabling private transactions on public blockchains as Paul talks about, and is desirable by enterprises and could facilitate adoption i.e. overcoming a privacy hurdle leading to companies feeling comfortable about using blockchains.

or:

b. "We can prove with Zero Knowledge that the new block is correct and that all the transactions are valid" and "The operator cannot commit any incorrect block on the Mainchain" which is more of a 'technical' hurdle that is being overcome, and would allow Ethereum to scale mathematically.

Or is it both?

Or maybe I'm still misunderstanding something.


texts: How can I generate EOA address on testnet using JavaScript without access to ETH node?

texts:
I just started Ethereum. I found how to generate an address by using JavaScript like below. I need an address for testnet. I'm using Ropsten testnet. In bitcoin, I can generate from pubkey to both mainnet address and testnet address. Does Ethereum have the same rule?

var bip39 = require('bip39');
var hdkey = require('ethereumjs-wallet/hdkey')

var mnemonic = 'xxx xxx xxx...';
var password = '';
var masterseed = bip39.mnemonicToSeed(mnemonic, password);
var hdnode = hdkey.fromMasterSeed(masterseed);

var getKeyPair = function(hdnode){
    return {
        "address" : hdnode.getWallet().getAddressString(),
        "private" : hdnode.getWallet().getPrivateKeyString(),
        "public" : hdnode.getWallet().getPublicKeyString(),
    }
}

// cointype=60=eth
// m / purpose' / coin_type' / account' / change / address_index
console.log(getKeyPair(hdnode.derivePath("m/44'/60'/0'/0/0"))) // { address: '0xbc0c53d89b2fe10d1d140665bd94b3d926f4a790', private: 'xxx', public: 'xxx' }

Update 1

Seems the address format of mainnet and testnet are same.

  There is no way to verify if an address belongs to a particular network - they are all valid for every Ethereum network.

Are addresses between different networks (testnet) interchangeable?


texts: truffle migrate fails:Insufficient gas limit or exceed gas limit

texts:
$ truffle migrate

Compiling .\contracts\Migrations.sol...
Compiling .\contracts\Voting.sol...
Writing artifacts to .\build\contracts
Using network 'development'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... undefined
Error encountered, bailing. Network state unknown. Review successful
transactions manually.
Error: insufficient funds for gas * price + value

I am facing error during migration.

my truffle.js is:

require('babel-register')

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*', // Match any network id
      gas: 4712388,
      from: '0xe8321ca272cb292Cc2485fBa749Fd20d40ed5C44'
    }
  }
};

gas limit 4712388 then insufficient...

gas limit 4712389 then exceeds...what to do ?


texts: Need help with setting up eth-netstats and eth-net-intelligence-api

texts:
I have set up an ethereum node on an ubuntu server. I'm running a geth instance with a miner in a private test net.

For the life of me I cant get eth-net-intelligence-api to monitor the eth-network.

So I've edited my app.json to reflect the correct servers and secret. And I've followed the install instructions on both githubs.

Additional question: will "WS_SECRET=abc npm start" to start the net-intelligence frontend be enough for the secret to work properly?

I think the problem is with the WS server. What exactly should I set the WS server to be?


texts: Testing solidity default function with Truffle and async/await

texts:
I am developing a crowd sale contract in solidity. The fallback function is payable so that investors can send ether to the contract. If incoming transaction is accepted then information about the investor is logged and the ether transferred to a storage wallet/address.

function() public payable {
    buyTokens(msg.sender, msg.value);
}

function buyTokens(address buyer, uint256 weiAmount) internal {
    require(checkPreSaleOn() || checkGeneralSaleOn());
    require(!halted);
    require(buyer != address(0));
    require(weiAmount > 0);
    require(weiAmount % 1 ether == 0); // only integer numbers
    uint256 numTokens;

    if (state == State.PreSale) {
        require(weiAmount <= 20000000000000000000); // max 20 ETHER
        numTokens = weiAmount.div(preSaleExchangeRateinWei);
    }
    if (state == State.GeneralSale) {
        require(weiAmount <= 20000000000000000000); // max 20 ETHER
        numTokens = weiAmount.div(generalSaleExchangeRateinWei);
    }

    investedAmount[buyer] = investedAmount[buyer].add(weiAmount);
    fundsRaisedInWei = fundsRaisedInWei.add(weiAmount);

    allocatedTokens[buyer] = allocatedTokens[buyer].add(numTokens);
    tokensIssued = tokensIssued.add(numTokens);
    TokensPurchase(buyer, weiAmount, numTokens);

    wallet.transfer(weiAmount);
}

Problem is that the javascript test (see below) is not awaiting for the (send ether) transaction to go through and so both the initial and final balances will be the same. Thus the assert will fail (because amount = 0).
After a few seconds I check the wallet balance and I see the amount has been correctly transferred.

const MyContract = artifacts.require("./contracts/MyCrowdSaleV2.sol");

var Web3 = require('web3');
var pwd = "123";
contract('MyContract', async function(accounts) {
        it("Token purchases go through after pre-sale open", async function() {

            MyContract.new('0x0ca1afa472b258e8811a0c1406a66c7b9cf6acea', preSaleDuration, generalSaleDuration);

            await instance.openPreSale({from: accounts[0]});
            let initialBalance = await web3.eth.fromWei(instance.getBalance(instance.address),'ether').toNumber();
            var tx = {from: accounts[2], to: instance.address, value: web3.toWei(10, "ether"), gas: 200000 };
            let txHash = await web3.eth.sendTransaction(tx, pwd);
            let finalBalance = await web3.fromWei(web3.eth.getBalance(instance.address),'ether').toNumber();
            let amount = (finalBalance - initialBalance);

            await assert.equal(amount,10, "Could not purchase 10 ether of tokens during pre-sale");
        });
})

Any ideas what I am doing wrong?

Thank you in advance


texts: Best Practices for Recommendation regarding Gas Price & Limit in a Dapp

texts:
I am developing a Dapp. I was wondering what are the best practices for user recommendation regarding gas price and limit in such a Dapp? Should I be using the following methods in my contract, or should I rely on the user's wallet (e.g. MetaMask) to recommend these values to the users? What are the pros and cons of each technique? In which scenarios should I use one instead of the other?
 web3.eth.getGasPrice([callback])
 myContract.methods.myMethod().estimateGas()

Thank you. J


texts: Substrate purge-chain expects a spec file

texts:
Working from a substrate-node-template generated with the tools at https://getsubstrate.io, I'm having trouble purging the chain.

According to this tutorial, the command

./target/release/substrate-node-template purge-chain --dev

Should work, but I get an error that seems to be looking for a spec file.

Error: Error opening spec file: No such file or directory (os error 2)

Since the tutorial made no mention of this, I'm confused and would appreciate any insight.


texts: ERC20.balanceOf changes output without any Transfer events occurred

texts:
Here is a use case,

There is an interest generating ERC20, where each address may have increasing balances for each blocks from earning interest. Usually, one would need to send a non-standard payInterest() transaction in order to trigger Transfer event so that balanceOf could reflect the increased balance. But imagine if the ERC20.balanceOf function is modified in such way that the accumulating interest is taken into account without actual Transfer events recorded on chain.

The question is: is such behavior of ERC20.balanceOf acceptable, and are there undesired side effects using ERC20 wallets because of this.


texts: Solidity error when encoding arguments to call a function with Bytes32 Type Parameters

texts:
While developing a Smart Contract with Solidity on Remix, after creating the contract I'm trying to call a function by passing Bytes32 datatype parameters:

function addTT(bytes32 _name) public {
...
}

but when I call addTT() by passing parameter "neo" it throws the following error:

  transact to Abc.addTT errored: Error encoding arguments: Error:
  invalid bytes32 value (arg=undefined, type="string", value="asda")

Any idea how can I properly call function addTT()?


texts: Function of smart contract returns 0 from Web3j

texts:
please help me in this problem.
I am successful to compile and deploy my smart contract using web3j on testrpc. But When I call the function that returns uint in this contract from web3j, I always receive 0. I present below my contract and my Java program.
1. My Smart Contracts:

pragma solidity ^0.4.6;
contract grandParentContract{

  address public myAddr = 0x1005...;

  modifier onlyFromMe() {
    if ((myAddr != address(0)) && (tx.origin != myAddr)) {
        Msg("Permission Error: this function is limited to the my address origin.");
        return;
    }
    _;
  }
}

pragma solidity ^0.4.6;
contract parentContract is grandParentContract {

/**************BEGIN: attributes or properties or dataobjectType**********/

 uint public maxIdValue=0;
 uint public minIdValue=0;

 event ElementAddition(uint _id);

 function parentContract() grandParentContract() {
   maxIdValue = 0;
   minIdValue = 0;
 }

}

contract MyContract is parentContract {
  struct MyElement {

    uint id;
    string name;
    string description;
    uint[] currentForeignKeys;
  }
  mapping(uint => MyElement) public myElementMap;

  function MyContract() parentContract() {

  }

  function addNewElement(string _name, string _description) public onlyFromMe() returns (uint) {
    uint _id = maxIdValue+1;

    myElementMap[_id].name = _name;
    myElementMap[_id].description = _description;

    maxIdValue = _id;
    ElementAddition(_id);
    return _id;
  }

}

Compile and Deploy successfully
I use testrpc

Web3j web3 = Web3j.build(new HttpService("testrpcIp:testrpcPort"));

When I compile smart contracts, I obtains 3 *.bin files and 3 *.abi files
MyContract.bin(abi), parentContract.bin(abi), grandParentContract.bin(abi)
I deploy successfully the smart contract using the file MyContract.bin and web3j
(Note that, when I deploy this smart contract, I only load the content of this MyContract.bin file, not add 0x before this content)

Call addNewElement function from Java and receive always 0 (zero)

List<String> results= callMyFunction(web3,aCredential,contractAddress, "addNewElement", Arrays.<Type>asList(new Utf8String("name1"),new Utf8String("description of name1")), Arrays.asList(new TypeReference<Uint>() {}));
System.out.println("results = " + results);

public static synchronized List<String> callMyFunction(Web3j web3, Credentials creds, String contractAddress, String functionName, List inputArgs, List outputs) throws Exception {

    List<String> results = new ArrayList();
    Function function = new Function(functionName, inputArgs, outputs);
    String encodedFunction = FunctionEncoder.encode(function);
    EthCall response = web3.ethCall(Transaction.createEthCallTransaction(creds.getEcKeyPair().getPrivateKey().toString(16), contractAddress, encodedFunction), DefaultBlockParameterName.LATEST).sendAsync().get();
    if(response.hasError()){
        System.out.println("functionCall: " + response.getError().getMessage());
    }
    convertMyResult((response != null) && (response.getValue() != null) ? FunctionReturnDecoder.decode(response.getValue(), function.getOutputParameters()) : new ArrayList(), results);
    return results;
}

public static void convertMyResult(List<Type> returns, List<String> results) throws Exception {
    if (returns.size() > 0) {

        for(int i=0; i<returns.size(); i++){

                results.add(returns.get(i).getValue().toString());

        }
    }
}

I always receive the results : [0].
I tried to put maxIdValue in the MyContract instead of in ParentContract, but the result is the same


texts:
After downloading and installing Ethereum wallet for mac from Ethereum web site
When I start the app, I get the initialisation screen saying "Ethereum node needs to sync, Downloading block.., Downloading chain structure...".

But I am not doing mining. why a wallet has to do a node sync and get blocks and chain...? Thanks


texts: Is it possible to get the token transfers of a address?

texts:
I want to get token transfers of an address (incoming) but i guess once i have this sorted i can figure that out.

So for example here - https://etherscan.io/address/0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be#tokentxns

They have all the token transfers and i can't really see in their API to get all the token transfers so i was wondering if anyone knew how to do to get all token transfers going on the address.
I have tried doing many stuff while trying to using web3.js and try subscribe to events.
I realise when a smart contract transfers a token the Transfer event is called and emitted but i don't see how to show all the token transfers using etherscan API.
Thanks guys.


texts:
Description of issue

I'm trying to debug a simple contract using remix on chrome v. 65 on Ubuntu.

I must be doing something wrong, because I have the following issue:

When I place a breakpoint in the middle of a function, execute the function and then hit "DEBUG", the debugger is not at the breakpoint.

Furthermore, when I hit the button "Jump to next breakpoint" it (the execution flow slider) merely jumps to the end.

The contract

The simple contract compiles and remix looks like so after compilation:

Deployment

Then I deploy the contract, after which remix looks like so:

Set breakpoint in a function and run that

Then I set a breakpoint on line 18, enter the value 15 as argument to the function changeValue and execute it, after which remix looks like so:

Hit "DEBUG" and notice that program is not at the breakpoint

After hitting "DEBUG" I would expect the program to be at the breakpoint and a highlight therearound in the code. In staed I see this:

Hitting "Jump to next breakpoint" ends

When I now hit "Jump to next breakpoint" I'd expect the debugger to hit the breakpoint after all, in stead it jumps to the execution end (as you can see from the slider position).

This is what remix looks like after hitting "Jump to next breakpoint":

Question

What am I doing wrong or what else should I try?


texts: ERC721 NFT : This contract does not implement all functions and thus cannot be created

texts:
I am working on a NFT project using the ERC721 token standard, and I cannot get the ERC721 contract to deploy in remix.

Here is the ERC721 contract:

   contract ERC721 {
  event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
  event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);

  function totalSupply() constant returns (uint256 totalSupply); //implemented
  function implementsERC721() public pure returns (bool); //implemented
  function balanceOf(address _owner) public view returns (uint256 _balance); //implemented
  function ownerOf(uint256 _tokenId) public view returns (address _owner); //implemented
  function transfer(address _to, uint256 _tokenId) public; //implemented
  function approve(address _to, uint256 _tokenId) public; //implemented
  function takeOwnership(uint256 _tokenId) public; //implemented
  function transferFrom(address _from, address _to, uint _tokenId) public; //implemented
}

Here is the contract that implements all of the functions:

    contract OwlOwnership is ERC721, OwlHatchery {

  using SafeMath for uint256;

  modifier onlyOwnerOf(uint _owlId) {
    require(msg.sender == owlToOwner[_owlId]);
    _;
  }

  mapping (uint => address) owlApprovals;

  function implementsERC721() public pure returns (bool) {
        return true;
    }

  function balanceOf(address _owner) public view returns (uint256 _balance) {
    return ownerOwlCount[_owner];
  }

  function ownerOf(uint256 _tokenId) public view returns (address _owner) {
    return owlToOwner[_tokenId];
  }

    function _owns(address _claimant, uint256 _tokenId) internal view returns (bool){
        return owlToOwner[_tokenId] == _claimant;
    }

    function _approvedFor(address _claimant, uint256 _tokenId) internal view returns (bool){
        return owlApprovals[_tokenId] == _claimant;
    }

  function _transfer(address _from, address _to, uint256 _tokenId) private {
    ownerOwlCount[_to] = ownerOwlCount[_to].add(1);
    ownerOwlCount[msg.sender] = ownerOwlCount[msg.sender].sub(1);
    owlToOwner[_tokenId] = _to;
    Transfer(_from, _to, _tokenId);
  }

  function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
    _transfer(msg.sender, _to, _tokenId);
  }

  function transferFrom(address _from, address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
        require(_to != address(0));
        require(_to != address(this));
        require(_approvedFor(msg.sender, _tokenId));
        require(_owns(_from, _tokenId));
        _transfer(_from, _to, _tokenId);
    }

  function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
    owlApprovals[_tokenId] = _to;
    Approval(msg.sender, _to, _tokenId);
  }

  function takeOwnership(uint256 _tokenId) public {
    require(owlApprovals[_tokenId] == msg.sender);
    address owner = ownerOf(_tokenId);
    _transfer(owner, msg.sender, _tokenId);
  }
}

I can deploy all other contracts in my project besides the ERC721 contract. I keep getting "This contract does not implement all functions and thus cannot be created.". Any ideas?


texts: What is the point of switching to ProgPOW for ethereum, when POS is coming in the coming year(s)?

texts: With the recent discussion of the new ProgPOW mining switch. What is the point of it when POS is coming in the coming year(s)? I understand it disables the ASIC miners, while benefiting the GPU miners. But this wouldn't this cause chaos for Ethereum causing a fork of Ethereum again with ASIC miners staking on the old algo while the new GPU miners go on the new Ethereum chain? I don't understand the cost/benefits of doing something so drastic when POS is supposedly coming in the coming year(s)?


texts: Is it possible to transfer ERC20 tokens without sending a transaction to the contract address?

texts: I'm trying to reverse engineer etherscan so I can make my own explorer. While I was checking Augur token transfers I found a transaction where both the to and from address where different from the token's smart contract address. How is this possible?


texts: Cloning geth and adding a POS consensus algorithm?

texts:
I am currently learning how to use geth, so far I was able to create a private POW and POA blockchain using one of its consensus types (Clique).

I am wondering how feasible it would be to clone the entire repository and add a new consensus algorithm (BFT, DPOS, POS etc). Is geth modular enough to do this?

I have gone through the github respository many times https://github.com/ethereum/go-ethereum but I still cannot understand the whole concept of what each folder contributes to. If someone can link me some guide of understanding the code of geth it would be great! Thank you


texts: Visual Studio using C# cannot find web3.Miner.Start.SendRequestAsync

texts:
The active using statements of the code are:

using System;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using Nethereum.Web3;
using Nethereum.Web3.Accounts;
using Nethereum.ABI.FunctionEncoding.Attributes;
using Nethereum.Contracts;
using Nethereum.Hex.HexConvertors;
using Nethereum.RPC.Eth.DTOs; //using Nethereum.Geth;

The lint in Microsoft Visual C# 2017 cannot find the function:

web3.Miner.Start.SendRequestAsync(6);

It flags Miner as not a member of web3.

Note: I declared web3 prior in the code as:

var web3 = new Web3(myAccount);

How do I resolve this?


texts: Installing web3: getting different results than the tutorial

texts:
Mac OS 10.13.6

I installed node and web3
npm install web3
...
+ web3@1.0.0-beta.52
added 331 packages from 246 contributors and audited 9528 packages in 144.776s
found 0 vulnerabilities

Instructions from tutorial:

  var Web3 = require('web3')
  undefined
  Web3
  [Function: Web3]

In the tutorial when the guy types Web3 he gets a long list of items. All I get is : [Function: Web3]
Following the rest of the tutorial, I don't get the results he does.


texts: Need a guide to access my ropsten test network contracts through my command line and not remix

texts:
I have written and published a contract on the ropsten test network using remix. Now I want to access the functions of the smart contract from my command line (My PC) and not the remix IDE. Is there a way to do this?

Note:
I have my contract address.


texts: I've installed Mist which uses geth; so how do I launch geth from the command line?

texts:
I've installed Mist (using a dmg, on Mac OS X).

Mist runs great, and when I run it, it seems to be using geth.  How can I run geth from the command line without reinstalling it and without running Mist?


texts: How to understand the Swap event payload?

texts:
I am trying to wrap my head around pancakeswap Swap event (which should be equivalent to uniswap).
Here is an example transaction: 0xd809e359a4037eb5e2617769b93f8b7fa1e708c37019b02933e1845e33c99884
This transaction contains Swap event:
Swap (
  index_topic_1 address sender,
  uint256 amount0In,
  uint256 amount1In,
  uint256 amount0Out,
  uint256 amount1Out,
  index_topic_2 address to
)

and it has the following values:
sender: 0x10ed43c718714eb63d5aa57b78b54704e256024e
amount0In: 12772329830235
amount1In: 2562091000000000000
amount0Out: 208940457743532637
amount1Out: 0
to: 0x97c2727b8f0584f45f86d2d3dead77e5c74814bc

and this event originates from contract 0xff3dd404afba451328de089424c74685bf0a43c9.
As far as I understand,

amount0 relates to token0 as defined in 0xff3dd404afba451328de089424c74685bf0a43c9
amount1 relates to token1 as defined in 0xff3dd404afba451328de089424c74685bf0a43c9

In this case,

token0 is SafeMoon contract (9 decimals)
token1 is Wrapped BNB (18 decimals)

If I am reading this event correctly, it says that we are trading WBNB 0.2562091 for SafeMoon 208,940,457.
However,

BscScan shows that the actual amount transferred is 188,046,411. This can also be seen by looking at the logs, Transfer event.
It is not clear what role does amount0In (12772329830235) play in Swap event.

How does one determine by looking at the Swap event that we traded WBNB 0.2562091 for SafeMoon 208,940,457?


texts: Warning: Using contract member "balance" inherited from the address type is deprecated. Convert the contract to "address" type to access the member

texts:
I have looked at the other posts with similar warning but I do not see how they apply to my context.

This is the exact line that is causing the error:

players[index].transfer(this.balance);

which is inside of this function:

function pickWinner() public {
  require(msg.sender == manager);
  uint index = random() % players.length;
  players[index].transfer(this.balance);
  players = new address[](0);
}

I am not sure if I should understand this literally, because I have not seen any documentation of what to use in lieu of balance.


texts:
Here I am having an issue where the values are not appearing to function correctly in the Remix IDE browser.

I am trying to have a buyer where they can transfer funds to each other, and the seller can add a description and retrieve the description.

The issue I am finding is when I execute the at the address I can't appear to get the amount from the Buyers contract. The only thing that happens when I click on getAmount it executes but returns nothing.

Any help would be appreciated.

Below is the code I entered into Remix:

 pragma solidity ^0.4.17;

contract Buyer {
        //event LogDescription(address sender, uint amount);
        uint  amount;
        mapping (address => uint) balances;

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

   function getAmount() returns(uint) {
        return(amount);
    }

}

    contract Seller{
        string description;

        Buyer bartscontract;

        function SetDescription(string _description) public {
            description = _description;
            //LogDescription(msg.sender, msg.value, description);
        }
        function getDescription() constant public returns(string) {
            return description;
        }

    }

Here are some screenshots for send and receive ether for further analysis.
Below is for Sending 1 Ether to the address:

Below is for trying to get or view ether sent to the specified address.


texts: How did cryotokitties create the image of the cats?

texts: For cryptoKitties, the images of the cats are based on gene, for example, color, curve type etc. and the image of the cat will be created, how does the image created, it is by programming running background? does it mean the server keep a lof of different types of tails, ears, mouths and use a program to combine them? what kind of program can do this? Thanks


texts: How do I connect a blockchain system to a cloud database

texts:
I am very new to blockchain, so I just wanted to get some preliminary answers and clarity.

So currently we have a cloud database to manage certain documents (which contains sensitive information). These documents are important and necessary for trade finance i.e. verifying personnel need to view these documents (banks, customs etc.)

1) If an organisation develops their own blockchain, and request for us to be part of their network (assuming private blockchain), how would we interoperate their blockchain system with our cloud database?

What sort of information would be included in each 'block' of the blockchain?
From my understanding, it is possible to simply provide the whole document (i.e. in PDF or some other format), and included it on the blockchain, however that due to the size of the file it may not be ideal.
The other potential option is for the blockchain system to create a hash value. Verifying personnel would compare the hash value to the document to check veracity. In this scenario, would the document need to have the hash key attached to it as well?
The third option, (I'm not sure if this is possible), is to provide the blockchain network a URI, which can link personnel to our cloud database. The URI can be designed either to link the personnel straight to the document or they could be given a login key. In this scenario, would the URI need to be formatted in a special way?

As you guys probably know that I am fairly new to this blockchain, so please correct me if I am wrong in any part.

Cheers


texts:
What is JITVM, what it is used for and what is its relation with --fastflag?

And also how is it different than EVM. Are they both same if not than what's the difference?


texts: How to execute a private transaction in quorum


texts:
I want to use web3 from loginmain.js file. My project hierarchy looks like:

Project/
  www/
    login.html
    js/
      login.js
      app/
        loginmain.js
      lib/
        jquery.js
        web3.js
  tools/

my loginmain.js file :

define(function (require) {
var $ = require('jquery'),
    Web3 = require('web3'),
    lib = require('./lib'),
    controller = require('./controller/c1'),
    model = require('./model/m1');

//A fabricated API to show interaction of
//common and specific pieces.
var web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8000'));
console.log(web3);
controller.setModel(model);
$(function () {
    controller.render(lib.getBody());
});});

I get the following Error

TypeError: Web3 is undefined

Any idea how can I solve it ?


texts: Unable to launch the Ethereum studio IDE

texts:
I would like to use Ethereum IDE for development . I have created a account on ether.camp  but when I click on the icon Start Now , I always see the same screen - attached below

Can anyone tell me why I cannot see the Ethereum IDE?


texts: What is the best way to verify that a text I received in mu function is a valid hash? In other words, contains a specified length and is composed only by numbers and "a", "b", "c", "d", "e" or "f"?


texts: How does drizzle know when contract state has updated and reflect that state in the store (when a value has been `cacheCall`ed)?

texts:
Basically could someone provide a more technical explanation of this?

It says that it watches(subscribes to) for block headers and when comes in it "through the transactions looking to see if any of them touched our contracts". How does it do this? Does it have to retrieve all the transactions in the block, or is there some clever way for it to know this (a merkle proof or something?)?

It then says "we replay the calls already in the store to refresh any potentially altered data." How do you 'replay a call'? Does that mean it simulates the call, or it fetches the data from the blockchain for every value drizzle is subscribed to?

Lastly (hopefully explaining the above will make this question redundant), how does this scale? If you are watching 100 contract values does that make 100x more calls to the blockchain every block than if you are only subscribed to 1 value?


texts:
Im trying to create a account using the web3j library. But i can´t find the method that create accounts. My idea is to make this judgment but not in the Geth console, but yes in the Java application using web3j:

  geth account new

Any idea?

Im new in ethereum and till the moment im not generating wallet because im not using smart contracts. Mi idea is just create accounts with de Java application and make simple transacion of eth betwen them in a private chain.

Thank you


texts: What exactly web3.eth.accounts.create do

texts:
When web3.eth.accounts.create is used to create an account something like this can be seen.

web3.eth.accounts.create();
> {
    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",
    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",
    signTransaction: function(tx){...},
    sign: function(data){...},
    encrypt: function(password){...}
}

now if web3.eth.accounts.encrypt(privateKey, password); is executed using the same privatekey that we got from the previous step we can get a output as the web3 keystore v3 standard. Now if we store this file in the geth node's keystore folder (ex user/.ethereum/private/keystore) and run personal.listAccounts we can get our created address on that list.

So when I need to unlock this account with web3.personal.unlockAccount what would be the passphrase that I need to give to unlock my account?


texts:
I have enums that I use in many contracts of one project. Sometimes, they need to be mapped to a uint256. Their uint256 values do not relate to their positions in the enum list, so I can't just cast the enums to uint256.
Currently, I have a library with functions converting between enums and uint256 values:
function enumToUint(Foo _foo) returns (uint256) {
    if(_foo == Foo.apple) {
            return 45245;
    }
    if(_foo == Foo.banana) {
            return 557857585;
    }
    if(_foo == Foo.clementine) {
            return 1352;
    }
    // ...
}

function uintToEnum(uint256 _bar) returns (Foo) {
    if(_bar == 45245) {
        return Foo.apple;
    }
    // ...
}

This solution not only is super ugly but I also think that it is burning gas unnecessarily because to get to Foo.zucchini, the EVM needs to walk through the entire Foo alphabet (there are a lot of enum values).
The elephant in the room is to use two Solidity mappings in my contracts. However, there are several problems with this:

I'd need to either duplicate the mapping everywhere, leading to an updating nightmare, or use inheritance simply for a contract knowing this mapping (seems really ugly).
This mapping would be part of the bytecode of all contracts of the project. Some of these contracts should be really small because they need to be deployed many times. Avoiding duplicated definitions is why I think that the mapping should be defined in a library.
I need to use the mapping in other libraries. Right now, this is not a problem because I can use library functions in other libraries. But if I misuse a contract as a library for my definition, I'd have to get that contract's address into the other libraries. The only way to do this I see is passing the contract's address to every library function that needs the mapping.

How can this problem be solved (somewhat) elegantly?


texts:
I am trying to experiment with ZoKrates library. When I use ./zokrates setup command, it warns me about gm16 malleability. So, I tried to change the proving scheme to gm17. But I keep getting the error "Backend gm17 not supported". Anyone faced this issue before? I am using MacOS. I see that gm17 requires libsnark. I checked in libsnark's github repo if they have instructions for activating libsnark in Mac. But, I don't see any instructions.

Thanks in advance for help.


texts: Does web3 soliditySha3 work with json object?

texts:
The above hash data is generated by web3 soliditySha3 with the objects below.

It seems the function generates hashes as I wanted; each object has different hash value. But I am not sure if it's working as I intended. In the official documentation page, and the function works with the object but really not sure about it. Can someone tell me about it?? Am I using it in right way? or should I compact the string values of each key and make the hashes based on it ??

let temp1 = {
    name: "sam smith",
    id: "tomato123123",
    timestamp: "2018/10/27"
}
let temp2 = {
    name: "sam smith",
    id: "apple123123",
    timestamp: "2018/10/22"
}


texts: Asymmetric encryption/decryption using ethereum public/private key

texts:
Is there any way to encrypt/decrypt data using web3js library(or any other standard tool), so that only user having access to public/private key can store and read data onto ethereum blockchain.

Scenario could be: A user stores sensitive information in encrypted file on IPFS and then using smart contract store encrypted hash of IPFS file onto blockchain, in future when he can access encrypted hash of IPFS file from blockchain using smart contract and view information.

In this scenario user has not remembered(stored) any thing except Ethereum private key.


texts:
I am trying to read a mapping inside my smart contract that looks like this:

mapping(address => User) public users;

My web3js code looks like this. I am trying to read mapping users inside the smart contract:

var contractAddress='0x3aacc70dced50f8c6c1951f27d505d2ad165b373';
var contractInstance = new web3.eth.Contract(abi,contractAddress);
contractInstance.users.call(web3.eth.accounts[0], function(err, result){
 if(!err){
    alert(result)
 }
 });

However I get the error like below:

TypeError: Cannot read property 'call' of undefined

Can someone help me resolve this


texts: How to Locate Private Key/JSON file of Account Created in Geth terminal

texts:
Software: Ubuntu on Virtual Box

I created test account in geth terminal (rinkeby network), i.e., but I am not finding keystore, or json file in

home\rinkeby\keystore

Please assist

can someone point me in the right direction


texts: If there is no transaction does blockchain size increases? If yes, why?

texts:
I have a private blockchain. Even though there is not much transactions going on, the chain's size keep increases. I observe that if there is not any transaction occurs still blockchain size increases, please note that I am not 100% sure.

For example, a block-chain started and there is no transaction occur for a week. In this time does the blockchain's size still get increases? If yes, what might be the reason, since state of the blockchain does not change at all.

Thank you for your valuable time and help.


texts:
I just started looking into the Ethash algorithm and I saw this:

s = sha3_512(header + nonce[::-1])

The thing is that here, nonce is an integer, and they used [::-1] to bitswap it from big endian to little endian? My question is what python version allows this? Every single one I tested gave me an __getitem__ not defined. As I also want to see in which version of python we can manipulate bits like this, I'm not searching for an alternative big to little endian conversion, I just want to know how did they get this working?

Also, in the algorithm, they say they combine header and nonce into a 64bit seed through this sha3_512 call. So how should header and nonce be? as hex string? integers? Should I convert nonce to an hex string so it can easily be added to header? This line lost me in their algorithm :/

Source : https://github.com/ethereum/wiki/wiki/Ethash


texts:
I'm simply trying to setup an event listener with web3 and metamask.

  incrementEvent = existingContract.events.Incremented(function(error, event){
                  if (error) console.log(error);
                  console.log("event is: ", event);
                })

Result:

Error: The current provider doesn't support subscriptions: MetamaskInpageProvider
    at Subscription.subscribe (bundle.js:45443)
    at Contract._on (bundle.js:48777)
    at (index):48
    at tryCatcher (bundle.js:44235)
    at Promise._settlePromiseFromHandler (bundle.js:42267)
    at Promise._settlePromise (bundle.js:42325)
    at Promise._settlePromise0 (bundle.js:42370)
    at Promise._settlePromises (bundle.js:42453)
    at bundle.js:39334
    at MutationObserver.<anonymous> (bundle.js:43502)
(index):50 event is: null

How do you listen to contract events with metamask?


texts:
I bought PAY tokens on etherdelta.github.io .  They show on Etherscan under the "Token Transfers" tab, but they do not show on Metamask. Metamask reports "No Tokens Found" on its Tokens tab.  I would like to send the tokens to my Myetherwallet, but am not able to do so because Metamask doesn't show I have tokens.

What am I misunderstanding?  Doing wrong?  How do I transfer tokens from Etherscan using Metamask??

Thanks in advance for your help!!!


texts: reject transaction in metamask from code after few minutes

texts:
Can anyone tell me if it is possible to reject transaction in metamask from javascript or java code after few minutes, if user didn't submit or reject it by himself?

The problem is that the user of my site can submit transaction to my smart-contract within 2-3 minutes.


texts: How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

texts:
Take an example of a voting DApp.  A user clicks on a vote button, then behind the scenes a transaction gets mined on the blockchain, and finally the DApp tells the user their vote has been recorded.

Now for some reason, there is a chain reorganization (maybe the user's node lost and regained network connectivity).

How can a DApp use web3.js to detect this, so that it can check if the user's transaction has been undone and if the user needs to submit their vote again?  Does web3.js fire an event to notify the DApp?  Are there any code snippets, such as what event to listen on and how?  Or are there any libraries with examples of their use?


texts: How to use already deployed erc20 token in another smart contract?

texts:
I have successfully created and deployed an ERC20 Token.
Now I would like to create a smart contract that takes the already deployed token from user to become user of system.

In simple words: what I want to build is, user needs to pay certain amount of that token upon registration. on user's side, when user registers, it will open Metamask for the user and user needs to complete the transaction in order to successfully register on our platform.

So I would like to call transfer token from user using new smart contract and tokens are transferred to my account

I am a beginner as far as solidity programming is concerned and would like to get help from you guys here. I searched for similar answers but found none to be successful.

I have tried doing this:

*

function setA_Signature(uint _val) public returns(bool success){
    bool ab = dc.call(bytes4(keccak256("transfer(address, uint256)")),0x05cd32f08CcB230bfEfAd6eb5d0A0b294076AcD5,_val);
    return ab;
}

Deployed(0x4a72b5BFA05A7022912FD441583D92b995782743).transfer(_to, _val);

*

That's the error when I try to test call the function of a contract using etherscan.


texts:
Tried out libraries for the first time, had a really bad experience with them. I need some help in getting my contracts to work between libraries.

Library 1:

pragma solidity ^0.4.0;

library IntExtended{

    function increment(uint _self) returns (uint){
        return _self+1;
}

    function decrement(uint _self) returns(uint){
        return _self-1;
}

    function incrementByValue(uint _self,uint _value) returns (uint){
        return _self + _value;
}

    function decrementByValue(uint _self,uint _value) returns (uint){
        return _self -_value;
}

    }

File that works with it, I don't know what you call it, second library?

pragma solidity ^0.4.0;

import "browser/Library.sol";

contract TestLibrary{
    using IntExtended for uint;

    function testIncrement(uint _base) returns (uint){
        return IntExtended.increment(_base);
}

    function testDecrement(uint _base) returns (uint){
        return IntExtended.decrement(_base);
}

    function testIncrementByValue(uint _base,uint _value) returns(uint){
        return _base.incrementByValue(_value);
}

    function testDecrementByValue(uint _base, uint _value) returns (uint){
        return _base.decrementByValue(_value);
}
}

The library IntExtended is not functioning, however, the contract referencing to IntExtended is functioning.


texts:
I use web3j to fetch information from ethereum blockchain,

public static void main(String[] args) throws InterruptedException {
    Web3j web = Web3j.build(new HttpService("http://10.9.59.138:18001"));
    Observable<EthBlock> observable = web.blockObservable(true);
    Subscription subscription = observable.subscribe(System.out::println);
    Thread.sleep(3000);
    subscription.unsubscribe();
    System.out.println("main say good bye.");
    // jvm not exit!
}

As mentioned in the official document, subscriptions should always be cancelled when no longer required. So I call unsubscribe(), but the JVM not exit.
How can I quit properly?


texts: value property from decoded txreceipt logs appending zeros

texts:
I wrote a program that scans all transaction for token transfers and logs the amounts transfered. I am using node package abi-decoder to decode the transaction receipt logs for this.
My question is, how can I parse the values (token amount) from the results, as some for example have a bunch of 0000000 at the end. Like USDT value of 23400000000000 is the result value from the logs, but the actual value transfered is just $234. Some times other tokens like MATIC have values of for example 200000000000000 even tho only 200 tokens had been transfered.
How can I parse this value property from the decoded logs, so that the value returned is the actual value without any appended zeros? Is there a unified way for this on all erc20 tokens?


texts:
I have installed MetaMask extension for Chrome, then I saw ext icon at top toolbar. To login I will open it by click on the icon. There is a question...

Is there a way to launch MetaMask window by JavaScript?
I want use my own Login button at web page to launch login screen.


texts: Why miners choose to verify the transactions of the incoming block?

texts:
I want to know whether miners can get rewards for verifying transactions in blocks broadcast by other nodes? If there is no reward, why would miners choose to verify transactions?
I am very confused about this. Hope you can give me some help, thanks!


texts: Accessing one smart contract contained in another smart contract from javascript

texts:
I'm cross-posting this from Stack Overflow, since there seems to be more activity here.

I am trying to develop a dApp with Truffle and want to test my smart contract. The contract contains a second contract within it, like so:

pragma solidity >=0.4.21 <0.6.0;

contract SubContract {
    uint public foo;

    constructor() public {
        foo = 0;
    }
}

contract MainContract {
    SubContract public my_contract;

    constructor() public {
        my_contract = new SubContract();
    }
}

I then want to test this contract in Javascript like so:

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

contract("MainContract", function(accounts) {

  it("initializes SubContract contract", function() {
    return MainContract.deployed().then(function(instance) {
      return instance.my_contract;
    }).then(function(subContractInstance) {
       return subContractInstance.foo();
    }).then(function(foo) {
      assert.equal(foo.toNumber(), 0);
    });
  });
});

If I then try to run this test as is, it tells me it cannot access member function foo() of undefined. If I change it from instance.my_contract to instance.my_contract() in the test, it tells me there is no function contract(), even though other fields are accessed through getter methods. What am I missing here to be able to access the SubContract instance?

---EDIT---

Per the suggestions, here's what a working test looks like:

var MainContract = artifacts.require("MainContract");
var SubContract  = artifacts.require("SubContract");

contract("MainContract", async accounts => {
  it("initializes SubContract contract", async() => {
    let instance = await MainContract.deployed();
    let subContractAddress = await instance.my_contract();
    let subContractInstance = await SubContract.at(subContractAddress);
    let foo = await subContractInstance.foo();
    assert.equal(foo.toNumber(), 0);
  });
});


texts: What does "third party liquidity" mean in blockchain technology?

texts:
In this what paper, it's mentioned that one of the reasons to use blockchain technology for the energy trading is:

  Provide 3rd party liquidity.

What does "third party liquidity" mean in blockchain technology ?


texts:
When I want to call MyContract's function like:
address payable owner = 0x12345.....;
function addHouse(uint _lease,uint _totalRent,uint _tenantNum)public{
            houseInfo[owner].push(House(owner,houseCount,_lease,_totalRent,_tenantNum));
            houseLandlord[houseCount] = owner;
            houseRent[houseCount] = _totalRent;
            houseCount++;
}

using the api of (methods.myMethod.send),
app.post("/addhouse_success",function(req,res){
    var lease = req.body.lease;
    var totalrent = req.body.totalrent;
    var tenantnum = req.body.tenantnum;
    MyContract.methods.addHouse(lease,totalrent,tenantnum).send({from: address},function(error,transactionHash){
        console.log('in function')
        if(!error){
            console.log('transactionHash:',transactionHash)
            res.send({msg:"ok",hash:transactionHash});
        }else{
            console.log('-------------error-----------')
            console.log(error)
            console.log('-------------error-----------')
        }
    });
})

but I get the error when using that api:
TypeError: Cannot read property 'length' of undefined
    at ABICoder.formatParam (/node_modules/web3-eth-abi/lib/index.js:224:30)
    at /node_modules/web3-eth-abi/lib/index.js:100:22
    at Array.map (<anonymous>)
    at ABICoder.encodeParameters (/node_modules/web3-eth-abi/lib/index.js:94:21)
    at /ode_modules/web3-eth-contract/lib/index.js:439:20
    at Array.map (<anonymous>)
    at Object._encodeMethodABI (/node_modules/web3-eth-contract/lib/index.js:438:8)
    at Object._processExecuteArguments (/node_modules/web3-eth-contract/lib/index.js:701:39)
    at Object._executeMethod (/node_modules/web3-eth-contract/lib/index.js:720:68)
    at /index.js:102:60
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at next (/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at /node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/node_modules/express/lib/router/index.js:335:12)

Is there anyone can help me solve this problem???
The question nagged me for days.
And the web3's version is 1.3.6


texts: I want to put lots of data into one transaction in private geth network. What is the max number which geth's targetgaslimit option can take?


texts: Checking balance of msg.sender before 'approve'

texts:
I analyzed this token contract on open-zepplin here : https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol

I wonder why there is not a statement in approve function which should check whether owner holds those tokens.


texts: Do you have to pay when browsing websites with Ethereum-enabled browsers?

texts:
When you're browsing Ethereum network using Ethereum-enabled browsers (such as Mist), do you have to constantly pay fees in order use it (a gas fee based on the usage)?

For example when I go to some Ethereum-based websites where Javascript is executing some contracts (Dapps) in the background (which I may or not aware of it), like the following sample code:

function get() {
    var param = document.getElementById('query').value;
    var res = contracts['Sample'].contract.get();
    document.getElementById('queryres').innerText = res;
}

function set() {
    var key = document.getElementById('key').value;
    var res = contracts['Sample'].contract.set(key);
}

does it mean that most of users browsing such websites have to pay (gas) fees for the its usage?

If so, what's the point or what are the benefits of browsing Ethereum network by constantly paying for it over the standard Internet where you can browse most of pages for free (where everything is executed at least locally, rather than on thousands of external nodes)? I may missing the point.


texts: Considering all NFTs are unique, are all erc 721 tokens collectibles? I'm asking this because on the Etherscan website some NFTs have the collectibles tag and some do not.


texts: How to preserve msg.sender==B when user A calls contract B which calls contract C which calls contract library D?

texts:
I have user A which calls contract B which calls contract C which calls contract D.
How to call external library D from contract C while preserving msg.sender==B ? Of course, I cannot use tx.origin since tx.origin is A.

User A created address of C and address of D, but not B.

DELEGATECALL isn’t the solution, isn’t it ?


texts: JSON RPC calls using Parity. Difference between Infura and Geth?

texts:
I began by trying to follow the article on front running bancor with Python.  I thought it would be easy to send an api request to my full   node then replicate the same request in Python--all following the tutorial.  The only difference was that the author used Geth and I am running Parity.  The inability to figure out how to use JSON RPC has led me down a rabbit hole.  I don't really know (1) what I'm doing wrong or (2) if I even conceptually understand JSON RPC at this point.

The problem:

I should be able to run this curl command: curl -X POST --data \
    '{"jsonrpc":"2.0","method":"eth_getTransactionByHash", \
    "params":["0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d"], \
    "id":123}' localhost:8545

And get a result like this:

{"jsonrpc":"2.0","id":123, "result":{
"blockHash":"0x42ea1578c23b159186853961dfbdfcdec6b40d23d8f1d971827412bc6948386b",
"blockNumber":"0x3dfb88",
"From":"0xcaf82fcb3a0323566c0f306684376e3e66d6284b",
"To":"0x77a77eca75445841875ebb67a33d0a97dc34d924",
"gasPrice":"0xba43b7400",
"hash":"0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d",
"value":"0x6c6b935b8bbd400000",
...}}

Howevever when I run it with localnode connected to parity I only get:

Supplied content type is not allowed. Content-Type: application/json is required

I found the Parity JSON-RPC API documentation and realized the formatting is different.

So I reformatted the curl command to look like this:

curl --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash",
"params":["0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d"], "id":1, "jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

I solved the Content Type error but then got a null result:

{"jsonrpc":"2.0","result":null,"id":1}

Then looking at this stack exchange article I realized that Parity has it's own Web3 console.  So, I thought maybe I don't have to use curl at all, and can just run.

web3.eth.getTransaction('0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d')

and I still get null return.

As a side note I have also tried to do the call using Infura's api

curl --include \
 --header "Content-Type: application/json" \
 --header "Accept: application/json" \

'https://api.infura.io/v1/jsonrpc/mainet/getTransaction?params=0x314e0246cfc55bc0882cbf165145c168834e99924e3ff7619ebd8290e713386d'

But am getting 404 return.

I really want to understand what I am doing wrong but I don't know where exactly to find the resources to teach myself, and feel a little stuck.  Thanks in advance for anything that can point me in the right direction.


texts: How to get notification right after account has received eth by geth?

texts:
My server stores many accounts.

How do i know when and what account has received eth or i have to check them manually one by one by looping many address to check the balance?

account := common.HexToAddress(address)
balance, err := client.BalanceAt(context.Background(), account, nil)


texts: cannot call internal function via `call`

texts:
I have a simple test contract:

pragma solidity ^0.4.8;

contract Test {
  uint public myVal;

  function callIt() {
      this.call.gas(50000)(bytes4(sha3("setMyVal(uint256)")), 123);
  }

  function setMyVal(uint _newVal) internal {
      myVal = _newVal;
  }
}

I am testing the contract in remix. It seems that I cannot call the setMyVal from callIt if setMyVal is set to internal - why? I am still calling it from within the same contract. Is the signature in that case different from bytes4(sha3("setMyVal(uint256)"))?

FYI: All works well when removing the internal keyword. But I would like to not allow these functions to be called from the outside. In case it matters: I am looking at using this pattern similar to function pointers, similarly as discussed before.


texts: Fine graininess of interface collisions between protocols

texts:
While working on integrating the Balancer Exchange protocol in my project, I noticed this interface defined in their exchange proxy:
interface TokenInterface {
    function balanceOf(address) external view returns (uint);
    function allowance(address, address) external view returns (uint);
    function approve(address, uint) external returns (bool);
    function transfer(address, uint) external returns (bool);
    function transferFrom(address, address, uint) external returns (bool);
    function deposit() external payable;
    function withdraw(uint) external;
}

This is almost an ERC-20 interface, but it has two custom functions, deposit and withdraw. The reason why these functions exist is out of scope for this question.
I want to call this function on the exchange proxy:
function smartSwapExactIn(
    TokenInterface tokenIn,
    TokenInterface tokenOut,
    uint256 totalAmountIn,
    uint256 minTotalAmountOut,
    uint256 nPools
) external payable returns (uint256 totalAmountOut);

But I would like to use a vanilla ERC-20 interface instead of this custom TokenInterface when writing my contract.
Here is the tricky part. Balancer has already deployed the exchange proxy at address 0x3E66B66Fd1d0b02fDa6C811Da9E0547970DB2f21. I will do the same thing with my own contract (deploy it at some point), and obviously the compiler won't complain because I used another interface instead of TokenInterface (it can't know what its eventual purpose is).
Will the the protocols "cross swords" when I attempt to call Balancer's smartSwapExactIn function via a contract that defines an interface that is slightly different to TokenInterface for the tokenIn and tokenOut arguments?


texts: Seed phrase of existing account in Metamask on different browser gave different address

texts:
I have Metamask installed on my browser on one machine, and I know the seed phrase of the account that it shows when I log in. Today, I installed Metamask browser extension on a different machine and entered the same seed phrase to import my existing account. However, the address shown is not the same, and so it does not show the tokens that I have in my account in the Metamask installed on my first machine.

FYI: Browser on both machines is latest Firefox version 61.0.2

The following question from 5/23/2018 seems to be a duplicate but it has no answer: metamask shows different address

Has anyone else been in this situation? What could be the reason?


texts: Design principles for a file sharing contract

texts:
I'm building a file sharing solution, which can benefit from the public ledger. I picture, that each file would have its own contract with an owner, and list of Addresses and their permissions on the file.

I'm building this Dapp using Truffle. I have studied the MetaCoin implementation, and while it is a single contract solution; I would like to believe that some applications like mine would require Contracts to be published in runtime. Please correct me if I am wrong.

From what I understand, Truffle compiles contracts and builds them once before the app starts serving. Is there a way to publish contracts on the fly, if Truffle isn't capable of this, what are my options; or am I wrong to dynamically publish contracts?


texts: How can you call Augur as an oracle from an Ethereum smart contract in Solidity?

texts:
The Augur FAQ states it possible to use it as an oracle:

http://blog.augur.net/faq-frequently-asked-questions/

“Will other contracts be able to query Augur outcomes?

Yes, Augur is actually 2 products that can be used alone. One is a prediction market, the other is an oracle. The results from the oracle service are publicly available, and anyone can pay what will likely amount to several dollars to have an official statement regarding the objective truth about a subject.”

However, the Augur API documentation doesn't seem to provide any information on how to call it from an Ethereum smart contract.

Is it already possible to call Augur as an oracle from an Ethereum smart contract in Solidity? How can you do it?


texts: Is it possible to achieve anonymous mixing through the Ethereum protocol?

texts: Are any developers working on anonymous mixing?  Is it achievable through the development of either smart contracts or dapps? Is information leakage reduced or eliminated?


texts: Global storage array - setting length on declaration vs inside a function

texts:
I have a global storage array of 64 entries, which I declare as follows:

uint256[64] globalArr;

However, its length really depends on a constant variable in my code:

uint8 constant MAX_VAL = 63;

If anyone wishes to change this value at some point in the future, then they need to change it also in the array declaration.

So ideally, I would like to declare them as follows:

uint8 constant MAX_VAL = 63;
uint256[MAX_VAL+1] globalArr;

However, the language does not support this type of declaration.

My alternative is to declare the array without length, and set it right before filling all the entries:

uint256[] globalArr;

function MyContract() // constructor
{
    globalArr.length = MAX_VAL+1;
    globalArr[0] = ...;
    globalArr[1] = ...;
    ...
    globalArr[63] = ...;
}

At this point, I should emphasize, that the array contents are computed separately, in a Python script which then auto generates the entire function. So the programmer needs not worry about changing these assignments as a result of changing MAX_VAL.

And I would just like to add the globalArr.length = MAX_VAL+1; to the Python script (of course, I can just let the script handle the uint256[64] globalArr; declaration, but this resides outside the function, and the script is essentially designated to auto-generate the function alone).

So my question is:

Is there any performance impact in using my desired coding structure:

uint256[] globalArr;

function MyContract() // constructor
{
    globalArr.length = MAX_VAL+1;
    ...
}

Over my current coding structure:

uint256[64] globalArr;

function MyContract() // constructor
{
    ...
}

Intuitively, I feel like my current coding structure is equivalent to a static allocation in C, while my desired coding structure is equivalent to a dynamic allocation in C. So I am wondering if this could potentially lead to any runtime impact of some sort.

Thank you very much!


texts: Gas and "Gas Used By Transaction" and how to get both values through json-rpc

texts:
On testnet I am analyzing the following transaction https://testnet.etherscan.io/tx/0x7b111a37998b25116b1a6962d393253bf09613dd083b420ec24ffc9a28bc74b6
having this attributes:

  Gas:  90000 and  Gas Used By Transaction: 21000

I guess 21000 is the actual fee applied to this tx, but what is Gas:    90000 then?

I am a bit confused because when querying this tx through json-rpc on my geth node using eth_getTransactionByHash method I got this result:

  gas => 0x15f90 = 90000

but there is no field gasUsed or similar. So it seems there is no way to find out actual tx fee, right?

How can I get gasUsed value for a tx using json-rpc calls?


texts:
I'm getting the following error while running a test in truffle:

  Error: Returned error: VM Exception while processing transaction: revert

Now, the code is simply to big and complicated to run through Stackoverflow.  So my question instead is,

-How can I debug this?
(more specifically: how can I get the VM logs and see exactly what is ducking up the test)

After a lot of trial and error I know exactly what function is misbehaving, I just don't know exactly what's misbehaving about it: here is the code in case it provides any clarity:

function onOCTReceived
(
 address operator,
 address from,
 uint256 amount,
 bytes calldata data
)
external
returns
(
 bytes4
)
{
    bobAndAlice(data);
    return (0x0);
}

important to note bobAndAlice(data) is working like a charm independently of the onOCTReceived() function so doubt the error is there, plus deleting it doesn't offer any more clarity on whats going on.

Edit: Additional testing shows that onOCTReceived() works perfectly fine in remix too.

Any pointers or help is very much appreciated.


texts: How to do Solidity percentage calculation?

texts:
I'm trying to calculate a percentage of a number in solidity with the following code.

The percentage is technically basis points (10000ths, instead of 100ths) because I want decimal percentage values.

uint128 is enough for expressing the normal numbers, but to try to avoid precision errors, I cast the values to int256 for the calculation.

pragma solidity 0.4.24;
contract PercentageCalc {
  uint128 public bp = 185; // 1.85% in basis points (parts per 10,000)

  function calculatePercentage(
    uint128 theNumber
  )
  public
  view
  returns (uint128) {
    return uint128(int256(theNumber) / int256(10000) * int256(bp));
  }
}

The problem is if I input 111111111111111111 as theNumber, the output is 2055555555555535 instead of the desired output of 2055555555555555 (what I get by doing the calculation with for example BigNumber.js).

I'm guessing it is some precision error I have overlooked. How do it get the desired output of 2055555555555555?


texts: web3js/nodejs error: eth.sendTransaction invalid address

texts:
I want to invoke a send transaction from my nodejs code using web3js api. But I'm getting error at eth.sendTransaction step: invalid address.
I have added default account assignment after looking at some other posts. But still the same error.
Any clue?

bcConn.eth.defaultAccount = bcConn.eth.accounts[0];
var defaultFlag = bcConn.personal.unlockAccount(bcConn.eth.accounts[0], '***whatever***', 15000);
if (defaultFlag) {

    var unlockFlag = bcConn.personal.unlockAccount(fromAddress, passphrase, 15000);
    if (unlockFlag) {

        **bcConn.eth.sendTransaction(fromAddress, toAddress, passphrase, sendAmount, function (err, result)** {
            if (err) return next(err, null);
            return next(null, result);
        });
    } else {
        console.log('DAO unlock error: ' +err);
        return next(err, null);
    }
}


texts:
I spent a couple of hours on upgrading web3 API to v0.15.3 in geth (on Mac OSX) with no effect. I installed the newest geth and it says:

web3.version
{
  api: "0.13.0",
  client: "Geth/v1.3.4/darwin/go1.6",
  ethereum: "63",
...

Which says that api is 0.13.0 (from Sep 2015) although geth is 1.3.4 (Feb 2016).

I tried to install the newest web3 0.15.3 with npm install web3
but it only creates a local directory node_modules with web3 and some more subdirectories.

To be honest, I completely do not know, what to do with that directory and how to tell geth that I have a new version of web3. Geth still says api: 0.13.0.

Could anyone give me a hint? How to update the web3 API version in geth?


texts: Using go, how to get the correct range of blocks

texts:
I have some eth wallet addresses, and I want to monitor the transfer information of these wallet addresses on some smart contracts.I use this function:
    query := ethereum.FilterQuery{
        FromBlock: ?, // I do not know what value should I set here, But I know this should not be `nil`, because i think i don't need to query event logs from genesis block, right?
        ToBlock: ? // Maybe I should set this to nil?Since I want to keep subscribing the recent logs of some contractAddresses, not a historical query.
        Addresses: contractAddresses,
    }
    logs := make(chan types.Log)
    sub, err := client.SubscribeFilterLogs(context.Background(), query, logs)


texts: How to determine using web3.py when this contract's tokens are unlocked? (contract code attached)

texts:
Currently the tokens of this contract are locked. I want to be able to figure out when the tokens of this contract have become transferrable in my python script. I'm using web3.py for this work.

Link to the contract: https://etherscan.io/address/0x971d048e737619884f2df75e31c7eb6412392328#code

There seems to be a transferLock argument inside the contract which stops the tokens from being transferred. There are also few others arguments and functions which seem to do a similar thing.

Can someone help me figure out how I can determine when the contract owner has unlocked the tokens?


texts: Ethereum multiple transactions is one transaction

texts:
i want to ask how / if its possible to create multiple transactions in one on ETH.
Let me explain details.
I have old eth address where i have some old tokens, but 0 eth. i think this address was compromised so i want to move all coins to new address.
But i want to make i all in one step. set up multiple coins outgoing transaction and send i only necessary eth for this transaction fee.
Is this possible in one step?
Thank you lot for any advices.
Or please let me know who can help me to do this.


texts: Are there UI-builders or automated UIs based on an ABI + contract address?

texts:
In order to demonstrate a contract, I want to use a generated UI, based on the ABI.

The contract runs on local network, or on one of the testnets.

Two options that I am aware of, and that work, but have downsides:

Remix can make a UI for the contract, in its right sidebar, and allows loading a contract from an address. It (appears to) build that UI from the ABI, extracted from the contract you have in your code-editor. It is an IDE, and so it is focused on development.
Mist can load a contract based on the ABI + contract address, but requires an application to be installed, configured and so forth.

Basically, I'm looking for something very alike the Mist-Contract feature, but then in a (simple) HTML/web3.js implementation; like Remix, but far simpler.

Requiring MetaMask is not a problem. And the UI should be workable, but does not need fancy UI designs or even customisation.

Being able to log the transactions and the emitted events is a pro.

Is there such a project, or site?


texts: Does every node execute contracts in Proof of Stake? If yes, why?

texts:
In Ethereum, for Proof of Work this sentence is true:

"Every single operation that is executed inside the EVM is actually simultaneously executed by every node in the network. This is why gas exists"

Is that true for Proof of Stake? I think yes is the answer as well. Then why is this needed for PofS?


texts: mapping the user's address with their account name

texts:
I'm trying to map the address with the account name, but with the find_user_name function in my contract, it keeps showing the Gas estimation failed while deploying the contract.
I have the struct user:

 struct user{
        string account;
        string password;
        address useraddress;
    }

and initialize the userlist

user[] public userlist;

then I write the find_user_name function to map to address with the account

 //return the user name by mapping the address
    function find_user_name(address _address) public view returns(string){
      uint256 i;
      string account_name;
      for(i=0; i < userlist.length; i++){//find the mapping user account name
            if(_address == userlist[i].useraddress)account_name = userlist[i].account;
      }

      return account_name;
    }

Is there anything wrong with my logic? Otherwise It sholud be okay when deploying the contract..


texts:
Is there any software apart from Geth and Mist that offers the Javascript console? I want to use the console but I don't want to do all that syncing.

Parity does not have a console as far as I know and neither does MetaMask. Any other software out there?


texts:
Imagine I have a contract that allows people to buy tokens.

After some time, only one token left, but two persons try to buy this token at nearly the exact same time from the same node (a web server).

What happens? Does the first person who ask it get the token and the second does not even if the block has not been mined yet?

Does the block needs to be mined so that the amount of token available in the contract is updated?

More generaly, where is the state of a contract saved between each block?


texts: Cannot access deployed smart contract on mainnet

texts:
I tested my contract code on the Ropsten test network and everything seemed to work fine. I was able to run all my scripts and call functions on the contract on Ropsten. I then proceeded to deploy to the mainnet and etherscan says the contract deployment was successful: Contract Etherscan link
However I am unable to access the contract or any of its functions and I keep getting this error:
Error: invalid hex string (argument="value", value="-0x02b4a8", code=INVALID_ARGUMENT, version=bytes/5.0.10)
at Logger.makeError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:205:28)
at Logger.throwError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:217:20)
at Logger.throwArgumentError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:221:21)
at hexStripZeros (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\bytes\src.ts\index.ts:296:16)
at Object.hexValue (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\bytes\src.ts\index.ts:287:21)
at C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:547:27
at Array.forEach ()
at Function.JsonRpcProvider.hexlifyTransaction (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:545:52)
at C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:186:60 {
reason: 'invalid hex string',
code: 'INVALID_ARGUMENT',
argument: 'value',
value: '-0x02b4a8'
}
Not really sure where the value is "-0x02b4a8" coming from. The code that calls the smart contract function is below:
const CEEU = (await bre.ethers.getContractFactory('CEEU')).connect(deployer)
const ceeuInstance = CEEU.attach(CEEUAddress)
await ceeuInstance.setMonetaryPolicy(PolicyAddress)

I know this code works because i tested on ropsten so i'm thinking that there is some mainnet config that i might be missing. but i'm relatively new to blockchain development so any help would be appreciated!
EDIT: The stack trace shows the error occuring in sendUncheckedTransaction function of json-rpc-provider.ts
sendUncheckedTransaction(transaction: Deferrable<TransactionRequest>): Promise<string> {
    transaction = shallowCopy(transaction);

    const fromAddress = this.getAddress().then((address) => {
        if (address) { address = address.toLowerCase(); }
        return address;
    });

    return resolveProperties({
        tx: resolveProperties(transaction),
        sender: fromAddress
    }).then(({ tx, sender }) => {
        if (tx.from != null) {
            if (tx.from.toLowerCase() !== sender) {
                logger.throwArgumentError("from address mismatch", "transaction", transaction);
            }
        } else {
            tx.from = sender;
        }

 // next line is where the stack trace show the error is coming from

        const hexTx = (<any>this.provider.constructor).hexlifyTransaction(tx, { from: true });

        return this.provider.send("eth_sendTransaction", [ hexTx ]).then((hash) => {
            return hash;
        }, (error) => {
            return checkError("sendTransaction", error, hexTx);
        });
    });
}


texts: Can I just change just 1 bit of data in a smart contract?

texts:
Can I just change 1 bit of data in a smart contract? More specifically would this allow me to make a smart contract where it is really cheap just to flip specific bits.

This would be like setting header flags in a IP packet. Initially I want to deploy a contact with a set of 1s and 0s then flip some later on. I want to just be-able to flip different bits in a contract that is as cheap as possible.

-Thanks


texts: Unexpected behavior with `block.timestamp` in truffle test

texts:
I am doing some experiments with block.timestamp(which is now's alias).
I wrote some code to see if block.timestamp really represents the timestamp of the last mined block.

From the documentation:

  block.timestamp (uint): current block timestamp as seconds since unix epoch

Below code is expected to return the timestamp of the last mined block(since it's just a call, not a transaction), but it seems to be returning the "current timestamp" which is unexpected.

(in solidity contract, tested with solidity v0.4.23):

function test() public view returns(uint, uint) {
    return (block.timestamp, block.number);
}

(in truffle js test case, tested with truffle v4.1.7):

it("test", async function () {
    for (let i = 0; i < 100; i++) {
        console.log(await contractInstance.test())
        await sleep(1000)
    }
})

Sample output with truffle test command:

[ { [String: '1524691464'] s: 1, e: 9, c: [ 1524691464 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]
[ { [String: '1524691465'] s: 1, e: 9, c: [ 1524691465 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]
[ { [String: '1524691466'] s: 1, e: 9, c: [ 1524691466 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]
[ { [String: '1524691467'] s: 1, e: 9, c: [ 1524691467 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]
[ { [String: '1524691468'] s: 1, e: 9, c: [ 1524691468 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]
[ { [String: '1524691469'] s: 1, e: 9, c: [ 1524691469 ] },
{ [String: '166'] s: 1, e: 2, c: [ 166 ] } ]

On the other hand, when I manually call the js function using the web3 interface in the browser(contractInstance.methods.test().call()), it works as expected.

Sample output:

p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}
p {0: "1524690793", 1: "157"}

So why is this? What's the catch when I call the function in truffle test? Any ideas?

Note: I've created a repo for this. If you would like to test, you can simply run truffle test after setting up local mining node(e.g.ganache).


texts:
Looking for a way to understand success (or failure) for ethereum transaction.

When we execute a contract method (send transaction) we receive it hash. Transaction is added to the block, block is added into chain and waiting for to be mind. It should be mined on one node and on others, success of failure would be clear after consensus stage.

The question is what is the proper way to wait for status of the transaction.

Here is a research on this topic

Polling
How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?

External lib
https://github.com/barkthins/ether-pudding/blob/master/index.js#L375

Consensus
What number of confirmations is considered secure in Ethereum?
(why they define 12 as a result of secure transaction? It should 51% of all nodes, isn't it?)

Usage of filter and why it is not right way to go
What's the proper way to wait for a transaction to be mined and get the results?
Waiting for a transaction to be confirmed