texts: Can't provide initial liquidity on PancakeSwap exchange using testnet

texts:
I have created a token on the bsc testnet, and have also created a liquidity pool. I am trying to provide initial liquidity but an error is shown whenever I try to do so.
The error message is below.\

code: -32603, message: "Internal JSON-RPC error." data: {
code: 32000, message: "gas required exceeds allowance (29885420) or always failing transaction" }

I have already called the 'initialise' method with the two tokens shown below, and have tried providing liquidity based on those two tokens, am I missing out on some steps?
I am using the pancake-swap-interface https://github.com/pancakeswap/pancake-swap-interface
For the tokens, I copied the token from https://github.com/goosedefi/goose-contracts/blob/master/contracts/EggToken.sol
My token address: 0xA6dE8E037201c6Ff9ff58e7fB72fE1Dbd15D1888
My psuedo BUSD address (copied from real BUSD): 0xA9bcCacD1D3f2EE7CA525f59c779F8c716965978
My LP token address: 0xb513219b46307eDDcaeFd1Aac99EB16394746B28
Thank you all, I know this isnt the correct place to ask questions about binance smart chain, but I do not know where to ask questions regarding bsc, so I am asking it here, if you guys could point me to where I can ask questions regarding bsc, I woudl really appreciate it. Also, I'm new to blockchain development hence if there are any resources on how to properly create a yield farming token, that would be great too, thanks all!


texts: Is there any way to fix my mistake when setting up a Multisig wallet?

texts:
So I am an idiot... I know. But feel free to tell me I am.
When I set up my Multisig wallet with gnosis I made a fatal error. I created a Rinkeby Test wallet. I did a test transaction and it all worked perfectly. And then when I was setting up my main net wallet I was copy and pasting addresses and copy and pasted the wrong one... I realized this blunder a month latter when me and the other owner were trying to withdraw 1ETH we have in the wallet. Turns out I made that Rinkeby Test multisig wallet as the other owner.... ugh....

So... The wallet stats are as follows:

Main net
2 owners total
1 owner = me
1 owner = a Multisig Rinkeby wallet
everything needs 2 confirmations.

I am assuming that it is lost forever. I tried added another owner, that also, obviously, required 2 confirmations. And since the other owner wallet address is the address of a contract on the Rinkeby network, I assume there is no way to talk to the Multisig wallet on the main net. My guess is there may be someone out there on the main net, that has the same wallet address, and they could theoretically confirm my transaction. But more likely no one has a wallet with that address. Is there any way to pick your wallet address? I would guess not, but I am trying to think of any possible way of getting at this money. Uhg... I am so ashamed of myself...


texts: Are there any tools to generate human-readable docs from Solidity source code?

texts: Solidity's got built in support for generating JSON from docstrings, which does the hard part of extracting machine-readable data to build developer reference documentation. Are there any tools to take this and generate nicely formatted HTML from it?


texts: How do I move tokens (OMG) from a contract wallet address to another wallet address?

texts:
Hello I know how to send my tokens from my normal wallet address using MyEtherWallet but I cannot figure out how to send tokens that I have on a contract address (in the same wallet) to another wallet address.

The tokens are OMG which I recently received from Omise.

I can see the tokens listed on my contract (on etherscan.io) but have no idea how to move them.

Can anyone give me step by step instructions? Thanks.


texts: Transfer of Ether from one party to another

texts:
I'm trying to transfer ETH from one account to another using web3j and a java program using following code.

public void transfer (String from, String to, BigInteger amount) throws InterruptedException, ExecutionException, IOException, CipherException{
     Credentials credentials1 = WalletUtils.loadCredentials(
            "mypassword",
            "path\\to\\keystore");

     EthGetTransactionCount ethGetTransactionCount = web3.ethGetTransactionCount(
             from, DefaultBlockParameterName.LATEST).sendAsync().get();

     BigInteger nonce = ethGetTransactionCount.getTransactionCount();
     System.out.println(nonce);

     RawTransaction rawTransaction = RawTransaction.createEtherTransaction (
             nonce, Convert.toWei("22", Convert.Unit.MWEI).toBigInteger(), Convert.toWei("44", Convert.Unit.GWEI).toBigInteger(), to, amount);
     byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials1);
     String hexValue = Numeric.toHexString(signedMessage);

     EthSendTransaction ethSendTransaction = web3.ethSendRawTransaction(hexValue).sendAsync().get();
     String transactionHash = ethSendTransaction.getTransactionHash();
}

But I cannot get it to work. Also the nonce doesn't change and keeps returning 44.

I am running it on the Ropsten test net.

Any thoughts?

Thanks,
Coen


texts: Error: gas required exceeds allowance or always failing transaction in Remix using Ropsten network

texts:
I am facing this error
, My Contract is quite simple

pragma solidity ^0.5.0;

contract sendEther {
  address payable sender;

  function showReceiver() public view returns (address payable) {
      return msg.sender;
  }

  function sendEtherToReceiver(address payable _receiver, uint256 _amount) public payable {
    _receiver.transfer(_amount * 10**18);
  }
}

Need help in fixing this, i am using MetaMask with ropsten test network
Below is attached screenshot and error too.


texts: How do I solve/get around this 'Gas estimation failed' error in my smart contract?

texts:
It appears after I compile, deploy the contract on remix (using Rinkeby test network), and call the JoinDXCon( ) method using any string "foo".

Here's the error:

And here's the smart contract:

pragma solidity ^0.4.24;

contract Home {

    address[] public deployedConferences;
    address[] public members;
    uint public totalMembers;

    event JoinedDXCon(address indexed memAddr, string name);

    function createConference(string _confName) public {
        address newConference = new Conference(_confName, msg.sender);
        deployedConferences.push(newConference);
    }

    function getDeployedConferences() public view returns(address[]) {
        return deployedConferences;
    }

    function joinDXCon(string _name) public {
        members[totalMembers] = msg.sender;
        totalMembers++;

        emit JoinedDXCon(msg.sender, _name);
    }
}


texts: What is the code for doing a crowdsale without a functional coin code?

texts:
How can i write a crowdsale code which will enable me to send all the users that backed the project only a private key and in 6 more month to send them their tokens .
what is the code for that?  the code in the site enable doing crowdsale only if the token code is set and ready..


texts:
when I develop my smart contract with solidity, I encounter a problem.
And Below is my solidity code.

pragma solidity ^0.4.0;

contract RegisterContract{

event setNewUser(bytes32 name,address etherAddr, address contractAddr,uint now);
address owner;
struct User{
    bytes32 name;
    address etherAddr;
    address contractAddr;
}
User[] private users;

constructor() public{
    owner = msg.sender;
}
modifier checkOwner(){
    require(msg.sender == owner);
    _;
}
function getOwner() public view returns (address){
    return owner;
}
// for a new user create a contract
function registerUser(bytes32 name,address etherAddr, address contractAddr) public checkOwner{
    User memory newUser;
    newUser.name = name;
    newUser.etherAddr = etherAddr;
    newUser.contractAddr = contractAddr;
    users.push(newUser);
    emit setNewUser(name,etherAddr,contractAddr,now);
}
//
function setAddress(bytes32 name,address etherAddr, address contractAddr) public checkOwner{
    for(uint8 i=0;i<users.length;i++){
        if(users[i].name==name){
            users[i].etherAddr=etherAddr;
            users[i].contractAddr=contractAddr;
        }
    }
}
// when systems assess all user
function getUsers() public checkOwner view returns (bytes32[],address[],address[]) {
    bytes32[] memory names= new bytes32[](users.length);
    address[] memory etherAddr = new address[](users.length);
    address[] memory contractAddr = new address[](users.length);
    for(uint8 i=0;i<users.length;i++){
        names[i]= users[i].name;
        etherAddr[i] = users[i].etherAddr;
        contractAddr[i] = users[i].contractAddr;
    }
    return (names,etherAddr,contractAddr);
}
//for a user who import contract
function getContractAddress(address etherAddr) public checkOwner view returns (bytes32,address) {
    for(uint8 i=0;i<users.length;i++){
        if(users[i].etherAddr==etherAddr){
            return (users[i].name,users[i].contractAddr);
        }
    }
}
}

The question is when I want to call registerUser and when I using web3.js calling registerContract.methods.registerUser(name,etheraddress,contractaddress) It throws an error on geth console. The error is

  Error: Transaction has been reverted by the EVM:
  {
    "blockHash": "0x45fe755c8c1f600108b55a12fa3bdf59dac0fe76d39883f23d15b2f9603d868d",
    "blockNumber": 22339,
    "contractAddress": null,
    "cumulativeGasUsed": 90000,
    "from": "0x5869c2317ce2df31cb1269d8028e9062ff470749",
    "gasUsed": 90000,
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "status": false,
    "to": "0xc249fa432a1c659e7aa4ad57e24e405215461afa",
    "transactionHash": "0xb52e0fabe160070597bd40192658b6f84779d52d4b295b39295d381eb0856f2d",
    "transactionIndex": 0,
    "events": {}
  }

Is it anything wrong when I addressed struct User and array push? Or there is any problems which I was unaware of at the time I developed?


texts:
Whenever i try web3.db.putString("user","name","jon_lobo") command from Geth console it throwsbelow error

  Error: The method db_putString does not exist/is not available
      at web3.js:3119:20
      at web3.js:6023:15
      at web3.js:4995:36
      at :1:1


texts: For example, I have 10 eth on my smart contract. How I send eth on another address?


texts: Can i compel miners to privilege my transaction by setting a high gas limit?

texts: I'm trying to send ether to a contract that has a fixed gas price, so I want to know if I can incentive miners to accept my transaction before someone else's by setting a high gas limit. Do miners work this way (ie. if there are two transactions to choose from, both doing the same thing for the same gas price, can they choose the higher gas limit one and make more eth by mining it?), or is the amount of gas used fixed based on the transaction data, opcode, etc.?


texts:
I am looking for an API service that allows my web app to generate Ethereum a deposit address, detect and notify a callback URL when a user sends ether to that address, and forward the funds to "cold" addresses.

Is there such a service out there? If not is there another way of programmatically detecting and forwarding deposits without running one's own Ethereum node?


texts: How can I complete a transaction without unlocking my account first?

texts:
I need to call a (state-changing) function on my contract.

Here is how I am currently executing this transaction:

let transaction = contract.methods.myFunc();
await web3.eth.personal.unlockAccount(ACCOUNT_ADDRESS, ACCOUNT_PASSWORD);
let gas = await transaction.estimateGas({from: ACCOUNT_ADDRESS, gasPrice: GAS_PRICE});
await transaction.send({from: ACCOUNT_ADDRESS, gasPrice: GAS_PRICE, gas: gas});

However, to my understanding, unlocking the account on my Ethereum client leaves a lot of security holes to deal with.

Is there any way for me to pass my credentials (account address and password) when I execute the transaction, instead of unlocking the account beforehand?

Documentation for unlockAccount is here.

Documentation for send is here.

Thank you very much!


texts: web3py: How to interact with deployed contract abi

texts:
I'm trying to interact with    a smart contract I deployed with truffle using web3py
 I can't figure out how to load the abi string into the web3py eth.contract function

contract = w3.eth.contract(address=contract_address, abi=...)

How do I load my ABI [ ] interface into the above function


texts: Is it possible to get the transaction count for a contract in Solidity?

texts: Is there built-in functionality for getting the transaction count (nonce) for an account in Solidity?


texts:
Why is the Rinkeby testnet only available when using geth and Kovan only available when using Parity?

Why is it not possible to connect to every testnet using every client? All clients can connect to the mainnet (Homestead), so why can't they connect to every testnet?


texts:
Goal: Sign in to the server with Metamask (done), import information to the server about NFTs from a wallet (not done) to our platform (trading platform similar to Opensea).
Problem: Metamask uses OpenSea to store NFT data
Docs ref
Possible solutions:

List NFTs on Opensea and query Opensea API (if possible) to fetch NFTs data;
Manually transfer NFT (ERC721) ownership from the wallet to our server and then sell it.

Is this correct or there is a better approach? Links to tutorials/articles will be very helpful too.


texts:
I have a smart contract that has a price (let's say it gets updated every hour).
The price is defined on some website. Using Chainlink oracles, is it possible to get the variable updated only when the price changes (i.e. have the oracle push the price to the contract)? Or can the price only be updated whenever the contract sends the request to the oracle (i.e. by calling sendChainlinkRequestTo)?


texts: Truffle deployment on test network says: Error: exceeds block gas limit

texts:
I'm trying to deploy a sample contract (following this guide) but I'm receiving an error of not enough gas. I changed the numbers a little but could not fix it. I saw this question in stack exchange but there are few things I don't understand in the answer suggested there:

What does it mean to modify the genesis block as follows?

  "You can modify your genesis block to have a gas limit of 0x2fefd8
  which is the same as the main network (3,141,592 gas). You will also need to reset that test chain since you'll be changing the genesis block."

In the js files I print below there are two "gas" parameters: one in 2_deploy_contracts.js and the other in truffle.js. What each of them means (how do they affect the deployment of a contract)? Are there any other places that relate to amount of gas issues?

My error and file contents:

~/voting$ truffle deploy
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: exceeds block gas limit
    at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:37022:16)
    at /usr/lib/node_modules/truffle/build/cli.bundled.js:209743:36
    at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:208522:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:210395:18)
    at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:210685:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:210840:12)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/truffle/build/cli.bundled.js:210800:24)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)

migrations/1_initial_migration.js

var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
  deployer.deploy(Migrations);
};

migrations/2_deploy_contracts.js

var Voting = artifacts.require("./Voting.sol");
module.exports = function(deployer) {
  deployer.deploy(Voting, ['Rama', 'Nick', 'Jose'], {gas: 5000000});
};

truffle.js
    require('babel-register')

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*', // Match any network id
      // gas:400000000000,
      gas:1000258612000000000,
      from: "0xf212bb926f7a831ff745e4236fc704a9947de77c"
    }
  }
}


texts: Reusing Ethereum deployed smart contracts

texts: I have developed and deployed my token and stacking contracts on the ethereum main net, now I want to deploy them on the Binance Smart Chain(BSC), my question is Do I need to modify my current written smart contracts or I can just use the same smart contracts and just deploy them on the BSC.


texts: Web3.js function(s) to help determine the block numbers inside a date range?

texts:
I just learned today that you can query past events using the Web3.js 1.0.0 getPastEvents() function.  That function supports filtering via the fromBlock and toBlock call parameters, so you can limit your query to a specific range of blocks:

getPastEvents("something", { fromBlock: 0, toBlock: "latest" }

Are there functions in Web3.js that can help you determine the from and to block numbers needed to cover a desired date range when calling getPastEvents()?  Or is there another method/technique that works directly with dates instead of block numbers when querying for events that you can use instead of getPastEvents()?


texts: Whisper Protocol: How could I use already generated keyPair or symKey after geth is restarted? Key pair cannot be stored //Error: non-existent key ID

texts:
My goal is to send a message from one ethereum node to another one by using same public key of the receiver. In order to accomplish it, I have followed this guide that uses Whisper Protocol. But after geth on receiver is restarted its keyPair is lost and it says Error: invalid id for it when I tried to use it again.

Please note that Whisper Protocol Overview is out of date and shh.newIdentity() function does not exists anymore.

In summary approach I followed from the linked answer above that successfully works within the geth session:

On the receiver node:

> kId = web3.shh.newKeyPair(); //"d4a2504d22955f20156c75bfce5c7f273865f7d8976de5eed3a48a103e4e6d2d"
> web3.shh.hasKeyPair(kId) //true
> web3.shh.newMessageFilter(
    {privateKeyID:kId},
    function(err, res) {console.log(web3.toUtf8(res.payload))});
> web3.shh.getPublicKey(kId) //returns PUBLIC_KEY_OF_THE_RECEIVER

> stored_kId = web3.shh.addPrivateKey(shh.getPrivateKey(kId)); //"b8a8344ae7010b8453e47c31d5cb99edbc7adce5ae3fe8ece2ee90dd0bcf446c"
> web3.shh.hasKeyPair(stored_kId) //true

On the sender node:

web3.shh.post({
  pubKey: 'PUBLIC_KEY_OF_THE_RECEIVER',
  ttl: 7, //Time-to-live in seconds (7 seconds).
  topic: '0x07678231',
  powTarget: 2.01,
  powTime: 2,
  payload: web3.fromAscii("Hello there!")
  });

The problem I am facing is when I restart the geth on the receiver node; I cannot reuse the kId(web3.shh.newKeyPair()) that is already created on the receiver before geth is restarted. So I need to regenerate shh.newKeyPair() and share its public key with the sender all over again (which seems inefficient).

The error I am receiving after geth is restarted.

> kId ="d4a2504d22955f20156c75bfce5c7f273865f7d8976de5eed3a48a103e4e6d2d" //web3.shh.newKeyPair() that is created before geth is restarted.
> web3.shh.getPublicKey(kId)
Error: invalid id
> web3.shh.hasKeyPair(kId) //false

So I have to create newKeyPair() all over again and share its public key with the sender.

This creates additional issue where, if receiver's geth node is restarted, sender's messages will not be received on receiver's end and sender will need to resent those messages into receiver with receiver's newly created public key all over again.

Please note that I observe similar issue on newSymKey().

Example:

> shh.newSymKey()
"2d97351f0c7394679c70472b9b3a2abf3a22b6cdc9815574b103b92e1f1bfde1"
> shh.getSymKey("2d97351f0c7394679c70472b9b3a2abf3a22b6cdc9815574b103b92e1f1bfde1")
"0x1edddb4ec019ce0f31e8a4a381c9b436476b547317d9508ce9dac1fb146a65f0"

restart the geth node and I tried to getSymKey(). with already generated symKey:

> shh.getSymKey("2d97351f0c7394679c70472b9b3a2abf3a22b6cdc9815574b103b92e1f1bfde1")
Error: non-existent key ID

More depth analysis:

From: Whisper v5 RPC API

shh_addPrivateKey

Stores the key pair, and returns its ID.

Parameters

String: private key as HEX bytes.
Returns

String: Key ID on success and an error on failure.

I have also tried shh_addPrivateKey to store the key pair. But after geth is restarted it seems like store key pair also lost and I cannot restore it.

Following line is used as the last line on the receiver node.

> shh.addPrivateKey(shh.getPrivateKey(kId))
"b8a8344ae7010b8453e47c31d5cb99edbc7adce5ae3fe8ece2ee90dd0bcf446c"

After geth is restarted still I cannot restore the keys with already added private-key's Key ID:

> kId='b8a8344ae7010b8453e47c31d5cb99edbc7adce5ae3fe8ece2ee90dd0bcf446c'
> shh.getPublicKey(kId)
Error: invalid id
> web3.shh.hasKeyPair(kId) //false

[Q] How could I handle this issue, where restoring already generated key pair (shh.newKeyPair() or shh.newSymKey()) after geth is restarted?


texts: Why cannot catch events retrospectively using filter (eth_newFilter)?

texts:
I've put the same filter with eth_newFilter before and after a set of transactions. The one which is installed after transactions catched 0 events. Is it how events work? Is there any other way to catch events retrospectively except eth_getLogs?

from ethjsonrpc import EthJsonRpc
c = EthJsonRpc('127.0.0.1', 8545)
ADDRESS = "0xdb1154368ba2645e6c090f3d1f3ddd5c8c1f8008"
params = {
    "fromBlock": "0x01",
    "address": ADDRESS
}
before = c.eth_newFilter(params)
for i in range(100):
    tx = c.call_with_transaction(c.eth_coinbase(), ADDRESS, 'setValue(uint32)', [i])
    receipt = c.eth_getTransactionReceipt(tx)
after = c.eth_newFilter(params)

print len(c.eth_getFilterLogs(before)) // 100
print len(c.eth_getFilterLogs(after)) // 0
print len(c.eth_getLogs(params)) // 100

I'm using testrpc as blockchain client.


texts: How does the private key generated in Whisper to decrypt the message

texts:
I am using Whisper private network to post the message and get the message. It is working fine.

I analysed the process and found that there is no private key is generated.

I have seen that the public key (x,y,curve) is generated based on the To address. Message is encrypted using this and sent.

I am not clear how the private key is generated at the receiver side to decrypt the message. I found that no additional inputs are given to decrypt other than the sealed envelope.

Can any one help me or correct me in the above.


texts:
I'm trying to find a better data type for storing SHA256 hash, right now I'm using string, and I'm thinking of switching to byte32 but considering it I don't know if this is really a step in the right direction.  Is there a better data type for storing a sha256 hash?
This sha hash is not generated by sha256() so there is not a 0x prefix already affixed to it which is why I am concerned about adding those extra bytes instead of just leaving it as a string


texts: How can I call the contract constructor and send a funding value when deploying with MyEtherWallet?

texts: This option doesn't seem to be available on MyEtherWallet. Are constructors unsupported?


texts:
There's a related question here ERC721: Interface ID Registration but I couldn't get the answer I need from there.

In the OpenZeppelin ERC721 basic implementation, there's this part:

 // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

    constructor (string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

_INTERFACE_ID_ERC721, _INTERFACE_ID_ERC721_METADATA, and _INTERFACE_ID_ERC721_ENUMERABLE are seem to be calculated (based on comments), but I'm not quite sure when this calculation needs to happen, and how?


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

texts:
Working on this Udemy course for Ethereum and i keep getting the error mentioned in the title of the question.

For reference i have checked out the answers on questions: 1, 2 and 3. But the error persists.

The contract goes like this:

pragma solidity >=0.4.22 <0.6.0;

contract Lottery {
    address public manager;
    address[] public players;

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

    function enter() public payable {
        require(msg.value > .01 ether);

        players.push(msg.sender);
    }

    function random() private view returns (uint) {
        return uint(keccak256(abi.encodePacked(msg.sender, now, players)));
    }

    function pickWinner() public {
        uint index = random() % players.length;
        players[index].transfer(address(this).balance); // Where the error happens
    }
}

Using Remix Solidity compiler.

I am pretty sure this is some old version code error since the Solidity version used in the course is ^0.4. Can anyone guide me what am I missing here?


texts: Can not get a value by calling method from another Contract

texts:
I have created two Contract to separate out storage and validation rules.

ValidationService.sol

pragma solidity ^0.4.16;
import "./Storage.sol";

contract ValidationService {

Storage public store;

 constructor(address add) public{
    store=Storage(add);
 }

 function getMyNumber() public constant returns (uint) {

     return store.getNumber();

 }

}

Storage.sol

pragma solidity ^0.4.16;

contract Storage {

uint public mynum = 5;

  function getNumber() public constant returns (uint) {
    return mynum;
  }

 }

I have called getMyNumber method which called getNumber method of Storage contract and it should return 5 as a output.

validationservice.getMyNumber.call()

The above code is working fine in remix and truffle development environment but it is not working in private blockhain network using Geth.

If i call getNumber method of Storage contract directly from geth console, It's working fine.

Can anyone please guide where is my mistake


texts: Send web3js event to webhook when it happens

texts:
I have a transfer method that transfers a token using the deployed smart contract in Web3JS.
I have to return the values to the customer, so I subscribe to the transfer event and wait for it to broadcast to return the data.
The problem is that this might take a long time and it gives me a timeout sometimes, so the frontend team suggested to inform me a webhook endpoint and I forward the event information to it when it happens.
So I have to split the process into two:

Do the transfer and inform the txHash, and start a separate process (2) that listens for the event.

Subscribe to the event and, when it happens, forward it to the webhook provided.

My code right now looks something like this:
function transfer(req, res, next) {

    try {

            contractRouter.transfer(from, to, tokenId).then(function(result){
                transferToWebhook(whHostname, whPath, result);
                next();
            }).fail(function(err){
                return res.status(500).json({status: 'error', name: err.name, message: err.message});
    }
    catch (ex) {
        return res.status(500).json({status: 'error', name: ex.name, message: ex.message});
    }
}

and the function that transfers to webhook looks like this:
function transferToWebhook(whHostname, whPath, txHash){
    contractRouter.getTransferEvent(txHash).then(function(result){

        var postData = JSON.stringify(result);
        var options = {
            hostname: whHostname,
            port: 80,
            path: whPath,
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            }
        }
            var req = https.request(options, (res) => {
              console.log(`STATUS: ${res.statusCode}`);
              console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
              res.setEncoding('utf8');
              res.on('data', (chunk) => {
                console.log(`BODY: ${chunk}`);
              });
              res.on('end', () => {
                console.log('No more data in response.');
              });
            });

            req.on('error', (e) => {
              console.log(`problem with request: ${e.message}`);
            });

            req.write(postData);
            req.end();
    });
}

The function that subscribes to the transfer event looks like this:
function getTransferEvent(txHash){
    var deferred = q.defer();

    ethereumHandler.setContract(config.get(cABIAddress), cAddress).then(function(abiContract){

        Promise.resolve(txHash).then(function resolver(txHash){

            abiContract.getPastEvents('Transfer',{filter: {transactionHash: txHash}}, function(error, events){})
            .then(function(event){
                var returnValues = {
                    from: event.returnValues.from,
                    to: event.returnValues.to,
                    tokenId: event.returnValues.tokenId
                }
                deferred.resolve(returnValues);
            });
        });

    return deferred.promise;
    });
}

The code for the last function works if I put it straight on the transfer function, but it's not called if I try to call it through the webhook.
How can I launch the transferToWebhook function after having answered the first request?


texts: ExecutionFailure in MultiSigWallet contract

texts:
I wanted to test a simple use case of MultiSig wallet. To do that I've deployed gnois MultiSigWallet.sol to Rinkeby network.

Before testing the multisig functionality I wanted to deposit 0.1 ether to the contract so I invoked the fallback function with value of 100000000000000000 (which is 0.1 eth in wei).

/// @dev Fallback function allows to deposit ether.
function()
    payable
    public
{
    if (msg.value > 0)
        emit Deposit(msg.sender, msg.value);
}

The transaction succeeds but no ether is transferred to the contract nor I see the expected Deposit event in etherscan.

What am I doing wrong? How do I deposit ether to my contract?
BTW - the account I'm using to deposit has a positive balance of 3.85 eth.


texts: I am new to ETH and started mining on the testnet. Right now my balance shows 1100. Is this like "play" money or have I actually mined that much ETH?


texts: How to create Wallet for Private Blockchain Network?

texts: I am creating private block chain network on AWS. Can I use existing block chain wallets like MyEth wallet with Private network?


texts:
pragma solidity ^0.4.18;

contract TransferFunds{
    address owner;
    mapping (address => uint) public balances;

    event Sent(address from, address to, uint amount);

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

I used the following code as a program to transfer funds. I am running the code in Remix with the default JavaScript VM. I created the contract and then called the send function with the following arguments - "0x14723a09acff6d2a60dcdf7aa4aff308fddc160c",1

I can see some changes in the ether balance, but haven't been able to sort what the change is.

Meanwhile, when I am trying to check the balance of the account, it returns zero. I found that even msg.sender is 0x. Can you please help me figure out the problem. Please find the logs below.

    Contract getting created -
 status     0x1 Transaction mined and execution succeed
 contractAddress    0x692a70d2e424a56d2c6c27aa97d1a86395877b3a
 from   0xca35b7d915458ef540ade6068dfe2f44e8fa733c
 to     TransferFunds.(constructor)

send getting calls -
status  0x1 Transaction mined and execution succeed
 from   0x14723a09acff6d2a60dcdf7aa4aff308fddc160c
 to     TransferFunds.send(address,uint256) 0x692a70d2e424a56d2c6c27aa97d1a86395877b3a


texts: Greeter variables are all undefined and contract doesn't run

texts:
I'm attempting to run the greeter contract on the live network. I'm following the commands as per the official tutorial, which worked on a test network when I tried it a while ago (on a different machine).

On entering the commands I'm getting an undefined response, though all variables are correctly defined when manually called on the console.

On entering the final var greeter, I'm correctly prompted for the passphrase of the account being used, which seems to go through. However, the pasted script itself doesn't seem to be called - there's no console log output.

Any ideas what I've missed out?

[Note: There's plenty of ether in the account being used.]

[Note2: The console has truncated long lines in the below log. I've confirmed they copied correctly.]

> {g) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'
undefined
>
> var greeterCompiled = web3.eth.compile.solidity(greeterSource)
undefined
> var _greeting = "Reason has always existed, but not always in a reasonable form."
undefined
> var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);
undefined
> {,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.code, gas: 1000000}, function(e, contract){
         if(!e) {

               if(!contract.address) {
               {saction send: TransactionHash: " + contract.transactionHash + " waiting to be mined  .");

                   } else {
                     console.log("Contract mined! Address: " + contract.address);
                     console.log(contract);
                   }

             }
       })
Please unlock account <account_address_removed>.
Passphrase:
Account is now unlocked for this session.
undefined


texts: How to apply pyethrecover.py on v3 .json/transfor v3 .json to .v1

texts:
I'm trying to get pyethrecover.py running via Python on one of my .json files that were created by Ethereum-wallet for Mac. It seems that my .json file is v3 and the pyethrecover.py only works for v1 files (the pyethrecover.py looks for 'encseed and 'ethaddr' that isn't available on v3 versions of .json files).

Is there a way to transfer v3 files into v1 files (without having to input the password) or another way to brute force my .json file were I've forgetting my exact password on? Or maybe alter my v3 .json file to help the pyethrecover.py working on it?

I've already email ethereal.org with my issue, but no response.

Hope you can help me!


texts: Can state in a smart contract be immutable

texts:
My question is referring to immutability of smart contract data.

If I make a function in smart contract and write a conditional such that if a key of a map already exists jump out of the function and don't add it to the map.

i.e.

library Library {
  struct data {
     uint val;
     bool isValue;
   }
}

contract Array{
    using Library for Library.data;
    mapping(address => Library.data) map;
    function addCluster(address id) {
        if(map[id].isValue) throw; // duplicate key
        // else insert a key value pair
    }
}

Is this state then immutable?

I've heard that if majority consensus of a private network agrees then they can reverse or 'roll back' already mined transactions and blocks. As stated in this article under the private blockchain section https://www.multichain.com/blog/2017/05/blockchain-immutability-myth/.

I'm trying to understand what happens consensus of a private network decide to roll back to a particular block before that transaction had been mined, will that key/value pair (state) be deleted?
Thus asking can state be immutable if it was programmed to in the contract.


texts: Why this ERC20 "stealing" transaction is valid?

texts:
I'm sending a token from account A to B. The account who issues transaction is C. Surprisingly, the transaction is valid and works fine. Why?

This means that I, being the transaction issuer, can make arbitrary account A give tokens to arbitrary account B? Does this not mean that I can literally steal tokens this way, given B is some other address of mine.

I'm pretty sure I'm missing some fundamental thing here.

The JSON RPC payload to depict the question is this:

{
  "jsonrpc": "2.0",
  "method": "eth_sendTransaction",
  "params": [
    {
      "to": "0x5928ead021bd523e6d3531de920d78b7a02efa60",
      "from": "0xef2b050377007e45ba43d9c2bf0d7acc2039c112",
      "data": "0x23b872dd000000000000000000000000d8e05701eFf33acfDA0A8e24C04070347703c72C000000000000000000000000ad9c9b5085bec8e8013296dc12bd9cecad102356000000000000000000000000000000000000000000000000000000005a9187bf",
      "gas": "0x3d0900",
      "gasPrice": "0x51f4d5c00"
    }
  ],
  "id": 1
}

The transaction happened on a ropsten network, and can be seen here: https://ropsten.etherscan.io/tx/0x3a1d9800565e93a7ff0e85958dcf49a9e7752d099f4b061598e8b73f1e453814

Here:

0x5928ead021bd523e6d3531de920d78b7a02efa60 – contract address,
0xef2b050377007e45ba43d9c2bf0d7acc2039c112 – transaction issuer (the one who will pay the transaction fee),
0xd8e05701eFf33acfDA0A8e24C04070347703c72C – user A, actually, contract creator who holds all the tokens; the one whos tokens are being stolen,
0xad9c9b5085bec8e8013296dc12bd9cecad102356 – user B, the one who is being gifted some tokens.

How come this transaction is valid?


texts:
how can we generate a unique funds deposit address for each investor who registers for ico. These days it is being done by many icos to prevent hacking.

This maybe very simple but I’m a newbie and still learning and was not able to find much :)


texts: How to get balanceOf of a deployed ERC20 contract using web3j?

texts:
I'm new to Ethereum and I got stuck on trying to call balanceOf on a deployed ERC20 contract.

Here is the code I have so far:

    Web3j web3j = Web3j.build(new HttpService());

    RemoteCall<BigInteger> customerBalance;
    Function function = new Function(
            "balanceOf",
            Arrays.asList(new Address(<address_of_the_account>,
            new ArrayList<>());
    String encodedFunction = FunctionEncoder.encode(function);
    org.web3j.protocol.core.methods.response.EthCall response = web3j.ethCall(
            Transaction.createEthCallTransaction(<not_sure_what_the _FROM_address_is>, <not_sure_what_the_TO_address_is>, encodedFunction),
            DefaultBlockParameterName.LATEST)
            .sendAsync().get();

    List<Type> result = FunctionReturnDecoder.decode(
            response.getValue(), function.getOutputParameters());

In the documentation (https://docs.web3j.io/transactions.html#querying-the-state-of-a-smart-contract) has a different signature (Transaction.createEthCallTransaction(contractAddress, encodedFunction), but that doesn't compile.

I'm on the 3.1.1 version of web3j (latest). I don't know what the to and from addresses are (in the documentation there's just one address which I assume is the deployed contract's address).


texts: If using 'now' or 'block.timestamp' is considering security risks (miner manipulation) how should I go about current timestamp in my code? Isn't it safe to use either of the two as long as it is not used for randomness?


texts: How can I automate smart contract interaction

texts:
I've deployed a smart contract to the blockchain with few functions.
I want to know how I can interact with the code e.g. > Contract has 2 functions - deposit and withdraw. Now, instead of me depositing and withdarwing 100 times manually, how can I write code which calls those functions automatically for me?
Let's say the code creates news Ether wallet, sends Ethereum to that wallet, then, from that wallet deposits the funds and withdraws it, then creates new wallet and repeat.


texts: How to keep running multiple geth nodes running on multiple VMs continously?

texts: I have 50 VMs and I installed geth on every VM. Now I need to run geth on each VM by doing ssh on each VM. So, I am facing one problem with this when I start a geth node on VM by ssh it starts at that time but, when I come out of ssh it stops. How should I keep the geth process running on VM continously even if I come out of ssh from that VM?


texts: Unused variables warning in address.call return tuple (bool, bytes memory)

texts:
I have the following code fragment.

function forward(address destination, bytes memory data) public {
    (bool res, bytes memory retData) = destination.call(data);
    assert(res);
}

Since retData is not used, I am getting the following warning (compiled with solidity 0.5.0):

Compilation warnings encountered:

/Users/ivica/Documents/deka/hekate.reloaded/digits-node/contracts/IdentityProxy.sol:55:20:
Warning: Unused local variable.
        (bool res, bytes memory retData) = destination.call(data);
                   ^------------------^

Question: how to get rid of it?


texts: Solidity TypeError: uint256 not implicitly convertible to uint256[] memory

texts:
Thus far I've RTFM'd the Data Location docs, and tried this solution, to no avail.

The full code of the contract looks like this:

pragma solidity ^0.4.13;

contract People {

    Person[] public people;

    struct Person {
        bytes32 firstName;
        bytes32 lastName;
        uint age;
    }

    function addPerson(bytes32 _firstName, bytes32 _lastName, uint _age) returns (bool success) {

        Person memory newPerson;
        newPerson.firstName = _firstName;
        newPerson.lastName = _lastName;
        newPerson.age = _age;

        people.push(newPerson);
        return true;

    }

    function getPeople() constant returns (bytes32[],bytes32[],uint[]) {

        uint length = people.length;

        bytes32[] memory firstNames = new bytes32[](length);
        bytes32[] memory lastNames = new bytes32[](length);
        uint[] memory ages = new uint[](length);

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

            // what does <<memory>> do in Solidity?
            Person memory currentPerson;

            currentPerson = people[i];

            firstNames = currentPerson.firstName;
            lastNames = currentPerson.lastName;
            ages = currentPerson.age;
        }

        return (firstNames, lastNames, ages);

    }

}

When I try to compile it with truffle compile --all I get the following error:

Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/People.sol...

/Users/s.matthew.english/ConsenSys/PegaSys/smart_contracts/peopleList/0.0_peopleList/contracts/People.sol:40:26: TypeError: Type bytes32 is not implicitly convertible to expected type bytes32[] memory.
        firstNames = currentPerson.firstName;
                     ^---------------------^
,/Users/s.matthew.english/ConsenSys/PegaSys/smart_contracts/peopleList/0.0_peopleList/contracts/People.sol:41:25: TypeError: Type bytes32 is not implicitly convertible to expected type bytes32[] memory.
        lastNames = currentPerson.lastName;
                    ^--------------------^
,/Users/s.matthew.english/ConsenSys/PegaSys/smart_contracts/peopleList/0.0_peopleList/contracts/People.sol:42:20: TypeError: Type uint256 is not implicitly convertible to expected type uint256[] memory.
        ages = currentPerson.age;
               ^---------------^
Compiliation failed. See above.

So it has to do with this assignment apparently:

        firstNames = currentPerson.firstName;
        lastNames = currentPerson.lastName;
        ages = currentPerson.age;

What's wrong with that?

To provide some context, writing this contract is part of completing this tutorial, specifically the contract at ~20:26.


texts:
I would like to create a simple smart contract between me and a couple of friends (basically, I'm putting money on the line and betting them that I will do something that they don't think I'll do.)

We want to write a simple (arbitration bound) smart contract that will allow us to put ether (or whatever, not bound to ether if someone knows a better platform) into 'escrow' so that we can bet on the outcome and then deliver the funds (we've had problems with people not paying afterwards because they 'weren't serious' about the bet, this would make them be serious).

Any recommendations for apps/dapps/platforms/annoyingly complicated solidity scripts that could do this for me?


texts: Unable to get response back from chainlink node using truffle console

texts:
I am trying to fetch close prices of a property deployed on a server running on a chainlink node. Here's what a snippet from my contract (RealEstateAPIConsumer.sol) looks like :
function returnClosePrice(string memory _name) public {
    Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.myCallback.selector);
    request.add("name", _name);
    request.add("copyPath", "closePrice");
    receipts[sendChainlinkRequestTo(oracle, request, fee)] = stringToBytes32(_name);
}

function myCallback(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId){
    tokenHash = receipts[_requestId];
    delete receipts[_requestId];
    currentRealEstatePrice[tokenHash] = _price;
    latestRequestId = _requestId;
    price = _price;
}

The contract on etherscan
The contract is deployed on a kovan infura node. When I invoke the truffle console with:
await instance.returnClosePrice("Mannat")

my terminal becomes unresponsive and there's no response coming from the node.
Here's what my migration file looks like:
var RealEstateAPIConsumer = artifacts.require('RealEstateAPIConsumer')
module.exports = function(deployer){
  deployer.deploy(RealEstateAPIConsumer)
}

Here's what my truffle-config looks like:
require('dotenv').config()
const HDWalletProvider = require('@truffle/hdwallet-provider');
const kovanUrl = process.env.KOVAN_URL;
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
const NonceTrackerSubprovider = require("web3-provider-engine/subproviders/nonce-tracker")

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 7545,
      network_id: "5777"
    },
    kovan: {
      provider: function() {
        var wallet = new HDWalletProvider(mnemonic, kovanUrl);
        var nonceTracker = new NonceTrackerSubprovider()
        wallet.engine._providers.unshift(nonceTracker)
        nonceTracker.setEngine(wallet.engine)
        return wallet
      },
      network_id: 42
    }
  },
  mocha: {
  },
  compilers: {
    solc: {
      version: "0.6.6",
    },
  },
};

Can anyone throw some light into the issue as to why it might be happening (this works fine on Remix. Only truffle console seems to cause issues) ?


texts: How to increase my privacy on Ether accounts?

texts:
What would be the best way, if any, that one could change their address/account in order to make themselves unknown or hard to identify by people they traded with? More specifically, if I send ETH to someone, is there a way to prevent them from knowing exactly how much ETH I own?

Obviously I could create another account and transfer my ETH there, but it wouldn't be too hard for someone to "follow the money", especially if I use it to store ether and that only one transaction leads to it.

I could also create multiple accounts and split my ETH among them, but it doesn't seem efficient, is there anything better?


texts: Reading of state variables vs the memory varables . and memory vs storage keywords

texts:
contract Shopping {

    struct Article {
        uint id;
        address seller;
        address buyer;
        string name;
        string description;
        uint256 price;
    }

    // state variable
    mapping(uint256 => Article) public articles;
    uint articleCounter;

    function buyArticle(uint _id ) public payable {
        Article  storage article = articles[_id];
        require( article.buyer == 0x0);
        require(msg.sender != article .seller]);
    }
}

1) I have got this code in online

2) i am wondering  why storage is declared rather than memory

3) For  getting values from  mapping articles[] i used slicing
technique which is similar to  array slicing

4) But Now in storage type  we are using article.buyer  rather than article[buyer]


texts:
For example, lets consider the basic example of issuing a token:

...string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance; ...

Here we are storing in an array the balance for every account. So every time we register a new address, the size of the array increases. As far as I understood the maximun size of data on time creation is limited by the possible Gas quantity to be used. Currently 3M of Gas (around 89KB) per block.

This limitation is only when creating a new transaction? Once the contract is on a transaction, Can it still be growing and growing by receiving new data from other transactions without a limit?


texts: How can we define the communication line with the Ethereum Blockchain?

texts:
Imagine we have a wordpress website and you want to use the functionalities of the smart contract to test your business logic. I am using a web3 library with drupal to test my smart contract using Metamask & TestRPC locally.
is there a way to use wordpress/Drupal/Joomla to make a Dapp out of it? I want to know if  there is other ways to test a dapp without testRPC or Metamask or Mist, just with any browser?
Thank you in advance.


texts: Simplest way to integrate Infura with a Web3/Truffle app?

texts:
I have a Truffle/Web3 app which has this code in app.js (by default) which runs when the page is loaded:

$(document).ready(function () {
  if (typeof web3 !== 'undefined') {
    console.warn('Using web3 detected from external source like Metamask')
    window.web3 = new Web3(web3.currentProvider)
  } else {
    console.warn("No web3 detected. Falling back to http://localhost:8545. You should remove this fallback when you deploy live, as it's inherently insecure. Consider switching to Metamask for development. More info here: http://truffleframework.com/tutorials/truffle-and-metamask")
    window.web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
  }

My truffle.js file looks like this:

require('babel-register')

module.exports = {
  networks: {
    "ropsten": {
      host: 'localhost',
      port: 8545,
      network_id: 3, // Ropsten
      gas: 500000
    }
  }
}

I have also signed up to Infura which has given me a "provider URL" like https://ropsten.infura.io/xxxxxxxxxxxxxxxxxxxxx

How should I then properly configure my truffle.js and app.js so I am using Infura? I would like to use Infura for the purpose of showing users who aren't using MetaMask/Parity/Mist data from the blockchain (so the app could still call functions from my contract), while Infura should be ignored if it's detected that the user is using MetaMask/Parity/Mist.


texts: How to manage nodes and accounts in private (permissioned) networks

texts:
I would like to create a private/permissioned blockchain to allow for data exchangement between a number of organisations which are known (and trusted) upfront. Moreover, multiple employees per organisation should be able to interact with the blockchain, where employees could have different roles and rights (e.g. execution of smart contract functions).
I've played around with creating private blockchains locally (using Truffle/Ganache), but I'm wondering how the structure should look like in a production environment (e.g. number of nodes, creation of accounts, etc.). I understand that, when creating a public blockchain, the more nodes participate in the network the more secure it becomes. This does not hold for private blockchains (using PoA) through which it seems overkill to have each employee run it's own node. Therefore I think it's sufficient to only have each organisation run it's own node. However, how to create the user accounts for each organisation? There should be a link between employees and the organisation but I'm not sure how to achieve this.
Any thoughts on how to proceed? Thank you in advance!


texts: Reading the result of a function that change state by using events in Solidity

texts:
I would like to get the result of a function by listening its emitted event.
These are two pieces of code of my contrats

CONTRACT 1:

function createTradeableContract() public stopInEmergency returns(address subcontractAddr) {
        TradeableContract tc = new TradeableContract(msg.sender);
        contracts.push(tc);
        return tc;
    }

CONTRACT 2:

function TradeableContract (address ownerAddr) public {
        owner = ownerAddr;
        NewOwnerEvent(0x0,owner);
}

I am using web3.0 1.0 beta. I wrote this code. I cannot understand why I cannot see the event in the logs.

self.contractCreator.methods.createTradeableContract().send({from: selectedAccount})
        .once('receipt', function(receipt){
            console.log("receipt");
            console.log(receipt);
            console.log("eventos...");
            console.log(receipt.logs); //it is undefined

         })
        .on('error', function(error){
            console.log("erro");
            console.log(error);
         })
        .then( receipt =>
        {
            console.log(receipt);
            console.log("events...");
            console.log(receipt.logs); //it is undefined

        })
        .catch (error => console.warn(error));

If I use Remix, I can see the event in the console (below).

[
    {
        "from": "0x8722aff990eda4d2d11915705076af5823f5f14c",
        "topic": "0x09f86d61eb5d6904c1fa8e5f071f171ec90eccc6e0a7b61d563a7d693db815f6",
        "event": "NewOwnerEvent",
        "args": {
            "0": "0x0000000000000000000000000000000000000000",
            "1": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "old": "0x0000000000000000000000000000000000000000",
            "current": "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c",
            "length": 2
        }
    }
]

Since I cannot get the returned value of a function that change state, I am using events. But... What is the best way to get the emmited event after invoking the function?


texts: ERC20 token transfer is not showing in receiver's balance

texts:
I have created 3 node (A, B, C) network in that I have deployed simple ERC20 token smart contract on node A.
function balanceOf(address tokenOwner) public view returns (uint256) {
    return balances[tokenOwner];
}

function transfer(address receiver, uint256 numTokens) public returns (bool) {
    require(numTokens <= balances[msg.sender]);
    balances[msg.sender] = balances[msg.sender].sub(numTokens);
    balances[receiver] = balances[receiver].add(numTokens);
    emit Transfer(msg.sender, receiver, numTokens);
    return true;
}

I am communicating with smart contract using web3.
const balance = async (httpProvider) => {
    const web3 = new Web3(httpProvider);
    const id = await web3.eth.net.getId();
    const deployedNetwork = token.networks[id];
    const accounts = await web3.eth.getAccounts();
    const account = accounts[0];
    const contract = new web3.eth.Contract(token.abi, deployedNetwork.address);
    return contract.methods.balanceOf(
        account
    ).call({ from: account });
}

const transfer = async ({sender, receiver, amount}) => {
    const httpProvider = getHttpProvider(sender);
    const web3 = new Web3(httpProvider);
    const id = await web3.eth.net.getId();
    const deployedNetwork = token.networks[id];
    const accounts = await web3.eth.getAccounts();
    const senderAccount = accounts[0];
    const contract = new web3.eth.Contract(token.abi, deployedNetwork.address);
    return contract.methods.transfer(
        getAddress(receiver),
        amount
    ).send({ from: senderAccount, gas: 30000000, privateFor: [getPublicKey(receiver)] });
}

when I am transferring token from A to B or A to C everything is fine balanceOf(A), balanceOf(B) and balanceOf(C) are returning correct values.
but when I am transferring from B to c balanceOf(B) is showing the correct value but not balanceOf(C) as if transfer didn't happen for C.
but from response I can see transfer was successful so why balance of C was not updated correctly?
"events": {
        "Transfer": {
            "address": "0x4D3bfd7821E237fFE84209d8E638f9f309865b87",
            "blockNumber": 32826,
            "transactionHash": "0x9e65454b1fd3e983f25010c324dc3a9633e696e77ac8446189c0dc941d42c7a9",
            "transactionIndex": 0,
            "blockHash": "0x0937d55d1effd81a150df3094ca2d19230c26a74e6dc7b6c83cec5828f51b1a2",
            "logIndex": 0,
            "removed": false,
            "id": "log_09bea0b7",
            "returnValues": {
                "0": "0xcA843569e3427144cEad5e4d5999a3D0cCF92B8e",
                "1": "0x9186eb3d20Cbd1F5f992a950d808C4495153ABd5",
                "2": "1",
                "from": "0xcA843569e3427144cEad5e4d5999a3D0cCF92B8e",
                "to": "0x9186eb3d20Cbd1F5f992a950d808C4495153ABd5",
                "value": "1"
            },
            "event": "Transfer",
            "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
            "raw": {
                "data": "0x0000000000000000000000000000000000000000000000000000000000000001",
                "topics": [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x000000000000000000000000ca843569e3427144cead5e4d5999a3d0ccf92b8e",
                    "0x0000000000000000000000009186eb3d20cbd1f5f992a950d808c4495153abd5"
                ]
            }
        }
    }


texts: Does nonce increase when the transaction fail?

texts:
DOes nonce increase when the transaction fail?

TX1 nonce=0 succeed

TX2 nonce=1 failed

TX3 nonce=?

What value of nonce will TX3 have? It will be appreciated if you explain the reason why.


texts: how one smart contract interact with another smart contract using web3js?

texts:
This is my doctor contract.

pragma solidity ^0.4.24;

contract doctor {

    struct doctor_ds {
        address doctor_address;
        string speciality;
    }
    mapping(address => doctor_ds) public doctors_list;
    address hospital_address;

    function doctor() {
        hospital_address = msg.sender;
    }

    function add_doctors(address _new_doctor_address, string _speciality) {

        doctors_list[_new_doctor_address].doctor_address = _new_doctor_address;
        doctors_list[_new_doctor_address].speciality = _speciality;
    }

    function doctor_exist(address _doctor) public view returns(bool) {
        if (doctors_list[_doctor].doctor_address == _doctor) {
            return true;
        } else {
            return false;
        }
    }
}

================

This my patient contract.

pragma solidity ^0.4.24;

import "./doctor.sol";

contract patient {

    doctor doctor_obj;

    function patient(address _doctor_contract) {
        doctor_obj = doctor(_doctor_contract);
    }

    function check_if_doctor(address _ddoctor) returns(bool) {

        return doctor_obj.doctor_exist(_ddoctor);
    }

    function add_doc(address _d, string _s) {
        doctor_obj.add_doctors(_d, _s);
    }

    function A() payable {

    }
}

I am getting gas exceeded error, when i am calling doctor exists in patient contract(using remix and private ethereum blockchain) and also i want to create front end  for patient contract, But How doctor contact's ABI will used in calling patient contract's add_doc and check_if_doctor functions. I  don't know code for  web3js when contracts interact with each other. Somebody please help


texts: Dynamic State Access vs Static State Access vs Statelessness

texts:
I have been reading up on ethereum and the changes that come from going from 1.0 to 2.0, but was confused about the terminology of the different "state" types. Would someone mind explaining the differences between dynamic state access, static state access, and statelessness as it relates to ethereum?
Thank You!


texts: Deployed contract does not show up on the remix.solidity

texts:
I am using a private ethereum network and I am using remix.solidity (http://remix.ethereum.org) to deploy my contract.

First I connect into my private-network:

Run => Environment and selected Web3 Provide
There will be a window opening asking “Are you sure want to connect to an ethereum node?” Clicked OK. Please note that, the connection is established to my private network and there is no problem on that side.

Than I deployed my contract via on Run tab and clicking Create button that is next to my contract.

After some time, I can see that my contract (simple hello-world contract) is deployed on my network status (as the transaction it show up), but I do not see the deployed contract on the remix solidity browser (on console it hangs as creation of greeter pending...), so I cannot obtain its address and access into my contract.

[Q] What should I do to see the address of deployed contract on the remix solidity? Does anyone face with the similar bug?

I also asked as a Github issue: https://github.com/ethereum/remix-ide/issues/1121


texts:
When I use Javascript VM in Remix I'm able to run functions and return outputs, but when I switch over to testrpc, the code runs properly but there's no decoded output.

I only ever run into this problem when I need to return a  bool or the now variable. Is there any way explanation as to why this happens?


texts: How to type cast fixed size byte arrays in solc 0.5.x?

texts:
In solc 0.4.28 I was able to do:

uint foo = 42;
bytes28 bar = bytes28(foo);

but in 0.5.9 I'm getting the error:

TypeError: Explicit type conversion not allowed from "uint256" to "bytes28".
        bytes28 bar = bytes28(foo);


texts: Ethereum mining problem - Receipt not found for transaction

texts:
I am using a private geth with a simple contract file SimpleContract.sol

pragma solidity ^0.4.0;

contract SimpleStorage {
  uint storedData;

  function set(uint x) {
    storedData = x;
  }

  function get() constant returns (uint) {
    return storedData;
  }
}

and the genesis file

{
  "nonce": "0x0000000000000042",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "difficulty": "0x400",
  "alloc": {
     "65a89fc3ff11a5fb1f6c77532dfb258fba531011":{ "balance": "10000000000000000"}
   },
   "coinbase": "0x0000000000000000000000000000000000000000",
   "timestamp": "0x00",
   "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   "gasLimit": "0xffffffff",
   "config": {
       "chainId": 42,
       "homesteadBlock": 0,
       "eip155Block": 0,
       "eip158Block": 0
    }
}

I compiled using

echo "var simpleOutput=`solc --optimize --combined-json abi,bin,interface SimpleContract.sol`" > simpleStorage.js

I invoked a private geth console and ran

loadScript("simpleStorage.js")
personal.unlockAccount(eth.accounts[0], <password>)
debug.verbosity(4)
var simpleStorageContract = web3.eth.contract(JSON.parse(simpleOutput.contracts["SimpleContract.sol:SimpleStorage"].abi));
var simpleStorage = simpleStorageContract.new(   {     from: web3.eth.accounts[0],      data: "0x" + simpleOutput.contracts["SimpleContract.sol:SimpleStorage"].bin,      gas: '47000'   },  function (e, contract) { if(!e) {    if(!contract.address) {      console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");    } else {      console.log("Contract mined! Address: " + contract.address);      console.log(contract);    }  }})

At this point, it printed

  INFO [07-02|17:30:53] Submitted contract creation
  fullhash=0x98a94a395677b304a90c6d73d64514272a32f7c891acbdde44bc3caca50fc162
  contract=0xe27c4df48e1a75bcb2de33fb9647a677268764c9

  Contract transaction send: TransactionHash:
  0x98a94a395677b304a90c6d73d64514272a32f7c891acbdde44bc3caca50fc162
  waiting to be mined...

When I tried

miner.start(4)

it printed

  INFO [07-02|17:31:05] Commit new mining work                  number=58 txs=0 uncles=0 elapsed=5.320ms

  DEBUG[07-02|17:31:05] Loaded
  old ethash dataset from disk      epoch=0

  DEBUG[07-02|17:31:05] Loaded old ethash dataset from disk      epoch=1

  INFO [07-02|17:31:06] Successfully sealed new block            number=58 hash=839455…388037

  DEBUG[07-02|17:31:06] Trie cache stats after commit           misses=8 unloads=0

  INFO [07-02|17:31:06]  mined potential block     number=58 hash=839455…388037

  INFO [07-02|17:31:06] Commit new mining
  work                   number=59 txs=0 uncles=0 elapsed=102.378µs

  DEBUG[07-02|17:31:06] Receipt not found for transaction      hash=98a94a…0fc162

It never mines the smart contract.

I have the unlocked account and the account signs the "from" in simpleStorageContract. Anything else I am missing?


texts: what does mean signer's key JSON on puppeth sealer?

texts:
System information
Geth version: 1.8.8-stable-2688dab4
OS & Version: ubuntu

I'm currently created private ethereum network using puppeth, when I created a sealer/ miner, appear this question "Please paste the signer's key JSON:"

whats that is mean? and where I can get signer's key JSON?

thank you guys


texts: Verify a (Metamask) transaction has happened on NodeJS

texts:
What is the best way to verify a (Metamask) transaction has happened on NodeJS?
Use case:
A user buys a digital card with ether.
After the user buys the digital card, a route on the server runs some code, makes a PDF, etc..
What is the recommended way to have a server (ExpressJS) verify that a tx has happened and is successful?
I was thinking of two options, but I'm pretty new to Ethereum so I'm probably missing some details here.

Have the server listen to events from the contract. When an event comes in, it'll have the user's address and prove they paid. Than I can make the card.

The only thing that I'm concerned here with is that maybe some details of the card are private. And if it's in the logs, it'll be public.
or..

OR have the user sign the message locally, push it to the server and somehow send it to the contract. I'm not sure what the details are with this route.

Are there any recommended ways to accomplish something like this?


texts: How is Parity's "warp" sync related to Geth's "fast" sync?

texts:
A follow-up to this question.

Geth's fast sync is one-shot. i.e. once we have synced some of the blockchain, we cannot use fast sync anymore. Is this the case for Parity? I ran it with warp, then without warp, then with warp again. It doesn't complain, so I guess this is doable in Parity.

One other issue I notice is the number of peers are way lower when I run parity with --warp. This is strange. Is warp sync exclusive? i.e. some nodes are warp, some nodes are not? Or is it just a coincidence whenever I run parity --warp, I find less peers?


texts: SyntaxError: Use of the "Var" keyword is disallowed

texts:
someone could tell me how to define this function without using "var"? I don´t know if I have done it well. This is part of my code:
struct user{
        uint time_transation;
        uint amount;
        uint[24] price_of;
        uint[24] price_de;
        uint[24] price;
        uint tipo_usuario;
        uint amountcasada;
        uint coinAccount;
        uint identificador;
    }
    mapping (address => user) usuarios;

    function setOwner(address DSO) public{
        owner=DSO;
    }

    modifier OnlyOwner{
        require(msg.sender==owner);
        _;
    }
function Input_prosumidor(uint _coinAccount) public{
        **var Usuario=usuarios[msg.sender];** //here is my error
        Usuario.time_transation=now;
        usuariosAd.push(msg.sender) -1;
        Usuario.coinAccount=_coinAccount;
        Usuario.price_of=_precio_of;
        Usuario.price_de=_precio_de;
        Usuario.identificador=contadoridentificador;
        contadoridentificador++;
    }

Thank you so much!


texts: How to encode data payload in ETH transaction

texts:
I'm using python to sign and send ETH transactions, and would like to do the same for ERC-20 token transactions as well. I'm having trouble correctly encoding the data payload to invoke the transfer method within ERC-20 token contracts.

Here's the method I want to use: transfer(address _to, uint256 _value)

Here's basically what I'm currently doing for the data field:

METHOD = "0xa9059cbb"
ADDRESS = "000000000000000000000000cD60535a5C13ED2D07199aDCe494D33b01930208" #this is the to_address padded to 32 bytes (changed for privacy)
VALUE = "0000000000000000000000000000000000000000000000000de0b6b3a7640000" #this is the hex of the value (1*10^18) padded to 32 bytes

DATA = METHOD+ADDRESS+VALUE

And I'm signing that along with the rest of the tx info. However, the resulting transaction I get has something completely different than my data payload in the "script" field. Any idea what I'm doing wrong?

Here's my code for signing the transaction. Unfortunately I didn't write this function so I don't understand a lot of what's going on in the rlp and ethereum libraries:

def signTransaction(to, value, privkey, nonce, data="", gasPrice=36000000000, gas=100000):
    from ethereum import transactions
    import rlp
    try:
        return {'error':False, 'sign':rlp.encode(transactions.Transaction(nonce, gasPrice, gas, to, value, data).sign(privkey)).encode('hex')}
    except Exception as msg:
        return {'error':True, 'message':msg}

signTransaction(CONTRACT_ADDRESS, 0, PRIVATE_KEY, NONCE, DATA)

Thanks!!


texts: I have some addresses and some strings which are denoted to some values and I must be able to retrieve the value associated with both keys. I guess I must create 2 separate mapping with each kind of keys but this is so ugly and I don't like it. Is there any better way to do this?


texts:
pragma solidity ^0.4.18;

contract MinInvest {

    function validPurchase() internal returns (bool) {
    bool moreThanMinimalInvestment = msg.value >= 0.1 ether; // change the value to whatever you need
    return super.validPurchase() && moreThanMinimalInvestment;
    }
}

  browser/Untitled.sol:7:12: TypeError: Member "validPurchase" not found
  or not visible after argument-dependent lookup in contract super
  MinInvest
      return super.validPurchase() && moreThanMinimalInvestment;

How do i add validPurchace?


texts: Is there anyway to set a maximum gas price for sending any transaction with any account? I know I could hard code this in, but wondering if this is fortunately built in?


texts:
I am using web3@0.20.7 and infura to connect Ropsten testing network.
I haven't opened my website(using ethereum) for a while.
Today I restarted my website, and I can not connect to ethereum with Infura.
Here's code

var express = require('express');
var router = express.Router();
var Web3 = require('web3');
const testnet = 'https://ropsten.infura.io/';
const web3 = new Web3(new Web3.providers.HttpProvider(testnet));
var contractAddress = '0x72682d0d54c7ED7cdDdAa66E6DD7171f2B9c626C';
var contractABI =[{"constant":false,"inputs":[{"name":"CopyMatch","type..........
var contract = web3.eth.contract(contractABI).at(contractAddress);

Variable "contract" cannot get anything.
How can I revise it? Thanks.


texts: How can I decode the inputs to a transaction written by a smart contract constructor with Nethereum?

texts:
I've been able to decode the inputs to a contract function transaction given the ABI as follows:

var myFunction = contract.GetFunction("MyFunction");
var myFunctionTxn = await contract.Eth.Transactions.GetTransactionByHash
        .SendRequestAsync(myTxnHash);
var inputs = myFunction.DecodeInput(myFunctionTxn.Input);

However, now I would like to do the same (i.e. retrieve a transaction hash and then decode the constructor inputs) for the constructor itself. I've looked at the ContractABI.Functions - I can see both the Constructor and the Functions, but the types are not compatable.

Also, I can see the types of the inputs from this, but unfortunately not the values:

var ctor = contract.ContractBuilder.ContractABI.Constructor;

Is there an equivalent for DecodeInput for constructors?

From here, it looks like this must be possible


texts: Usage regarding for loop in solidity contract

texts:
I am trying to integrate for loop in my smartcontract for adding details to a struct.

I have implemented for loop using frontend by calling the function in smartcontract one by one.

 struct details {
    string[] value;
}
mapping (uint=>details) Details;
function add(uint id,string valuetosubmit){
    Details[id].value=valuetosubmit
}

As I have mentioned,I am calling the function add one by one inside a for loop.

I have to move the for loop inside the smart contract.How can it be implemented?
Any samples for reference?
Which is the best method to follow? What will be difference in Gas Consumption?


texts: Domain registration for decentralized application

texts:
I have a question I can not find any answer to.

I understand that through blockchain, ethereum, some decentralized applications can be made. My question is, how can these applications be accessed? If such an application is accessed online, the .com domain is not owned by a person who has full access to it?


texts: Is there a difference between geth and the cpp-ethereum CLI?

texts:
I am a cpp dev and i want to have a look at the ethereum code so i chose the cpp-ethereum repo.

Do geth and cpp-ethereum have the same CLI commands? I wasn`t able to find a list of the commands for cpp-ethereum (I can look at the argv loop but I also need the command list for quick reference).


texts: Timeout error on deploying to Rinkeby from truffle migrate

texts:
I have just finished the CryptoZombies tutorials, and was trying to deploy the file following their instructions to the Rinkeby network. But I keep getting this timeout error and am lost on how to proceed.

$truffle migrate --network rinkeby

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56
        throw new Error(errorMessage);
^
Error: There was a timeout while attempting to connect to the network.
       Check to see that your provider is valid.
       If you have a slow internet connection, try configuring a longer timeout in your Truffle config. Use the networks[networkName].networkCheckTimeout property to do this.
    at Timeout._onTimeout (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:56:1)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

My truffle-config.js is as follows:

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

const mnemonic = "depth invite butter ...";

module.exports = {

  networks: {

    mainnet: {
      provider: function () {

        return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/v3/YOUR_TOKEN")
      },
      network_id: "1"
    },

    rinkeby: {

      provider: function () {

        return new HDWalletProvider(mnemonic, "https://rinkeby.infura.io/v3/YOUR_TOKEN")
      },

      network_id: 4
    }
  }
};


texts: Solidity: Timestamp dependency, is it possible to do safely?

texts:
My contract depends on checking to see if an expiration period has expired before sending the contracts balance. I was looking at the ConsenSys best practices here and it says:

Timestamp Dependence
Be aware that the timestamp of the block can be manipulated by the miner, and all direct and indirect uses of the timestamp should be considered. Block numbers and average block time can be used to estimate time, but this is not future proof as block times may change (such as the changes expected during Casper).

Is there any way around this? It seems like it would be quite a hinderance to the idea of smart contracts since contracts are often heavily reliant on time.


texts: What if difficulty bomb makes mining impossible before POS release?

texts: As mining difficulty raises and POS is still not ready, I was just wondering if POS release can still be on time compared to the difficulty bomb giving too high difficulty. In simpler words, is there a risk that difficulty become too high to mine before POS is ready and what would be the consequences? Thanks.


texts:
The bittrex contract has the following code.
What does (a); and (val); mean?

contract Token {
    function balanceOf(address a) returns (uint) {
        (a);
        return 0;
    }

    function transfer(address a, uint val) returns (bool) {
        (a);
        (val);
        return false;
    }
}


texts: How did the CryptoKitties contracts update, given that contracts are immutable?

texts:
How did the CryptoKitties contracts update?
There were CryptoKitties bounty programs which suggests that the contracts changed over time in order to address issues.
How? I peeked at the sources for some of the contracts and couldn't see anything like the OpenZeppelin proxy pattern for updating contracts.


texts: Fee for sending 4.3 ether with gasprice set to 200000

texts:
I'm about to buy some ICO and I want to maximize my purchase. What is the fee
on 4.3eth with the gasprice set to 200000?


texts:
I installed parity-poa-playground from (https://github.com/dstarcev/parity-poa-playground) on Windows 10 and managed to made it working with parity configured from (https://github.com/paritytech/parity).

Now, after compilation when i run cargo run --release I think it start mining real ether. but i want development ether in my account.

If I made transaction using following

curl --data '{"jsonrpc":"2.0","method":"personal_sendTransaction","params":[{"from":"0x6B0c56d1Ad5144b4d37fa6e27DC9afd5C2435c3B","to":"0x00f3409AF27Eaa81CbF5d2884d8c138cD633826d","value":"0x186a0"}, ""],"id":0}' -H "Content-Type: application/json" -X POST 192.168.99.100:8545

where 0x00f3409AF27Eaa81CbF5d2884d8c138cD633826d is my account in parity, it gives me the following output:

{"jsonrpc":"2.0","result":"0x8744eab96a01dcfeda3e674f94de0851aff1d6b7d8ee6b08aea15b460f5af0e9","id":0}

but no change in my account in parity.


texts: How can I expose Geth's RPC server to external connections?

texts:
I want to set up a private network of applications which can connect to a single Geth node. What options do I have for exposing the RPC server?

I'm running this: geth --rpc --testnet (sometimes I use --dev)

How can I achieve the following:

Permit specific public/private keys to access the node
Permit anyone to access the node
Permit IP range to access the node

Possible solution?

Would this just require running a reverse proxy with a server like Nginx?


texts: If I were to perform an airdrop (Transfer) with my custom token to addresses holding a different token, would the wallets that my token are being sent to need to be watching it before the transfer to receive it or is that not an issue and they'll be there but just not visible until they watch it?


texts:
I have got as far as generating the method ID for the function:

function transfer(address src, address dst, uint256 amount);

The method ID would be:

bytes4(keccak256("transfer(address,address,uint256)")) // 0xbeabacc8

How do I pass the function variables (on-chain) along with the method ID to a function:

function execute(address _target, bytes _data)

Where _data is the calldata  of the transfer function.


texts: Proof Of Authority vs Proof Of Work geth

texts:
In case of proof of work consensus mechanism miners compete with each other to solve the cryptographic puzzle and once a miner found the answer of puzzle , he will broadcast it to all the nodes participating in blockchain network. Majority of miners need to agree and validate the block using answer sent by miner and block is appended to blockchain.

In case of proof of authority, how sealers/signers validate blocks?

EDIT 1 :

This question suggest that in case of Proof of Authority consensus mechanism signers sign blocks in round robin fashion ,Agreed ! My question is what procedure signers follow to sign a valid block? How do they identify invalid block? In case of proof of work node can validate block based on answer of cryptographic puzzle sent by miner.


texts: --ethstats to send node details to multiple servers

texts:
I am using --ethstats to send the node details to a server and to show on UI. For this purpose I am using the Secret key, Ipaddress and Port t which the details need to be sent.
However, now I have use case where I need to send the node data to two different servers at the same time. Is it possible?
PS: I tried myself by using --ethstats twice  in  my geth command, but only the last --ethstats command is considered.


texts:
I'm trying to create a simple ZKP verifier using Zokrates, if the input is more than 18 it'll will output 1 otherwise 0.
Here's the .zok file:
def main(private field a) -> (field):
    field result = if a > 18 then 1 else 0 fi
    return result

Proof when input a is 5.
["0x1be322ed8dd01d1de109077e84a5cc7ddaeb9d8b3052f2d4ab2578b36608f2c2","0x1a4c0b06083c13589371595dc2c3fbe5799f3ce44f15ac89389843b728eb0d9c"],[["0x2c89e2c9c3d99c1e7e7114ed7cb0c8f5a72172ed11a42b983053e489ceff9343","0x297ebf7b81df6ab02553a018f58f2e5abf6a2bfafa4184ff00b6d13cf04efc1d"],["0x28b9a6212fa99ee1388f1623bc3dbd3dd4094b3dcf4587be7c7a2b6a802df7bc","0x13a6fed7e0a61a1e0a066b85699d0419232ba5ced0e247fc99aaf5201ff1689f"]],["0x11a7d8ec24029020d0e6565328f2df3eb26bcfcb9f40a01dd89123029c94562b","0x22f9b98dd00e83bb22888d9186117e21246d24063ba562550760a1ec6175a654"],["0x0000000000000000000000000000000000000000000000000000000000000000"]

The address of verifier on Goerli TestNet
0xCCb12641221454891588b66845FbC7E710B85447

ABI of the verifier
[
    {
        "inputs": [
            {
                "internalType": "uint256[2]",
                "name": "a",
                "type": "uint256[2]"
            },
            {
                "internalType": "uint256[2][2]",
                "name": "b",
                "type": "uint256[2][2]"
            },
            {
                "internalType": "uint256[2]",
                "name": "c",
                "type": "uint256[2]"
            },
            {
                "internalType": "uint256[1]",
                "name": "input",
                "type": "uint256[1]"
            }
        ],
        "name": "verifyTx",
        "outputs": [
            {
                "internalType": "bool",
                "name": "r",
                "type": "bool"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }
]

While computing the witness I'm getting the correct outputs.
But when I deploy the contract and pass the proof, it's always "true", even when I give wrong values.


texts: passing String object with "0x.." value as bytes32 to a solidity function

texts:
I'm having trouble to pass bytes32  to a solidity function from javascript. It's converting to an incorrect bytes32 in solidity.
The javascript is a test, running with truffle v3.3.1 on testRPC v3.0.5.

MyContract {

  event myEvent(bytes32 id);
  function myTran(bytes32 arg) {
     myEvent(arg);
  }
}

When I pass it a string it works (and myEvent emits a correct hex):

myContract.myTran( "0x2a1acd26847576a128e3dba3aa984feafffdf81f7c7b23bdf51e7bec1c15944c");

this works too:

var x = "0x2a1acd26847576a128e3dba3aa984feafffdf81f7c7b23bdf51e7bec1c15944c";
return myContract.myTran(x);

This works but I i receive a different hex value from the myEvent than the passed hex:

 ... tx executed before  ...
    var x = new String( tx.logs[0].args.id );
    console.log(typeof x, x); // output: string 0x2a1acd26847576a128e3dba3aa984feafffdf81f7c7b23bdf51e7bec1c15944c
    return myContract.myTran(x); // executes but the bytes32 in the event is different


texts: mapping's used gas changes based on index used as static value or a variable

texts:
On the following contract which I have tested using populus. I have experience that the same code generates different gas usage based on mapping index I used as a static value or a variable.

[Q] I really wonder does anyone else experience the same behavior of the gas change? If yes what might be the reason?

Used gas = 86658

self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head });
self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10 });

//self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head });//commented out!!
//self.list_[3]     = Interval( { num: 10, core: 10, next: 10 });//commented out!!

-- or
Used gas = 65220

//self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head });//commented out!!
//self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10 });//commented out!!

self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head });//used GAS = 65220
self.list_[3]     = Interval( { num: 10, core: 10, next: 10 });

--As you can see both code accessing to index value 2 and 3.

Contract: Array.sol

pragma solidity ^0.4.8;
library ReceiptLib {
  struct Interval {
    uint32 num;
    int32  core;
    uint32 next;
  }

  struct intervalNode {
    uint32 den;
    mapping(uint32 => Interval) list_;
    uint32 len;
    uint32 head;
    int32 coreLimit;
  }
  function constructReceipt(intervalNode storage self){
    self.head      = 1; //self.listSize - 1;
    self.coreLimit = 128;

    self.list_[0] = Interval( { num: 0, core: 0, next: 0 });
    self.list_[1] = Interval( { num: 0, core: 0, next: 0 });
    self.len = 2;
  }
  function number(intervalNode storage self, uint32 s, uint32 e, int32 c){
    uint32   selfSize = self.len;
    //self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head });
    //self.list_[selfSize + 1] = Interval( { num: 10, core: 10, next: 10   });

    self.list_[selfSize]     = Interval( { num: e - 1, core: c, next: self.head  });
    self.list_[3]     = Interval( { num: 10, core: 10, next: 10 });
  }
}

contract Array{
  using ReceiptLib for ReceiptLib.intervalNode;
  ReceiptLib.intervalNode receiptList;

  function Array(){
    receiptList.constructReceipt();
  }
  function test(uint32 s, uint32 e, int32 c) {
    receiptList.number(s, e, c);
  }
}

Thank you for your valuable time and help.


texts: message signing and verification for micropayment channel

texts:
I am writing a micropayment channel for ERC20 Token, but I have pasted here a small signature verification code which is not working.

The transaction doesn't succeeds. I have to use web3py to send signed messages to verification to the contract..

Here is the piece of code to sign message and then  sign transaction.

signature = Web3.soliditySha3( [ 'address' , 'address' , 'uint256' , "uint256" ] ,
                   [ "recipient address" ,
                    Web3.toChecksumAddress("contract address") ,
                    w3.eth.getTransactionCount('my address'),
                    token ])
output : HexBytes('0xcc40a4139efd7fd5fe58396e60d18d181cee0a3d808749faa1682590ab2ee835')

from eth_account.messages import encode_defunct
## so then i sign it..

msg = signature.hex()
message = encode_defunct(text=msg)
signed_message = w3.eth.account.sign_message(message, private_key=private_key)
signed_message

transaction = mygrail.functions.withdraw(w3.eth.getTransactionCount('my address'),
                                         "recipient",
                                            less token , signature).buildTransaction({'chainId': 42 ,
                   'gas':700000 ,
                   'nonce': w3.eth.getTransactionCount('my address')})

signed_tx = w3.eth.account.signTransaction(transaction,
                                           "private key")

txn_hash = w3.eth.sendRawTransaction(signed_tx.rawTransaction)

txn_receipt = w3.eth.waitForTransactionReceipt(txn_hash)

this doesn't work ,... what am I doing wrong?

One of the problems that I am seeing is that when I am signing my message with remix it gives a 132 byte output. But my signature is only  bytes. what should I do? But still the signer that I obtain is address(0) or in some cases a different address.

Contract:

pragma solidity ^0.5.0;

contract Verify{
    address owner ;
    mapping (uint256 => bool) public usedNonces;

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

    function withdraw(uint256 nonce , address recipientAddress , uint256 tokens, bytes memory signature) public {
        require(!usedNonces[nonce]);
        usedNonces[nonce] = true ;
        bool done ;
        done = isValidSignature( recipientAddress , nonce , tokens  , signature );
        emit Success(done);
    }
    event Success(bool done);

    function isValidSignature(address recipient , uint256 nonce , uint256 amount, bytes memory signature)
        internal
        view
        returns (bool)
    {

        bytes32 message = keccak256(abi.encodePacked(recipient , address(this), nonce, amount));
        return recoverSigner(message, signature) == owner ;
    }

    function splitSignature(bytes memory sig)
        internal
        pure
        returns (uint8 v, bytes32 r, bytes32 s)
    {
        require(sig.length == 65 , "invalid length");

        assembly {
            r := mload(add(sig, 32))
            s := mload(add(sig, 64))
            v := byte(0, mload(add(sig, 96)))
        }
        if (v < 27) {
            v += 27;
        }

        require(v == 27 || v == 28);
        return (v, r, s);
    }

    function recoverSigner(bytes32 message, bytes memory sig)
        internal
        pure
        returns (address)
    {
        (uint8 v, bytes32 r, bytes32 s) = splitSignature(sig);
        return ecrecover(message, v, r, s);
    }
}


texts: Is mapping via msg.sender as secure as calling a function only by the owner?

texts:
On my implementation, only the owner of the contract's function was able to call some important functions that I defined. I changed the implementation as by removing onlyOwner, and adding cluster_constract[msg.sender].deleteAll() that will allow only the message sender to call that important function, if their address mapped to a list. cluster_constract[<my_address>] = list.

[Q] If an attacker knows the address of the msg.sender, can he calls deleteAll() function (cluster_constract["<valid_address>"].deleteAll(); ) from an external contract? Is my approach safe to use?

contract owned {
  address  public owner;
  function owned() {
    owner = msg.sender;
  }
  function ownerOnly() {
    if (msg.sender != owner) throw;
  }
  modifier onlyOwner {
    if (msg.sender != owner) throw;
       _
  }
  function transferOwnership(address newOwner) onlyOwner {
    owner = newOwner;
  }
}

Before:

  LinkedList.data list;
  function deleteAll() onlyOwner {
     list.deleteAll();
  }

After:

  mapping(address => LinkedList.data) cluster_constract;

  function add_cluster() {
     cluster_constract[msg.sender] = list;
  }

  function deleteAll() { //if cluster_constract[msg.sender] exits deleteAll() can be called.
     cluster_constract[msg.sender].deleteAll();
  }


texts: tokens generation in smart-contracts specific to one asset

texts: I have been building a smart-contract for tokens for songs such that they are specific to different songs such that one token is only valid for one specific song not other. Ive made a smart-contract which does exactly that but does not follow ERC-20 and so the tokens do not show in the mist wallet. What is the best approach, to inherit ERC-20 in my smart contract and make it have the total supply of all tokens for all songs?? If yes then I would need the initial supply to be increased dynamically, is that possible(or should even be done)?? Thanks in advance.


texts:
Is it possible to create a mutex that prevents reentrancy, without using the SSTORE operation?

I would like to create a flag to prevent reentrancy of my contract which will call out to other contracts. The SSTORE operation, of writing to storage is expensive. Is there a way to maintain this mutex in memory, or do it with less expensive operations?

I'm writing with Solidity, but curious about any version. Seems like this problem will exist for use cases beyond reentrancy protection. Limiting fees by keeping them to just Gsreset fees after initialization is the cheapest I can think of right now, but maybe there is something I'm missing.


texts:
Trying to understand how ethereum and blockchain work. I keep hearing that miners are needed to do the computations to unlock a block (don't know if that's the correct term).

My question is this: when the block is unlocked(?) and the miner is paid in Ether, is the payment coming from the total "gas" value of all transactions in the block, or have they intrinsically created value just by unlocking the block?


texts: Recover parameters from failed transaction on etherescan

texts: I have some failed transactions on etherscan that I'd like to investigate. An example is this one. How do I convert inputs like 00000000000000000000000000000000000000000000000000000001ae43e5e0 to what their original value was?


texts: Testing the functions of an instance contract with truffle

texts:
I have contract A and contract B with the following structures:
contract A {
  int x;
  function setX(){
       x = _x;
     }
}

contract B {
   A[] contractInstances;

   function createContractInstance() {
       contractInstances.push(new A());
      }

}

How can I access the method setX() of the created instance, when I am doing the testing with truffle?
P.S. when I try to access them directly from the array, it is not working, cause the js platform sees the contract as string addresses.


texts: How can you tell which version of Solidity to use when deploying contracts?

texts: I've noticed in various smart contract tutorials that different versions of Solidity are declared at the top. I would assume that you would just use the latest but I've noticed that certain contracts seem to work on one platform don't work on another i.e. deploying the same contract via Remix & MetaMask vs Mist?


texts: How can i make a simple chartjs chart with ethereum contract address

texts:
i would like to have a chart on my site that prints the last price of a certain erc20 token

i have seen a widget from ethplorer but i rather build my own chart but i cant find any documentation for that.

so far i have this html code(the chart is a sample from chartjs) but i cant figure out on how to add the erc20 contract address

 MONTHLY HISTORICAL PRICE +39.31%

        <canvas id="myChart" height="251" width="944" style="display: block; width: 944px; height: 251px;"></canvas>


texts: "Transfer amount exceeds allowance" eror

texts:
I have an ERC20 contract and I've created another contract which use this contract.
But when I call transferFrom function I get transfer amount exceeds allowance error.
I tried several methods like approve but nothing works, because of _allowances in ERC20 contract controls.
_approve(
        sender,
        _msgSender(),
        _allowances[sender][_msgSender()].sub(
            amount,
            "BEP20: transfer amount exceeds allowance"
        )

Can anyone help me?
contract a {

    BEP20Token private _BEP20Token;

    constructor(address _BEP20TokenAddress) public {
        _BEP20Token = BEP20Token(_BEP20TokenAddress);
    }

     function lock(uint256 amount) public returns (address){
        _BEP20Token.transferFrom(msg.sender, address(this), amount);
     }
}