texts: Estimating gas cost of function with multiple inputs

texts:
I have the contract

pragma solidity ^0.4.11;

contract UserBasic {
    struct Record {
        bytes32 _id;
        address _addedBy;
        uint _dateAdded;
        bytes32 _transactionHash;
        bytes32 _type;
        bytes32 _hash;
        bytes32 _signature;
    }
    // Type to records array
    mapping(bytes32 => bytes32[]) typeRecords;
    // Record ID to record
    mapping(bytes32 => Record) idRecord;
    // Search for record
    function searchRecord(bytes32 _id) constant returns (bytes32, address, uint, bytes32, bytes32, bytes32, bytes32) {
        Record storage temp = idRecord[_id];
        return (temp._id, temp._addedBy, temp._dateAdded, temp._transactionHash, temp._type, temp._hash, temp._signature);
    }
    // Add a record
    function addRecord(bytes32 _type, bytes32 _id) {
        typeRecords[_type].push(_id);
        var _new = Record(_id, tx.origin, now, "", _type, "", "");
        idRecord[_id] = _new;
    }
    // Get all records of a given type
    function getRecordsByType(bytes32 _type) constant returns(bytes32[]) {
        return typeRecords[_type];
    }
}

My addRecord method isn't working (I figure because of gas costs). I wanted to estimate how much gas that method costs but not sure how. This answer explains a way for a function with one parameter but it seems too complex of a process, I was wondering if there is a simpler way.

I'm calling it from node with

function addRecord(publicAddress, contractAddress, _type, _id) {
    const contract = contractInstance("UserBasic", contractAddress);
    // Interaction with the contract
    contract.addRecord(_type, _id, {from: publicAddress}, (err, res) => {
        // Log transaction to explore
        if (err) {
            console.log(err);
        } else {
            console.log('tx: ' + res);
            helpers.addTransaction(publicAddress, res);
        }
    });
}

I read the docs but the only part I don't know is how to convert multiple parameters to data.


texts: Solidity: Conversion bytes memory to uint

texts: Is there a workaround to convert a bytes memory to uint256?


texts: Python web3 return value of getBlock(full_transactions=True)

texts:
I am trying to get the meaning of all fields returned by getBlock, but no where to find!
web3.eth.getBlock(block_identifier='pending', full_transactions=True)

returns a list of :
AttributeDict({'blockHash': HexBytes('0x50edaaa071801750cb71d5b89b23a98e4ac911a3451acfa1646ee45a45200902'),
   'blockNumber': 11633063,
   'from': '0xA2F4442B71267F12A6844bb9b93cb744F0217baF',
   'gas': 243390,
   'gasPrice': 132000000000,
   'hash': HexBytes('0x630a3fc021744bb400437578464b4c4f3eeea82b3e1f58d3a2483e2cb0fbe9e1'),
   'input': '0x1e83409a000000000000000000000000a2f4442b71267f12a6844bb9b93cb744f0217baf',
   'nonce': 4,
   'r': HexBytes('0x02c77d2251fbd4b97aa0285e7b7651ff7775b8d41f3c5c42925a30ae087a6fdb'),
   's': HexBytes('0x4e8c0bb1e73ed38dc02a3a22167507b2572e1a18440a054ac421f2342f8b6fd9'),
   'to': '0x098e1708b920EFBdD7afe33Adb6a4CBa30c370B9',
   'transactionIndex': 87,
   'v': 28,
   'value': 0})

Could anyone provide some explanation of those fields (especially input, r, s and v).
Thank you!


texts: How many Uncles (Ommer) can be included and how is the reward distributed

texts:
how many uncles can one block include? I think I read somewhere that you can only include maximum 2 uncles, is that true?
If a block includes 2 uncles or more, how is the reward distributed between those?
If one uncle gets 7/8 of the static reward, the 7/8 is distributed between multiple uncles?


texts:
As per my knowledge, RPC  connection to a node is quite unsafe. so the alternative is connecting to a node via IPC. But how to connect to node via IPC?
I have used web3 for connecting to node via RPC and interact with my ethereum application. Can I use web3 for connection via IPC also or there is some other library that I need to explore. TIA
Edit:
I have tried using both web3_extended and web3_ipc.

When I install web3_ipc inside my node project and use
 var web3_extended = require('web3_extended'),
 I get error Cannot find node module 1web3_extended.

When I install either web3_extended or both web3_extended and web3_ipc , then at run time I get error like

Your browser sent a request that this server could not understand.<br>

I think only installation of web3_ipc will be sufficient but as per documentation I have to use require('web3_extended') in both cases. Can anybody point at what I am missing?


texts: Can one get the current gas used as a function inside of a smart contract?

texts:
We have seen a number of instances of popular smart contracts that stored a lot of data and that "clean up" their data with a single function call. Sometimes that clean-up code uses a lot of gas and hits the maximum gas limit for a single call.

Is there a function to tell the contract writer the "remaining gas limit" during execution and then write code to exit when that level gets too low, so a clean-up could be performed with multiple calls without running out of gas?

Alternatively, is there at least a "gas used so far during this call" function?


texts:
There doesn't seem to be an answer to this question anywhere.
Geth shows I mined an uncle.
There's all kinds of discussions about what/where/and how uncles exist,
but when does the miner get paid?


texts: Ethcore not deploying contract via web3 Javascript API

texts:
I have written some Solidity code, with a setter method createId to write a name-value pair to contract storage, and a getter method getPermissions to get the value associated with a particular name. It works correctly in browser-solidity (In screenshot below, createId was called before getPermissions).

Then, I used the web3 Javascript API from a NodeJS app to send a contract-deploying transaction to a Parity (Ethcore) node, connected to a private chain. That transaction gets mined. Using the JSON RPC API eth_getTransactionReceipt, I can get the transaction receipt, which has the contract address. However, when I send a JSON RPC API eth_getCode request with the contract address, all I get is: { "jsonrpc": "2.0", "result": "0x", "id": 1 }

To test whether it is just the eth_getCode not working correctly, I used the JSON RPC API eth_call to call the setter (which has no return value) to set a value, but calling the getter returns an empty result, too. The screenshot shows that the correct value was returned by the getter in browser-solidity.

Is there something I am missing? Thanks a lot for your help.

EDIT: Some additional information. I compiled and deployed the following Solidity code:

contract test { function double(int a) returns(int) { return 2*a; } }

In this case, eth_getCode returned the compiled code, given the contract address. Also, I invoked the double(int) method twice (with 2 different input values) using eth_call JSON RPC API, and got the correct return value in both cases.

Does that mean there is something wrong with the other contract's code (which is more complex than this test contract), even though it works correctly in browser-solidity? Are there any known issues in browser-solidity which would cause this? Does this give a hint about what problem in that contract could be?

The Solidity source, which works correctly in browser-solidity:

pragma solidity ^0.4.7;

contract owned {
  address owner;
  function owned() {
    owner = msg.sender;
  }
}

contract mortal is owned {
  function kill() {
    if (msg.sender == owner) selfdestruct(owner);
  }
}

contract IdMgmt is mortal {

  struct acl {
    string dataType;
    string permissions;
  }

  mapping (address => acl) public aclOf;

  function IdMgmt() { }

  function createId(address _user, string _dataType, string _permissions) {
    aclOf[_user].dataType = _dataType;
    aclOf[_user].permissions = _permissions;
  }

  function getPermissions(address _user, string _dataType) constant
    returns (string userPermissions) {

    if (stringsEqual(aclOf[_user].dataType, _dataType)) {
      userPermissions = aclOf[_user].permissions;
    }
    else {
      userPermissions = "NO DATA";
    }
  }

  function stringsEqual(string _a, string _b) internal returns (bool) {
    bytes memory a = bytes(_a);
    bytes memory b = bytes(_b);
    if (a.length != b.length) {
      return false;
    }
    for (uint i = 0; i < a.length; i ++) {
      if (a[i] != b[i]) return false;
    }
    return true;
  }
}


texts: ERC725 and ERC735 vs Hyperledger Indy (decentralized identity/self-sovereign identity)

texts:
Which is the better platform for decentralized identity, ERC725 and ERC735 or Hyperledger Indy?

Thinking from a performance perspective, Indy would probably shine. However, what about the other dimensions?

Which platform data structure, security, etc is better equipped to support a pan-region decentralized identity platform with more than 280 million people?


texts: Can I download all transactions into EOS ICO as a excel file?

texts:
I would like to download all transactions into EOS ICO as an excel file. I know etherscan provides this service but it only allows me to download 2000 transactions. But the transactions into EOS crowd sale address is already over 50000, so this option does not meet my need.

I am wondering if there is an easy way to download the transactions in a similar form that etherscan provides, but without the restriction of 2000. The information I need looks like the following:

DateTime/sender address(from)/ Value in / Value out/Historical price/status

I am not a computer science guy but willing to do some coding if I need. Is it any plausible solution to my problem?


texts:
I am currently looking at my ethereum wallet and it shows that a transaction happened overnight and wiped my whole balance. I was trying to transfer some funds from my cold wallet. I went on www dot ether-wall dot com and logged on with my private key. I was looking at the rates fluctuating and was waiting before to engage a transaction on shapeshit.
I decided not to go through and i notice that my balance was not showing on the right-hand side of the screen. i went on etherscan and myetherwallet.com sites this morning and i discovered that 189 ether were withdrawn and my balance is now 0

I am not sure what happened and why?

Anyone could help me and clarify if my 189 ether got stolen? And is there a way to get support or help to recover that transaction?!? or ban the thief!


texts: showing error when doing npm install to install openzeppelin it shows error

texts:
when i am trying to install the dependencies using npm install from openzeppelin.it shows error as
  Error: Can't find Python executable "python", you can set the PYTHON env variable.


texts: Transactions are failing randomly for multiple reasons when sending them in bulk for a benchmark

texts:
I'm trying to benchmark a private blockchain network (3 Vagrant nodes with 2gb of RAM running Geth Clique PoA, on an i7 7th gen Intel Core machine), following this process:

A function launch n functions per second
Those launched functions are reading a JSON file indicating what they should do (ex: deploy a contract and execute those 2 functions).
Thus, they compile, deploy and transact with the smart contract according to the JSON file using Web3 library and Solc.

The problem is the following: Sometimes, transactions are failing for multiple reasons, such as:

Error: The contract code couldn't be stored, please check your gas limit.
Error: Invalid JSON RPC response: ""
Error: Returned error: known transaction: 81fef157995faa9fe32b685e2c5b8d274612a6c2a31fa32008d06e8e3ea05cb8
Error: Failed to check for transaction receipt:

Block time is set at 0 (if I understood well, every incoming tx is automatically added to a block), the gas limit is very high (0x346DC5D638865) and gas price is set to 0 (and even so, accounts are well funded).

As an example, for a benchmark of 100 functions launched by second, that have to deploy a smart-contract and execute 1 send/1 call function, benchmark duration being 50 seconds, results are the following:

[50037.15841400018] Tasks launched: 1891
[50037.18162100017] Tasks successfully finished: 561
[50037.19864200009] Benchmarks functions launched: 5000
[50037.21361899981] Benchmarks functions done: 567
[50037.228593999986] Benchmarks functions failed: 1600

Only 567 function execution was completed, 1600 failed and others were executing when benchmark stops ...

https://github.com/nicoSix/sc-archi-gen/tree/supply-chain-bench my code is available here, but the 2 main functions are the following:

//runWorkflow
//- read a json file containing benchmark instructions, deploys linked smart-contract then perform each function at once
async function runWorkflow(idBench) {
    benchmarkLaunchedCount++;
    var execResult = true;
    var startTime = performance.now();
    var machineId = allocateTaskToMachine();
    var scWorkflow = require("./contracts/" + benchmarkContractFN.split('.').slice(0, -1).join('.') + ".json")

    try {
        var contract = await deployContract(machineId, scWorkflow[0]);
    }
    catch(e) {
        execResult = false;
        if (VERBOSE) tlog(e);
    }

    if(execResult) {
        for(var i = 1; i < scWorkflow.length; i++) {
            opLaunchCount++;

            try {
                var parameters = resolveParameters(scWorkflow[i].parameters, machineId);
                var execResult = await contract.methods[scWorkflow[i].name](...parameters)[scWorkflow[i].type]({from: machines[machineId].address, gas: '0x346DC5D638', gasPrice: '0x0'});

                if(execResult.transactionHash || execResult) {
                    opSuccessCount++;
                }
                else {
                    execResult = false;
                    break;
                }
            }
            catch(e) {
                execResult = false;
                if (VERBOSE) tlog(e);
            }
        }
    }

    var endTime = performance.now();

    machines[machineId].load -= 1;

    ... just saving results after this line ...
}

//deployContract
//- deploys a smart-contract
async function deployContract(machineId, constructorDef) {
    // Compile the source code

    const parameters = resolveParameters(constructorDef.parameters, machineId);

    //Deploy the contract and return instance
    var contract = await new machines[machineId]["provider"].eth.Contract(contractCode.abi)
        .deploy({
            data: '0x' + contractCode.bytecode,
            arguments: parameters
        })
        .send({
            from: machines[machineId].address,
            gas: '0x346DC5D638',
            gasPrice: '0x0'
        })

    return contract;
}

What could cause transaction failure? Could it be bad management of nonce or other related stuff in Web3? Could nodes struggle that much for that amount of incoming transactions?


texts:
I get a reference to my contract on Rinkeby like this:

const MyContract = web3.eth.contract(MyContractABI)
  myContract = MyContract.at(contractAddress)

I can call this function fine:

myContract.functionOne(addressParamater, function(err, res) {
    console.log(res)
  });

But when I call :

myContract.functionTwo(addressParamater, function(err, res) {
    console.log(res)
  });

I get this error:

Unhandled Rejection (Error): invalid address

I'm passing an address as a paramater to both functions, and I know its well formated since when I do this:

web3.isAddress(addressParamater);

I get true

Any idea what could be going on?

Thanks!


texts:
I would like to know how does the process of authentication work and how are the private keys used for signing transactions?

For eg while using email : We log-in to our accounts and send as many mails as we want...but in this case each transaction is signed with the users private key.

How is this implemented while developing an application?

Also what is a blockchain signer?


texts: How to simulate the DAO attack with Truffle and testRPC

texts: I want to simulate the DAO recursive attack. Can you please define the steps for simulating the attack with Truffle using the TestRPC.


texts: Running Npm init on powershell but its stuck and I can't proceed

texts:
I can't run truffle commands on windows powershell so I went to do the steps
that I got here.
However npm init got me stuck and I can't proceed:

Here is the stuck screen:

EDIT: After I uninstalled and reinstalled truffle


texts: Cannot declare web3 object in JavaScript

texts:
When I try to declare a web3 object It's always undefined.

I'm writting in JavaScript and using Infura as my provider for the ETH mainnet. I also tried with a local blockchain instead of Infura, but it also didn't work. I'm new to blockchain development and I'm kinda stuck on this. I know it must be something very small I'm missing, maybe I forgot to install something. I've also spent quite some time researching my problem, but I just can't seem to get it to work.

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
        <script type="text/javascript" src="https://raw.githubusercontent.com/ethereum/web3.js/master/dist/web3.min.js"></script>
    </head>
    <script>
        const rpcURL = "https://rinkeby.infura.io/INFURA_PROJECT_ID";
        const address = 'MY_WALLET_ADDRESS';

        const web3 = new Web3(new Web3.providers.HttpProvider(rpcURL));

        web3.eth.getBalance(address, (err, wei) => {
            myBalance = web3.utils.fromWei(wei, 'ether')
            console.log(myBalance)
        })
    </script>
</html>


texts: Replacing pending deploy tx with truffle

texts:
I deployed my contract with default params using truffle migrate --network mainnet --reset the gas was too low and got my tx pending for more than 20 hours already. I wanted to replace the tx with new one and dropping the old tx. How do I do it on truffle? My new truffle-config.js is this:
mainnet: {
      provider: () => new HDWalletProvider(
        process.env.PRIVATE_KEY,
        process.env.NODE_URL
      ),
      network_id: 1,       //mainnet
      gasPrice: 75000000000
    },

Is there a way to set the nonce there to drop and replace the tx?


texts: How to detect mining based on power consumption?

texts: Is there any data from power consumption of ASICs to understand the mining process? Is there any pattern to know about that?


texts: How to handle refer by register functionality in Dapp with Smart Contract?

texts: I've just started to learn  solidity programming..Firstly, I have a register page, in which the metamask opens up an popup and connect the user address to my dapp by registering the user on their platform..I just want to know how do I store user data.How do I know if the user has register before, if yes then show him/her an error that they're already registered and about the refer page, how do we store the new user respective  to the referral account.. .Why don't anyone have an article related authorization on the web?? I guess it's the core component of any web app or dapp..Do we have to store user data on the blockchain on not ??


texts: Can someone explain the meaning of derivation path in wallet in plain English (such as m/44'/60'/0'/0)?

texts:
Like m / purpose' / coin_type' / account' / change / address_index
which gives say a value of m/44'/60'/0'/0

What is the meaning of "m", purpose, coin type, etc.


texts: contract reference another contract, what ABI information needed?

texts:
To reference another contract, the ABI is easily included like this. What information needs to be there? The function name, I guess, what about accessability such as public/private/internal/external/pure/view, or if it returns a type and what it returns? Asking for what is needed, not so much what looks good or makes it more human readable.

contract A { function foo() public returns (uint) {} }

contract B {

    A a = A();


texts: Subscribe to new txpool transactions on geth node

texts:
I know that the state of the txpool of a geth node can be queried using the txpool API. However, I was wondering if it is somehow possible to subscribe to new transactions entering a geth node's txpool, possibly on a websockets or local socket rpc connection? I'd like to write the program that subscribes to new txpool transactions in Go as well.
I discovered this subscription in go-ethereum internally, but it doesn't look like it's exposed, unfortunately.
Note that I'm not only talking about local pending transactions (answered here), but all transactions arriving to the txpool.
Background: I'd like to do research on frontrunning. The authors of the Flash Boys 2.0 paper released their geth fork on github, which they used to observe gas auctions in the txpool. However, using a fork is not as reusable and maintainable than having the possibility to extend geth's API so that external applications can subscribe to txpool udpates.


texts: truffle version and solcjs --version returns different versions

texts:
I want to change solc version on my system(downgrade from 0.5.16 to 0.4.17). I tried uninstalling it with

npm -g uninstall solc

and then installed with

npm -g install solc@0.4.17

but it does not work, "truffle version" still returns "Solidity v0.5.16 (solc-js)" when I run it from my CMD. However when I run

solcjs --version

separately, the correct version is returned - 0.4.17+commit.bdeb9e52.Emscripten.clang

How can I change solc version on my system?


texts: I sell my tokens, how do I get the token to automatically pass on to the buyer

texts:
I issue a token and now I want to sell my token.  How is it possible that when a buyer transfers BNB to my wallet in MetaMask, the buyer will automatically receive my token.  My token uses the BSC platform

How do I transfer a BNB amount to the BSC address in Metamask?
And automatically get back 1 of the tokens I have reserved.
For example I have token: xxx
When I transfer some bill to the BSC address in Metamask
Thi automatically I will receive back 1 amount of token: xxx
please help me


texts: What is the v part of transaction signature?

texts:
If I understand correctly when we send a transaction, we send an unsigned part m and a signature consisting of v, r, s. Each node verifies the signature by checking:
hash(m,r) * publicKey + r = s * generator
the generator is known, where as the public key cannot be restored from the address and has to be computed. This is where the v part of the signature comes in. Can someone explain how is v defined and how does it help us retrieve the public key? Thanks a lot.


texts: How can you concatenate uints in Solidity?

texts:
I want to generate tokenIDs based on the properties generated in the contract.
         uint256[5] memory tokenID;

         for (uint i = 0; i < 5; i++) {
             tokenID[i] =  1 + item[i] + property[i] + level[i];
         }

So if the item is 14, the property is 4, and the level is 51, then the combined uint would 114451.
As I see it now I need to convert every uint to a bytes32, convert bytes32 to a string, and then I'm not even sure if there is a simple way to converts string to a uint. Is there a way to do this without much gas, or do I need to look at a more complicated naming convention?
Edit: Forgot to add the current solution which doesn't allow for scaling:
tokenID[i] =  (((item[i]+1) * 10**5) + (property[i] * 10**4)) + level[i]
Item goes up to 1000, property goes up to 100, and level is always under 10.


texts: Downloading all the current smart contract

texts:
I want to make a "big-data" analysis of smart contracts,

Is there a "crawler" out there, to retrieve all the smart-contract that are "active"?

(Another question is how can I verify whether the contract is still active)

Thank.


texts: Which is cryptographically harder (higher cost to break), sha256 or secp256k1?

texts: Which has a higher computational cost, to find the private key associated with a signature, or, a pre-image of a sha256 hash?


texts: Error when using function import in solidity and vscode

texts:
What am I doing wrong? When I use the ctrl + left mouse key combination, vscode displays the Transfer function in the ERC20.sol file with no errors. But when I call the Transfer function at the file that uses the import file ERC20.sol, I get this error

The contents of the Transfer function at ERC20.sol are:

  event Transfer(address indexed _from, address indexed _to, uint256 _value) ;


texts: Remixd Error when Hooking up shared folder to Remix

texts:
The first type of error occurs when I run the listener on my Windows 10 using a terminal (powershell). The listener (remixd) starts OK then when I go to connect to the browser session I get the following:
PS C:\Windows\System32>  remixd -s D:\zz210201_shared_folder --remix-ide https://remix.ethereum.org
[WARN] You may now only use IDE at https://remix.ethereum.org to connect to that instance
[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.
[WARN] Symbolic links are not forwarded to Remix IDE

Wed Feb 03 2021 18:29:11 GMT+0700 (Indochina Time) Remixd is listening on 127.0.0.1:65520
setup notifications for D:\zz210201_shared_folder
Error: Error: EPERM: operation not permitted, lstat 'D:\System Volume Information'

When I use the desktop version I get the following errors when trying to make the connection.
Wed Feb 03 2021 18:13:57 GMT+0700 (Indochina Time) Remixd is listening on 127.0.0.1:65520
Wed Feb 03 2021 18:14:14 GMT+0700 (Indochina Time) Connection from origin package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod rejected.
Wed Feb 03 2021 18:14:15 GMT+0700 (Indochina Time) Connection from origin package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod rejected.
Wed Feb 03 2021 18:14:29 GMT+0700 (Indochina Time) Connection from origin package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod rejected.
Wed Feb 03 2021 18:14:30 GMT+0700 (Indochina Time) Connection from origin package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod rejected.
Wed Feb 03 2021 18:18:31 GMT+0700 (Indochina Time) Connection from origin https://remix.ethereum.org rejected.
Wed Feb 03 2021 18:18:32 GMT+0700 (Indochina Time) Connection from origin https://remix.ethereum.org rejected.

Not sure how to proceed to get it working. Any clues appreciated.
stopped using any proxy and the behavior did change a bit. Still get the EPERM error and can't read the directory from the remix browser page, but I can create and write files to localhost. Just can't display what is in localhost.


texts:
I have seen that some smart contracts (not tokens) have a text name in etherscan. Is it possible to add it to my contract? How I could do it?

I have try to add a public variable "name" but it is not worked.

For example ZRXTokenContract:
https://etherscan.io/address/0xe41d2489571d322189246dafa5ebde1f4699f498


texts: Can you write a contract which bytecode can be proven that can only send ether to a given address?

texts: I'm thinking maybe looking through the OP codes, you can realize that the contract can only send money to a given address. Would this kind of formal verification be hard to write?


texts: How to test kill function including selfdestruct()?

texts:
there.

I'm coding kill function below:

function kill() public onlyOwner returns (bool) {
  selfdestruct(msg.sender);
  return true;
}

and my unit test code:

function testOwnerCanKillContract() public {
  XToken xtn = XToken(DeployedAddresses.XToken());
　bool isKilled = nmt.kill();
　Assert.equal(isKilled, true, "Owner should have to kill contract with selfdestruct.");
}

However, test fails with revert error after $ truffle test:

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

So does anyone know how to resolve this problem, or any idea?

and also, my enviromnent is here:
Truffle v5.0.5 (core: 5.0.5)
Solidity v0.5.0 (solc-js)
Node v10.9.0

Thanks in advance!


texts: What is the cost of using a Chainlink Oracle?

texts:
I use the market.link to check available jobs and each job has its own price in terms of link. My question is how many times this fee will be paid?
For example:
Let's say the API GET request costs 0.01 link. If I trigger a function that triggers ORACLE for a GET call, are we going to pay only 0.01 no matter how many miners execute it? Or is it going to cost 0.01 x numberOfMiners since each transaction will run by all the miners of the network?


texts:
I am trying to find a way to use the JSON-RPC calls to scan for new tokens on the BEP-20 Binance chain.
I cannot find any documentation or information regarding this.


texts: Web3.py transfer call failing, not sure why

texts:
I am trying to learn how to work with ethereum and ERC20 tokens. I have managed to setup ganache and deploy my contract. I can see it on ganache and I can connect and read the balance of the token on the contract with no problems. I am moving onto making transactions for the token.

Below is the code I am trying to use.

from web3 import Web3
w3 = Web3(Web3.HTTPProvider("http://127.0.0.1:7545"))

# Load contract
ABI_PATH="myabifile.json"
truffleFile = json.load(open(ABI_PATH))
contract = w3.eth.contract("0xE6b7aD1717AD978d4Cf573FD750863B16c362890", abi=truffleFile["abi"])

# Set default account
w3.eth.defaultAccount = w3.eth.accounts[0]

make a transfer with an address on the network
tx_hash = contract.functions.transfer("0x5eB642aD40467499783868EAd82F41cf0730f6e4", 10).transact()

I keep getting the following error ...

{'message': 'execution error: revert', 'code': -32000, 'data': {'stack': 'Error: execution error: revert\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/utils/gasEstimation.js:12:11\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/ethereumjs-vm/dist/runTx.js:74:9\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/async/dist/async.js:969:16\n    at next (/Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/async/dist/async.js:5225:18)\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/ethereumjs-vm/dist/state/cache.js:160:13\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/util.js:51:36\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:52:16\n    at done (/Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:246:17)\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/merkle-patricia-tree/node_modules/async/lib/async.js:44:16\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/database/levelupobjectadapter.js:110:7\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/async/dist/async.js:473:16\n    at iteratorCallback (/Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/async/dist/async.js:1064:13)\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/async/dist/async.js:969:16\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/level-sublevel/shell.js:53:51\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/node_modules/level-sublevel/nut.js:109:13\n    at /Applications/Ganache.app/Contents/Resources/app.asar/node_modules/ganache-core/lib/database/filedown.js:64:7', 'name': 'Error'}}

I see it has something to do with gasEstimation, but I can't figure out what I am doing incorrect.

I have been following a few tutorials, this one is the one I have been following for this - https://www.youtube.com/watch?v=p5W67zTQFRM&list=PLS5SEs8ZftgVn38FOhXvLc0PoX_0hnJO9&index=4

Any help pointing me in the right direction would be appreciated.


texts: Metamask removed the cancel button for a transaction but ive waited for like a week and the transaction is not done

texts: So i have a transaction running on the eth mainnet which is pending but it has been over 1 week now and i have sped up the transaction many times. Now, i dont even have the ability to cancel the transaction. How do i end this transaction as im unable to do anything else on the eth mainnet without the transactions becoming stuck.


texts: Why are geth testnet nodes not communicating

texts:
I'm on Windows 10 pro. Using a reasonable genesis block, I have set up 3 geth instances (01,02, 03) on the same laptop called as follows:

geth ^
 --identity "XxxxxTest01" ^
 --genesis C:\WORK\Ethereum\Geth\XxxxxTest_Genesis.json ^
 --datadir C:\WORK\Ethereum\Data\XxxxxTest01 ^
 --networkid 4999 ^
 --rpc ^
 --rpcport 40901 ^
 --rpccorsdomain "*" ^
 --rpcapi "db,eth,net,web3" ^
 --port 30901 ^
 --nodiscover ^
 --maxpeers 10 ^
 --ipcpath \\.\pipe\geth.XxxxxTest01.ipc ^
 --gasprice 1 ^
 --etherbase "0x37...." ^
 --unlock "0x37...." ^
 --password C:\WORK\Ethereum\Geth\Xxxxx01.pw.txt ^
 --cache 1024 ^
 --verbosity 6 ^
 2> C:\WORK\Ethereum\Geth\Xxxxx01.log ^
 console

Once these are running, I can open three consoles like this:

geth --preload C:\WORK\Ethereum\Geth\Xxxxx01Peers.js ^
attach ipc:\\.\pipe\geth.XxxxxTest01.ipc

The .js contains the necessary admin.addPeer(..) calls. The output of admin.peers looks ok. I have two problems:

1) I can only mine on one of the 3 eth instances. Once I have mined on one, and stopped mining via miner.stop(), any attempt to start mining on one of the other instances results in

I0628 15:53:41.873442 ethash.go:259] Generating DAG for epoch 0 (size 1073739904) (0000000000000000000000000000000000000000000000000000000000000000)
panic: ethash_full_new IO or memory error

goroutine 228 [running]:
panic(0xcfc560, 0xc0841b2c40)
....

Note that whatever is mined does show in the 2 other instances in real time, so the instances do communicate with each other. In terms of memory, only about 6 of 16 GB is used.

2) the nodes do not synchronize correctly, so if a transfer is done on node 2, this shows in the log as

I0628 16:01:30.481569 eth/handler.go:776] broadcast tx to 2 peers

but the other two logs show nothing. If I then mine on node 2, then the transaction appears in nodes 1 and 3. If I mine in another node, then the transaction is lost.

NB after closing all instances, and restarting, I can start mining on any one (but only one) instance.

Any ideas what the problem might be?


texts: Boolean returning method: validate input with "if" or require()?

texts:
Open Zeppelins mintable token has the method mint(address _to, uint256 _amount) ... returns (bool) to create new tokens.
I'd like to introduce a supply limit and am unsure how to validate the input correctly. Should I use require(), throw, or is it preferred to return a boolean as the caller might expect?

What are the consequences of these options?

function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
    // TODO: validate amount is not too big.

    // Validate with require():
    // require((totalSupply + _amount) <= SUPPLY_LIMIT);

    // Or validate with if:
    // if ((totalSupply + _amount) > SUPPLY_LIMIT) return false;

    // Or throw?
    // if ((totalSupply + _amount) > SUPPLY_LIMIT) throw;

    totalSupply = totalSupply.add(_amount);
    if (totalSupply == SUPPLY_LIMIT) mintingFinished = true;

    balances[_to] = balances[_to].add(_amount);
    Mint(_to, _amount);
    Transfer(0x0, _to, _amount);

    assert(totalSupply <= SUPPLY_LIMIT);

    return true;
}

The calling contract looks like this:

contract Crowdsale {

    // ...

    function buyTokens(address beneficiary) public payable {
        require(beneficiary != 0x0);
        require(validPurchase());

        // ...
        token.mint(beneficiary, tokens); // return value not used
        // ...
  }
}


texts: monitoring deposit or withdraw using web3js

texts:
I know I can send ether to another account using web3.eth.sendTransactions. I also want to get confirmation when a transaction has been successfully broadcasted to the ethereum network, or when an account received ether from another account.

How can I do this with web3?


texts: How to get my node listed on Rinkeby testnet stats?

texts: Hey all I'm running a full node for rinkeby testnet, but unfortunately I could neither find it on https://www.rinkeby.io/#stats nor https://ethernodes.org/network/4/nodes, I'm curious how to be eligible for listing on those pages?


texts: How do I obtain the TokenID of an ERC721 token through etherscan API transaction? E.g. CryptoKitty TokenID

texts:
I want to be able to find the TokenID of a Crypto Kitty being sold.
The transaction returned from by the etherscan API is such:
{
  blockNumber: '11711690',
  timeStamp: '1611403229',
  hash: '0x8f8d4e163e90c8db91672f443b0896f157d45fc32c3ccf74d131137eedbdd896',
  nonce: '4',
  blockHash: '0xbdd67604d6cc7844f151a38360753ad96fa234bd9cf199c6cf14317ebb4fd0ad',
  transactionIndex: '147',
  from: '0x65274ae6d0d4f88818b600c4b3435c868f5dad4c',
  to: '0xb1690c08e213a35ed9bab7b318de14420fb57d8c',
  value: '2527858781343926',
  gas: '164016',
  gasPrice: '43000000000',
  isError: '1',
  txreceipt_status: '0',
  input: '0x454a2ab3000000000000000000000000000000000000000000000000000000000005a5a3',
  contractAddress: '',
  cumulativeGasUsed: '9793966',
  gasUsed: '27036',
  confirmations: '5702'
}

By looking at the transaction on etherscan I can see that the TokenID is 587058 - https://etherscan.io/tx/0xc7e09024a41841d6acb5933ab983a68bb4433a94e3167a2a893be3ea4387fad6
However that is not recorded anywhere on the transaction... Is there any way that I can derive the token ID? Or, is there an alternative way that I can find the token programmatically/via API? I intend to use the TokenID to then obtain further information about the particular Kitty.


texts: How to connect local ganache node with epirus

texts:
I tried apirus to connect to local ganache node.

Ganache node is running on localhost:7545.

git clone https://github.com/blk-io/epirus-free.git
cd epirus-free
docker-compose pull
NODE_ENDPOINT=http://docker0:7545 docker-compose up

But couldn't connect.  Error log says docker0 is unknowHost.

api_1      | 2020-03-26 07:05:52.323 ERROR 1 --- [   scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.
api_1      |
api_1      | java.util.concurrent.CompletionException: java.net.UnknownHostException: docker0
api_1      |    at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
api_1      |    at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
api_1      |    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(Unknown Source)
api_1      |    at java.base/java.lang.Thread.run(Unknown Source)
api_1      | Caused by: java.net.UnknownHostException: docker0
api_1      |    at java.base/java.net.InetAddress$CachedAddresses.get(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName0(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
api_1      |    at java.base/java.net.InetAddress.getAllByName(Unknown Source)
api_1      |    at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
api_1      |    at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:160)
api_1      |    at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:125)
api_1      |    at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:7

How to connect to local ganache node from docker container ??


texts: Connecting wallet to custom test network

texts:
I want to connect my EthereumWallet app up to my private network, I fire up the app but it is trying to connect to the default test network. I get the error

Node type: geth
Network: test
Platform: darwin (Architecure x64)

...  config="{ChainID: 3 Homestead: 0 DAO: <nil> DAOSupport: true EIP150: 0 EIP155: 10 EIP158: 10 Engine: ethash}"
INFO [05-18|15:30:40] Disk storage enabled for ethash caches   dir=/Users/marklar/Library/Ethereum/testnet/geth/ethash count=3
INFO [05-18|15:30:40] Disk storage enabled for ethash DAGs     dir=/Users/marklar/.ethash                              count=2
INFO [05-18|15:30:40] Initialising Ethereum protocol           versions="[63 62]" network=3
INFO [05-18|15:30:40] Loaded most recent local header          number=949371 hash=308cb6…370760 td=670950083564135
INFO [05-18|15:30:40] Loaded most recent local full block      number=949371 hash=308cb6…370760 td=670950083564135
INFO [05-18|15:30:40] Loaded most recent local fast block      number=949371 hash=308cb6…370760 td=670950083564135
WARN [05-18|15:30:40] Blockchain not empty, fast sync disabled
INFO [05-18|15:30:40] Starting P2P networking
Fatal: Error starting protocol stack: listen udp :30303: bind: address already in use

What am I missing here to get my wallet connecting to my custom test network? Here is my local setup -

CustomGenesis.json

{
  "config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "nonce": "0x000000000000002a",
  "difficulty": "0x20000",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "author": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x",
  "gasLimit": "0x2fefd8",
  "alloc": {}
}

Then I'm firing this up with

geth --rpc --networkid=39318 --maxpeers=0 --datadir=./datatest --ipcpath=./datatest/geth.ipc --mine --minerthreads 1 console CustomGenesis.json

This seems to work fine, I get a bunch of mining output

INFO [05-18|15:28:50]  mined potential block                  number=540

hash=3973bc…6e5529
INFO [05-18|15:29:08] Successfully sealed new block            number=541 hash=2a25df…0192a6
INFO [05-18|15:29:08]  block reached canonical chain          number=536 hash=61237c…bf0cb5
INFO [05-18|15:29:08]  mined potential block                  number=541 hash=2a25df…0192a6
INFO [05-18|15:29:08] Commit new mining work                   number=542 txs=0 uncles=0 elapsed=171.074µs
INFO [05-18|15:29:10] Successfully sealed new block            number=542 hash=2419d9…29a87b
INFO [05-18|15:29:10]  block reached canonical chain          number=537 hash=fd5016…7a94a8
INFO [05-18|15:29:10]  mined potential block                  number=542 hash=2419d9…29a87b
INFO [05-18|15:29:10] Commit new mining work                   number=543 txs=0 uncles=0 elapsed=277.916µs
INFO [05-18|15:29:15] Successfully sealed new block            number=543 hash=ee3af6…c45936


texts: Solidity compiler,error:not found browser IERC20.sol

texts:
Who can halp me with error and codig fleshloan?
I try use for my contract http://remix.etherium.org and i have a promlem with compiller,i use code from official docs aave https://www.docs.aave.com/developers/guides//flesh-loans and pragma solidity compiler 0.6.12 dispey me error: Not found browser /IERC20.sol.
I think a have a promlem with import....,and it promlem for me!
I dont understand this error and what can i do.
My start fragmets code:
pragma solidity 0.6.12 ;

import { FlashLoanReceiverBase }  from "./FlashLoanReceiverBase.sol"  ;
import { ILendingPool }  from "./ILendingPool.sol"  ;
import { ILendingPoolAddressesProvider } from "./ILendingPoolAddressesProvider.sol"  ;
import { IERC20 } from "./IERC20.sol  ;

contract Myv2 is FleshLoanReceiverBase {

  function ...........

I think remix compiler dont see this 4 import!
Please to help me .


texts:
I have setup one test node on my machine. When trying to connect to Metamask, I keep on receiving below messages on the node console and am unable to connect with node using Metamask.
2019-06-14 14:48:32  Accepted a new tcp connection from 127.0.0.1:54536.

2019-06-14 14:48:33  Accepted a new tcp connection from 127.0.0.1:54538.

2019-06-14 14:48:34  Accepted a new tcp connection from 127.0.0.1:54540.

2019-06-14 14:48:34  Accepted a new tcp connection from 127.0.0.1:54541.

2019-06-14 14:48:34  Accepted a new tcp connection from 127.0.0.1:54542.


texts:
I have the following solidity code:
pragma solidity ^0.6.0;

import "./DappToken.sol";

contract DappTokenSale {
    address payable public admin;
    DappToken public tokenContract;
    uint256 public tokenPrice;
    uint256 public tokensSold;

    event Sell(address _buyer, uint256 _amount);

    constructor (DappToken _tokenContract, uint256 _tokenPrice) public {
        admin = msg.sender;
        tokenContract = _tokenContract;
        tokenPrice = _tokenPrice;
    }

    function multiply(uint x, uint y) internal pure returns (uint z) {
        require(y == 0 || (z = x * y) / y == x);
    }

    function buyTokens(uint256 _numberOfTokens) public payable {
        require(msg.value == multiply(_numberOfTokens, tokenPrice));
        require(tokenContract.balanceOf(address(this)) >= _numberOfTokens);
        require(tokenContract.transfer(msg.sender, _numberOfTokens));

        tokensSold += _numberOfTokens;

        emit Sell(msg.sender, _numberOfTokens);
    }

    function endSale() public {
        require(msg.sender == admin);
        require(tokenContract.transfer(admin, tokenContract.balanceOf(address(this))));

        // UPDATE: Let's not destroy the contract here
        // Just transfer the balance to the admin
        //admin.transfer(address(this).balance);
    }
}

Everything works except for the endSale() function. When I call it, it throws an error. I can't understand what is the problem. Please help! Thanks!


texts: Metamask account related to Geth account?

texts:
I've created a Metamask account and now I want to import it to Geth. I don't have a Geth account. I've exported the private key to a .txt file. When I import the file Geth asks me to insert 2 times the passphrase. The question is, do I have to put the same password (Metamask) or create a new one? Is it the same account?

Thank you


texts: Mining stops after generating DAG for epoch

texts:
I first initiate the node using the genesis file with the command:

>geth init genesis.json

Then i start the blockchain network using the following command:

>geth --identity "node1" --rpc --rpcport "8001" --rpccorsdomain "*" --datadir "node1" --port "30304" --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --rpcapi "db,eth,net,web3" --autodag --networkid 123 --nat "any"

Then i open another command prompt and type

>geth attach

I could've used 'console' but i wanted to monitor network log properly.

Now i created an account and gave the command:

>miner.start()

I0310 11:14:39.402000 eth/backend.go:454] Automatic pregeneration of ethash
DAG ON (ethash dir: C:\Users\Rahul13615\AppData\Ethash)
I0310 11:14:39.403000 eth/backend.go:461] checking DAG (ethash dir:
C:\Users\Rahul13615\AppData\Ethash)
I0310 11:14:39.404000 node/node.go:296] IPC endpoint opened:
\\.\pipe\geth.ipc
I0310 11:14:39.407000 node/node.go:366] HTTP endpoint opened:
http://localhost:8001
I0310 11:15:31.755000 miner/miner.go:119] Starting mining operation (CPU=4
TOT=5)
I0310 11:15:31.756000 miner/worker.go:539] commit new work on block 1 with 0
txs & 0 uncles. Took 1ms
I0310 11:15:31.757000 ethash.go:259] Generating DAG for epoch 0 (size
1073739904)
(0000000000000000000000000000000000000000000000000000000000000000)
I0310 11:15:32.717000 ethash.go:276] Done generating DAG for epoch 0, it
took 961ms

After this no new blocks are commited. It just stopped or is running slow. How should i remedy this situation and make it run fast?


texts: How can i get peers on my ethereum light node?

texts:
I'm running a light node on a DigitalOcean VPS in order to use it to query data on the ethereum blockchain, but suddenly it stopped answering to any of my requests and i noticed that i always have 0 peers:
INFO [03-02|21:49:32.033] Looking for peers                        peercount=0 tried=16 static=0
INFO [03-02|21:49:42.036] Looking for peers                        peercount=0 tried=10 static=0
INFO [03-02|21:49:52.039] Looking for peers                        peercount=0 tried=5  static=0
INFO [03-02|21:50:02.043] Looking for peers                        peercount=0 tried=9  static=0
INFO [03-02|21:50:12.046] Looking for peers                        peercount=0 tried=8  static=0
INFO [03-02|21:50:22.050] Looking for peers                        peercount=0 tried=12 static=0

Here is how i'm running the node:
geth --syncmode "light" --http --http.port 8545 --http.addr 0.0.0.0 --http.corsdomain '*' --http.vhosts '*' --http.api 'eth,web3' --ws --wsaddr="0.0.0.0" --wsorigins="*"

Am i doing anything wrong here? Or is it a problem with the chain itself, since i read there aren't a lot of peers being served for light nodes?


texts: Gets reverted when calling ERC20.transfer in a contract, not reverted when transferring 0

texts:
I have this code inside a contract

interface ERC20 {
//standard variables
  function allowance(address _owner, address _spender) constant       returns (uint remaining);
  function approve(address _spender, uint _value) returns (bool success);
  function balanceOf(address _owner) constant returns (uint balance);
  function transfer(address _to, uint _value) returns (bool success);
  function transferFrom(address _from, address _to, uint _value) returns (bool success);
}

...
    function multiERC20Transfer(address _token, address[] _addresses, uint[] _amounts)
      public
    {
        for(uint256 i=0;i<_addresses.length;i++){
            ERC20(_token).transfer(_addresses[i], _amounts[i]);
        }
    }

When I call this with amounts of [1, 0] it always gets reverted however when I do it with [0, 0] it succeeded.

Can anybody tell me what is wrong?

The contract that has this function is https://kovan.etherscan.io/address/0xfbdf97cdf6481f7b60b205916212f0e280a2f3d4#tokentxns

Thank you very much in advance


texts: Why some internal transactions can be successful and others fail

texts:
https://ropsten.etherscan.io/tx/0x8d5b9a6906b9f287c4b09333272f691a75655e470c128b78b3bc4a540c534190
In this transaction, I tried to send 10wei to 0x0000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000001,
 .....
0x0000000000000000000000000000000000000009
But the ethes sent to 0x0000000000000000000000000000000000000001 and several other accounts have failed, and the other part has succeeded. I don't know why this is so.
This is the source code of the contract.

  function getThisBalance() payable returns(uint, uint){
  for (uint i = 0; i < msg.value; i ++){
      address(i).send(1);
  }
  return (i, msg.value);

}


texts: Issues while sending raw transaction for calling smart contract methods?

texts:
let provider_url =
"https://ropsten.infura.io/v3/d5bca90ec3084aee8abd468fdf876a11";

this.web3Provider = new Web3.providers.HttpProvider(provider_url);
window.web3_ = new Web3(this.web3Provider);

let account = "0x25bA673A96acadD7A02f4c5834Ba80C1AF6b7758";

          let nonce = window.web3_.toHex(window.web3_.eth.getTransactionCount(account));

          let myPrivateKey = "****";

          let privateKey = new Buffer(myPrivateKey, "hex");
          let functionName = "markAttendance";
          let types = ["address", "uint", "uint256"];
          let args = [attendeeAddress, opinion, date];
          let fullName = functionName + "(" + types.join() + ")";
          let signature = CryptoJS.SHA3(fullName, {outputLength: 256}).toString(CryptoJS.enc.Hex).slice(0, 8);
          let dataHex = signature + coder.encodeParams(types, args);
          let data = "0x" + dataHex;
          // let nonce = web3.toHex();
          let gasPrice = window.web3_.toHex(20000000000); // 20 Gwei
          let gasLimitHex = window.web3_.toHex(4700000);

          let rawTx = {
            'nonce': nonce,
            'gasPrice': gasPrice,
            'gasLimit': gasLimitHex,
            'from': account,
            'to': '0xf77c958bdffee94c3f53eb763cffd646cde336d9',
            'data': data,
            'value': window.web3_.toHex(window.web3_.toWei("0.5", "ether")),
          }
          let tx = new Tx(rawTx);
          tx.sign(privateKey);
          tx.serialize();
          console.log(tx.validate());
          let serializedTx = '0x' + tx.serialize().toString('hex');
          console.log(serializedTx);
window.web3_.eth.sendRawTransaction(serializedTx, function (err, txHash) {
  console.log(err, txHash)
})

Contract

contract MarkAttendance {

struct AttendeeDetails {
    address attendance_giver;
    address attendee;
    uint attendance_opinion;
    uint256 timestamp;
    uint256 date_of_attendance;
}

//mapping of structure  for storing the attendeeDetails
mapping(uint => AttendeeDetails) public attendeeDetails;
uint public attendeeDetailsCount;

function markAttendance(address _attendee, uint _attendance_opinion, uint256 _date) public {
    attendeeDetailsCount ++;
    attendeeDetails[attendeeDetailsCount] = AttendeeDetails(msg.sender, _attendee, _attendance_opinion, now, _date);
    }
}

I am getting TXHASH but transaction is getting cancelled every time . what might be the issue i am doing ? can anyone suggest me any solution for this .

It works fine if I call the method from truffle console. I get a successful transaction receipt .

please find the screenshot


texts:
I am learning to develop smart contract using Solidity. Currently, I am working and test the feature of following crowdsale contract.

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/v1.8.0/contracts/crowdsale/Crowdsale.sol

This contract constructor has three different values.

rate
wallet address
token address

I am confused about the first one that is "rate". what value should i have to pass here ?

for example, I want to sell 1 token at cost of 1 ether then what should i pass here ?


texts: ETH stuck after cancelled due to "out of gas

texts:
I have seen another questions with the same problem but the answers given there do not work for me and therefor put my question here again.

I sent 0.5 ETH and 0.1 ETH from my Jaxx Wallet to Poloniex. Both transactions were cancelled due to "out of gas". According to many people the amount never left the wallet and should bounce back. It did for the 0.1 ETH but NOT for the 0.5 ETH. I tried everything, delete cache, sync with new phone, emailed Jaxx, emailed ETH but no one can help. This is the TX 0x7f75ed41a57b356c3df0d6828386d24311cef78a6e74fd0bccf38074315fad00. The weird thing is that my balance shown on the blockchain corresponds with the one in my wallet so as far as Jaxx is concerned it is synced correctly, but it is not. the 0.5 ETH is not shown.

I hope someone can help me with this. According to Etherium this should not be possible, but as you can see it can.


texts: Trying to Deploy copy of safenebula token smart contract on bsc testnet, keep getting an error. using remix on chrome. Is it problem with my remix?

texts:
The error I'm Getting -
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error. { "code": -32000, "message": "gas required exceeds allowance (30000000) or always failing transaction"

Code for the contract-https://bscscan.com/address/0xa1fd60c51c0bdac1ff5bb6067a24d61441e39569#code


texts: What is the core difference between send and transfer method of address payable in solidity?

texts:
I'm learning solidity I got two methods for transferring ether

<address payable>.send(1 ether)
<address payable>.transfer(1 ether)

Both are used to transferring ether to the recipient address but what is the difference between them, and where should we use transfer or send.


texts:
I understand the vision for Binance is to create a decentralized crypto exchange. Wouldn't it be more flexible to build their own block-chain rather than rely on an existing one (ETH)?

From my understanding tokens based on ETH is programmable because of ETH's VM. So programmers need to code in ETH's higher level language such as Solidity. It is very apparent that Solidity and its peers are not designed as a general-purpose programming language and not suitable for building and optimizing a distributed exchange.

Can someone explain to me why Binance does not build their own block-chain code from scratch?


texts: Offline creation of signed contract transactions with web3js v1.2.11

texts:
I'm attempting to sign a contract transaction offline using web3js v1.2.11.
signingAddr = //my eth address
signingPk = //my private key

// docs: The options object for the contract instance. from, gas and gasPrice are used as fallback values when sending transactions.
myContractInstance.options = {
  gas : 800000,
  gasPrice : 60000000000,
  value : 1000000000000000,
  from : signingAddr
}
//docs: Creates a transaction object for that method, which then can be called, send, estimated.
let tx = await myContractInstance.methods.myFunction(myParam1,myParam2)

//docs: "Signs an Ethereum transaction with a given private key."
let signedTx = await web3.eth.signTransaction(tx,signingPk)

console.log(signedtx)
//Error: The send transactions "from" field must be defined!

I've also tried with:
let tx = await myContractInstance.methods.myFunction(myParam1,myParam2).send({from:signingAddr})
//TypeError: Cannot read property 'filter' of undefined

Links to docs:

contract options
contract method call
signTransaction

I get that the tx object returned by the contract method is different to the tx object required for signTransaction. I'm unsure as to whether this is possible with web3.js?
It seems in earlier versions of web3js there was a getData function to get the needed call data.
How can I create valid signed contract call transactions offline using webjs v1.2.11?


texts: How to get current nonce that I need to send along with a transaction?

texts:
I wish you send nonce with every transaction so that I can store my nonce in DB and can override a specific transaction if it is pending for a while.

I know I can use eth.getTransactionCount("accountAddress"); to get the number of transactions sent from a specific address and this will be the nonce.

But, the transactionCount only returns the count of mined transactions and not exactly sent transactions.

For e.g., if I send a transaction with nonce 18, and it's not mined yet. And I try to send next transaction from the same account and I calculate transaction count for this address, the transaction count returns 18 (but I should send transaction with nonce 19, right?). So the question is simple:

How can I calculate the nonce for my next transaction keeping the case in mind where there may be pending transactions from the same address?


texts: When starting an auction for an .eth address on MyEtherWallet.com am I automatically placing a bid on the address or do I have to manually place a bid afterwards (and pay 0.01 ETH AGAIN)?


texts:
I under stand that a contract calling another contract will generate an internal transaction that is not recorded in the blockchain. This usually happens after CALL opcode.

I'm wondering if there are any other opcodes that can generate internal transactions? and if this is mentioned anywhere in the documentation


texts: What happens to generated but unsent transactions?

texts: I created a transaction in mew with nano s. I generated a transaction, clicked confirm on nano s, but missed the final step of clicking send transaction in the mew screen.  I can't find the transaction anywhere now, not listed in history...will this transaction eventually cancel and have my funds returned to wallet?


texts: Why do Ethereum clients download the entire blockchain?

texts:
Lets say that I am not interested in mining but instead just interested in one contract and its latest state. Why shouldn't my client discard all the other state on initiation, and also ignore any new blocks unless they include state changes related to the contract of interest?

Sure, some time later, I may find out that I want to "subscribe" to some other new contract that my client may have ignored up to that point. However, in that case my client could bootstrap the same process normally used on initial install and discard everything that's irrelevant to the contract in question.

To make the process more efficient (and avoid a lengthy syncing process each time I'm interested in a new contract) I could rely on the entity publishing the contract also including the block number representing the "genesis" block for that contract such that my client could discard any blocks prior to that block, and then skip any subsequent blocks that do not include any transactions for the said contract.

So.. to re-iterate the question, why do Ethereum clients download the entire blockchain rather than something along the above lines?

Note: for clarity, the context of the above question is a client with mining disabled.


texts:
I am doing a tutorial and I get the following message.

  Fatal: Error starting protocol stack: listen udp :30334: bind: Only
  one usage of each socket address (protocol/network address/port) is
  normally permitted.

I started the Node with:

  bootnode -nodekey masternode.key -verbosity 9 -addr :30333 INFO
  [09-04|05:47:38.287] UDP listener up
  self=enode://98b3ea03edd9d500313466467dc0178ac107c0c3ac529e21abfc9586f6886c98b7e5bcd0b2de27ee4c99cce6b53ef1cad7f4a9934275d8b611dfb96061a76abe@[::]:30333

Then I start my first signer.

  geth --datadir signer1/ --syncmode 'full' --port 30334 --rpc
  --rpccorsdomain "*" --rpcaddr 'localhost' --rpcport 8544 --rpcapi 'personal,db,eth,net,web3,txpool,miner,clique' --bootnodes
  'enode://98b3ea03edd9d500313466467dc0178ac107c0c3ac529e21abfc9586f6886c98b7e5bcd0b2de27ee4c99cce6b53ef1cad7f4a9934275d8b611dfb96061a76abe@127.0.0.1:30333'
  --networkid 3131 --gasprice '1' -unlock '08f8e3a8db8d4d2611d524188391b689b3b6ee00' --password
  signer1/passphrase.txt --mine

On to the second signer.

  geth --datadir signer2/ --syncmode 'full' --port 30334 --rpc
  --rpccorsdomain "*" --rpcaddr 'localhost' --rpcport 8544 --rpcapi 'personal,db,eth,net,web3,txpool,miner,clique' --bootnodes
  'enode://98b3ea03edd9d500313466467dc0178ac107c0c3ac529e21abfc9586f6886c98b7e5bcd0b2de27ee4c99cce6b53ef1cad7f4a9934275d8b611dfb96061a76abe@127.0.0.1:30333'
  --networkid 3131 --gasprice '1' -unlock '939fb51695c7b8892382ec253475c580377ecbd9' --password
  signer2/passphrase.txt --mine

As far as I understand they should listen to the same ports but I get an error instead.

I am using Windows 10.

Any hints?


texts:
What is the max length of solidity contract?

I have been trying to deploy a contract of 328 lines of code on Remix Browser with a locally created Quorum Private Permissioned Node.

I get the following error

  Note

  Quorum version: quorum-v2.4.0

  Genesis Config:

  "homesteadBlock": 0,
  "byzantiumBlock": 0,
  "chainId": 10,
  "eip150Block": 0,
  "eip155Block": 0,
  "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "eip158Block": 0,
  "isQuorum": true


texts:
I am making a smart contract with a Transfer function.

function transfer(address _to, uint256 _value) public returns(bool success) {
        //checking whether sender has enough number of tokens
        require(balanceOf[msg.sender] >= _value);

        //Transfer of Token ownership
        balanceOf[msg.sender] -= _value;
        balanceOf[_to]+=_value;

        emit Transfer(msg.sender,_to,_value);
        return true;
}

Error:

  //     Replacing 'DappToken'
  //    ---------------------
  // Error: Error: Error:  *** Deployment Failed ***

  // "DappToken" -- Invalid number of parameters for "Transfer". Got 1 expected 3!.

  //     at Object.run (C:\Users\rohit.mittal\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-migrate\index.js:84:1)
  //     at process._tickCallback (internal/process/next_tick.js:68:7)
  // Truffle v5.0.18 (core: 5.0.18)
  // Node v10.2.1


texts: Why does truffle require 4 authorizations for 1 contract + 1 migration?

texts:
Ok looking at this I see the Migrations.sol is setup by truffle to help you migrate versions of your contract?

I'm still getting prompted to unlock my wallet 2x per contract (2x per migration, 2x for my contract).

Why 2x instead of 1x?

truffle compile && truffle migrate --network=kovan
Using network 'kovan'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x5ca98daea12403079262477b929880c92db79f652fa575d248ca1c9f3699f69b
  Migrations: 0x8f6f3b66cc52c15b4ab02ada34a3db222ce87d70
Saving successful migration to network...
  ... 0xc0651e0c972162a555ff98c93251756ec96c135cfcd500faaddaeb0aec213a7b
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying IdleMiner...
  ... 0x36d241c8a51582381e769bc09e0e85bcf34ca8248e58109eebd5d5481732c06a
  IdleMiner: 0x7ba6f6878809a672e835354a95bf376ac51c210a
Saving successful migration to network...
  ... 0xfa1fd8d7fc5c863fa6bfd628358c8d9a6e7f087a85b9debe52542a00889e8a2a
Saving artifacts...


texts:
D:\Truffle Projects\payable>truffle test

Compiling your contracts...
===========================
> Compiling .\contracts\First.sol
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\First.sol
> Compiling .\test\TestFirst.sol

TypeError: Using ".value(...)" is deprecated. Use "{value: ...}" instead.
  --> /D/Truffle Projects/payable/test/TestFirst.sol:15:9:
   |
15 |         meta.receivePayment.value(2 ether)();
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^

Compilation failed. See above.
Truffle v5.2.4 (core: 5.2.4)
Node v14.16.0

This is my code:
First.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract First {
    function receivePayment() public payable {

    }

      function checkBalance() public view returns (uint) {
        return address(this).balance;
    }
}

TestFirst.sol:
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/First.sol";

contract TestFirst {

    uint public initialBalance = 10 ether;

    function testAge() public {
        First meta = First(DeployedAddresses.First());
        meta.receivePayment.value(2 ether)();

        Assert.equal(meta.checkBalance(), 2 ether, "Value should be equal to 2 ether");
    }

}


texts: Truffle CMD Bignumber to number; hex to string

texts:
A function in my contract when called on the truffle develop command line gives output in BigNumber format.
Here is what I wrote on the command line:

instance = contract.at('deployed address')

instance.getAge()

I tried instance.getAge().toNumber() but that throws an error saying that toNumber isn't defined. I checked How to convert BigNumber to Number in Truffle framework? however that doesnt seem to work on command line.

Similary outputs from functions returning bytes32 are in hex.I checked web3 return bytes32 string but web3.utils.toAscii(x) {x is any variable}  throws an error

  "Cannot read property toAscii of undefined"

I read the stack related to that and that also didn't help.


texts: when iam runing npm run dev it showing me this error, how to solve this

texts:
[![shiva@shiva-VirtualBox:~/sta$ npm run dev

  StarNotary@1.0.0 dev /home/shiva/sta
  lite-server

** browser-sync config **

{
  injectChanges: false,
  files: [ './**/*.{html,htm,css,js}' ],
  watchOptions: { ignored: 'node_modules' },
  server: {
    baseDir: [ './src', './build/contracts' ],
    middleware: [ [Function (anonymous)], [Function (anonymous)] ]
  }
}

[Browsersync] Access URLs:

 ----------------------------------
       Local: http://localhost:3000
    External: http://10.0.2.15:3000
 ----------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 ----------------------------------
[Browsersync] Serving files from: ./src
[Browsersync] Serving files from: ./build/contracts
[Browsersync] Watching files...
events.js:282
      throw er; // Unhandled 'error' event
      ^

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/shiva/sta/build/contracts'
    at FSWatcher.<computed> (internal/fs/watchers.js:169:26)
    at Object.watch (fs.js:1361:34)
    at createFsWatchInstance (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:38:15)
    at setFsWatchListener (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:233:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:429:19)
    at FSWatcher.<anonymous> (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:477:19)
    at FSWatcher.<anonymous> (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:482:16)
    at FSReqCallback.oncomplete (fs.js:166:5)
Emitted 'error' event on FSWatcher instance at:
    at FSWatcher._handleError (/home/shiva/sta/node_modules/chokidar/index.js:260:10)
    at createFsWatchInstance (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:40:5)
    at setFsWatchListener (/home/shiva/sta/node_modules/chokidar/lib/nodefs-handler.js:81:15)
    [... lines matching original stack trace ...]
    at FSReqCallback.oncomplete (fs.js:166:5) {
  errno: -28,
  syscall: 'watch',
  code: 'ENOSPC',
  path: '/home/shiva/sta/build/contracts',
  filename: '/home/shiva/sta/build/contracts'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! StarNotary@1.0.0 dev: `lite-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the StarNotary@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/shiva/.npm/_logs/2020-03-13T07_43_57_369Z-debug.log


texts: How to speed up data loading from the blockchain to the frontend?

texts:
I have a function that, according to the Unique ID of the car, gives me all its characteristics:

function getCarArray(uint _carId)
        public
        view
        returns (uint[12] memory)
    {
        CarData memory car = cars[_carId];

        uint[12] memory carInfo;

        carInfo[0] = car.statusEnd;
        carInfo[1] = car.number;
        carInfo[2] = car.load;
        carInfo[3] = car.capacity;
        carInfo[4] = car.region;
        carInfo[5] = car.status;
        carInfo[6] = car.abrasion;
        carInfo[7] = car.repairs;
        carInfo[8] = uint(car.currentOwner);
        carInfo[9] = uint(car.movingTo);
        carInfo[10] = car.resourceType;
        carInfo[11] = car.resourceAmount;

        return carInfo;
    }

When I call this method on the front end, in order to display all the cars and their characteristics, I have a very long time to process this whole. Suppose I have 1000 cars. I go through all the auto cycle

for(i=0;i<1000;i++){
     contractAddress.getCarArray(i)….
}

And then I get 1000 calls to the node, which results in a long time loading all the information.

That's the question - Is there any mechanism that will reduce the time to get all the available cars and information about them? Or on the front end side or on the Solidity side?


texts: how create address for each ethereum user

texts:
I have a group of Ethereum users how do I create an address for each user to  send their data on the network??
I want a way to create addresses for each user??


texts: Are miners eliminated in Proof of Authority?

texts:
According to this blog post by Vitalik on April 1st 2017, Ethereum will move from Proof of Work to Proof of Authority in 2018. He states:

  We have decided that the problem is too hard, and secure proof of
  stake is almost certainly unachievable. Instead, we are now planning
  to transition the Ethereum mainnet to proof of authority in 2018.

I was looking at getting into Ethereum mining, but now I am unclear what impact this decision has on mining profitability and risk.

I attempted to read this, and ended up in over my head. However, I found this quote under Proof-of-authority 101:

  For those not aware of how PoA works, it's a very simplistic protocol,
  where instead of miners racing to find a solution to a difficult
  problem, authorized signers can at any time at their own discretion
  create new blocks.

It seems to be saying that signers are the new miners. Is mining even necessary under a proof of authority system?

As someone new to block chain technology and Ethereum this is a little confusing.


texts: Is searching data stored in event logs prohibitively slow?

texts:
Augur uses event logs to store data that never needs to be accessed on-contract, since it is about 10x cheaper than on-contract storage.  However, I've noticed that retrieving event logs (e.g., using eth_getLogs) takes significantly longer than retrieval of on-contract data.  (I know filters let you listen for new event logs, but I'm specifically concerned with looking up old event logs.)

I don't really understand how event logging works under the hood.  Currently, we're indexing one (or more) of the log's arguments, then using eth_getLogs to search on the indexed argument.  For example, all Augur trades are logged and indexed by both market ID and account.  Our UI looks up trades made by the current account as part of its initial loading.  Right now this takes about 10 seconds to finish.  The eth_getLogs request is made asynchronously, and interleaved with the other initial market loading tasks, so it's not overly annoying at the moment.  However I'm concerned about how this will scale as both Augur and the Ethereum blockchain as a whole grow.

My question: will retrieving event logs become prohibitively slow as the blockchain becomes larger?  More specifically, what is the time complexity of eth_getLogs?  (Is blockchain size the relevant variable, or something else?  Is eth_getLogs even the correct RPC request for what I'm trying to do?  Basically any insight into this problem is appreciated!)


texts: Why does the Ethereum project have a coin?

texts:
As I understand, the Ethereum project provides an innovative technology for allowing developers to build distributed apps that can insert smart contracts in their blockchain and execute these on their distributed network.

Why do they need a coin for any of this? Couldn't they just have an auction market place where developers bid to execute apps and miners accept bids?


texts: how to create a smart contract that receives funds, displays addresses that sent the funds?

texts:
function safeWithdrawal() public afterDeadline {
    if (!fundingGoalReached) {
        uint amount = balanceOf[msg.sender];
        balanceOf[msg.sender] = 0;
        if (amount > 0) {
            if (msg.sender.send(amount)) {   //is this a condition or a command?
               emit FundTransfer(msg.sender, amount, false);
            } else {
                balanceOf[msg.sender] = amount;
            }
        }
    }

I was studying this code: https://www.ethereum.org/crowdsale and there was a part I didn't quite understand (see code above). My question is how does the contract iterate over every address that sent money to the contract and send it back... I can't see that in the code above. Also what does this condition (see code below) mean? From what I understand it looks like a command not a condition.

 msg.sender.send(amount)

Also How do you create a smart contract that receives funds, displays the addresses that sent the funds to the client? Like if in the crowdfunding dapp you would like to publicly display the addresses and how much they sent and even when they sent the funds.


texts:
I'm wondering if the following scenario could work with smart contracts. I'm very new to Blockchain so what I'm saying might sound too silly.

I have 10 users who are sharing a common resource. There is an efficient resource allocation mechanism (which I'm not gonna explain for the sake of simplicity). The allocation mechanism receives some information from each user and decides on a final allocation. I do not have a central trustable entity to run the mechanism and none of the users is trusted by all the others so we can choose them as the host to run the mechanism.

1- Does it make sense to say let us allow all the users run the mechanism as a smart contract and record the results in the blockchain?

2- If yes, the problem is that the mechanism needs the information from all the users to run properly and this information is private to each user. Is there any solution for this?


texts: Why Etherscan is reporting negative token balances?

texts:
I am wondering if its possible a holder to have negative balances as reported by Etherscan. Bellow are the links for the cases that I spotted:

KICK token holder 0xc12d1c73ee7dc3615ba4e37e4abfdbddfa38907e: https://etherscan.io/token/0xc12d1c73ee7dc3615ba4e37e4abfdbddfa38907e?a=0xc12d1c73ee7dc3615ba4e37e4abfdbddfa38907e#tokenAnalytics
WETH token holder 0x76481caa104b5f6bccb540dae4cefaf1c398ebea: https://etherscan.io/token/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2?a=0x76481caa104b5f6bccb540dae4cefaf1c398ebea#tokenAnalytics

How reliable is for applications that keep track of historical ERC20 token balances based on just ERC20's Transfer events and querying balanceOf for a given address? Does make sense to have negative balances at some point of time?


texts: How to test forked block on local machine?

texts:
Read this article How can I reliably induce a blockchain fork for testing purposes?.

Example from that thread is outdated, and need to be refreshed.

First my step is create initial chaindata from own genesis

geth --datadir=./1 init custom_genesis.json

custom_genesis.json

{
    "nonce": "0",
    "difficulty": "0x20000",
    "mixhash": "0x00000000000000000000000000000000000000647572616c65787365646c6578",
    "coinbase": "0x0000000000000000000000000000000000000000",
    "timestamp": "0x00",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x",
    "gasLimit": "0x2FEFD8",
    "alloc": {},
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "200000000",
    "gasLimit": "2100000"
}

which successfully created but not working when started

nohup geth --datadir=./1 --dev --nodiscover --networkid=15 --maxpeers=10 --verbosity=4 --preload ./utils.js --port=30305 --mine --minerthreads=1 > ./1/info.log 2>&1 &

and result

Fatal: Error starting protocol stack: database already contains an incompatible genesis block (have 5308cb1366d2a01a, new e5be92145a301820)

It is another problem, but question not in this point.

  --nodiscover

param forces to run app on autogenerated port, so usage of this param

  --port 30304

will be ignored. So adding manually nodes via param --bootnodes or in file <datadir>/static-nodes.json will not work.

Also such param

  admin.verbosity(6)

does not exist anymore.
Manually usage of admin.addPeer does not help, seems that nodes does not see each other and always answer true, even this node does not exist.( Please help anyone.

My 2 nodes runner script

nohup geth --datadir=./1 --dev --nodiscover --networkid=15 --maxpeers=10 --verbosity=4 --preload ./utils.js --port=30305 --mine --minerthreads=1 > ./1/info.log 2>&1 &

nohup geth --datadir=./2 --dev --nodiscover --networkid=15 --maxpeers=10 --verbosity=4 --preload ./utils.js --port=30306 --mine --minerthreads=1 > ./2/info.log 2>&1 &


texts: REMIX debugger invalid opcode before JUMP

texts:
I am testing simple ERC20 token creation with the following in remix:

pragma solidity ^0.5.0;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.4.0/contracts/token/ERC20/ERC20Detailed.sol";

contract TestToken is ERC20, ERC20Detailed {

    constructor () public ERC20Detailed("TestToken", "TKN", 18) {
        _mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
    }
}

I launch the contract and debug, but prior to every JUMP opcode, i receive an INVALID opcode in remix debugger.

If we look at _mint call in the stack trace (opcode 250 on compiler 0.5.13):

PUSH1 20
INVALID
JUMP
JUMPDEST

Is this merely a parse error or is every jump have an invalid opcode now? How can one discern this from an OPCODE used as an error?


texts: safewithdrawal on contracts not work with goal not met?

texts: I created a crowdsale contract and sent ethereum to it to test it. The contract was supposed to last for 3 months and then end at which point I thought all the eth would be returned to anyone who sent it if the goal was not met. The funds have not been returned and the safe withdraw function does not work from my owner account. What is going on here? I have 2 contracts like this for two different coins I created. I donated eth to those to get my coin kicked back to my wallet which worked. But now I want my eth back from the crowd sale contract yet I have no idea what to do..


texts: install ethereum wallet on local computer

texts: I want to be able to transfer ether from an online exchange to a private wallet on my local computer. How can I install a safe standard wallet? Do I need to install ethereum blockchain first? If so, no problem, but where and how? What is Mist?


texts:
This is a follow-up question of Split Contract Design Pitfall

Background: I have split my logic into two contracts A and B. A keeps the state and not ETH. All state change functions are only allowed to come from its owner, contract B. Contract B functions interface with public (and are payable).

Everything works now. However, as business logic grows, the state contract A is literally on the edge of running out of gas during deployment -- i.e., at 8M gasLimit, it only deploys if solc optimizer runs <= 1000, any optimization higher than that will fail the deployment out-of-gas -- which means I can not add even a one-line function in contract A.

My question is: Is there a way to further split state contract while my state struct/mapping/array are pretty closely related to each other. Is there a design pattern that achieves separating states into multiple contracts yet still allow them to interact with each other?

How about the setter functions? Is there a way to separate the setter functions out yet allow them to set their state variable?

Or are there other smart ways that I'm not aware of?


texts: which data type is use for decimal/float values

texts:
I am writing a contract in solidity which accept a float/decimal value.

Perform some division operation and the function should return decimal value.

Can anyone suggest which data type is use for decimal values?


texts: In "msg.sender.call.value(msg.value)", where is msg.value taken from?

texts:
Given the following example:

function x(address receiver) public {
    receiver.call.value(msg.value)();
}

Am I correct that receiver can be any address but msg.value cannot be controlled via argument? Will msg.value always be zero or will it be taken from msg.sender?


texts:
This is supposed to be pretty straightforward however, seems to be not.

I am trying to use --exec and --preload options with geth. --preload options seems to work sometime. But suddenly started giving problem.

*Fatal: Failed to start the JavaScript console: “customcommands.js”: open “customcommands.js”: no such file or directory.*

I tried this command..

*geth --datadir firstserver --networkid 2017 --jspath "." --preload “customcommands.js” --unlock 0 --password pwd.txt --rpcport 8545 --rpcaddr 0.0.0.0 --port 8000 --rpc --rpcapi="admin,db,eth,net,web3,personal" --maxpeers 3 --nat="any" --nodiscover --rpccorsdomain "*" console*

my directory listing says

-rw-r--r--   1 rahulgolash  staff    10 16 Nov 13:32 pwd.txt

drwxr-xr-x  11 rahulgolash  staff   374 16 Nov 14:33 ..

-rw-r--r--   1 rahulgolash  staff    52 16 Nov 19:21 account.txt

-rw-r--r--   1 rahulgolash  staff   570 16 Nov 19:33 genesis.json

-r--r--r--   1 rahulgolash  staff  8241 16 Nov 19:39 customcommands.js

drwxr-xr-x  12 rahulgolash  staff   408 16 Nov 19:40 .

drwx------   6 rahulgolash  staff   204 18 Nov 11:24 firstserver

geth --jspath "." --exec 'loadScript("customcommands.js")' never worked for me! Is this option work only with geth attach command or with geth as server node as well?

Please note that I have already gone thru
https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console


texts: Connect Metmask to ( local host ) port other than 8545

texts:
How to connect metmask to genach-GUI having port : 7545 instead of
  8545 .

Only network localhost :8545 is available on metamask

Is it done through  custom RPC network ?
If yes, then how should I proceed ?


texts: What _totalsupply number are we passing in smart contract in functions?

texts:
I created own token with 1000000(1 million) total supply, with 18 decimals. When I check _totalSupply in remix it returns 1000000000000000000000000. How is this number converted?
When we have a contract that we want to move some tokens from one account to another which number decimals do we have to use? 1000000000000000000000000 or can we simplify if I want to move 100 tokens?
In truffle I used _totalSupply call to get total supply and it gives me big number.

truffle(bracknell)> rofl._totalSupply.call()
BigNumber { s: 1, e: 24, c: [ 10000000000 ] }

Then I used following to get total supply in human friendly display:

truffle(bracknell)>
rofl._totalSupply.call().then(function(balance){console.log(web3.fromWei(balance.toNumber(),
"ether")); console.log(balance.toNumber() / Math.pow(10, 18)); })
1000000
1000000

It shows in human friendly, but which number do we use for transfer? I guess big number, in that case what is the easiest way to convert this if we pass for example 100 tokens in function to move them?


texts: Network state unknown deploying to testnet

texts:
Following this blogpost: https://medium.com/@guccimanepunk/how-to-deploy-a-truffle-contract-to-ropsten-e2fb817870c1

I created an account with geth --testnet account new

I requesed Ether into this account, but when I check

geth attach http://127.0.0.1:8545
personal.unlockAccount(eth.accounts[0])
Unlock account 0x78ca93e2a0621a1b5e198e85fd8e1d2db78d17ba
eth.getBalance(eth.accounts[0])
0

So maybe that's the problem? (The faucet worked fine for me with my Metamask address. I'm suspecting that my geth account isn't syncing)

I start testnest with this:

~/geth --testnet --fast --rpc --rpcapi eth,net,web3,personal

How do I connect to Ropsten test network and deploy my contract with truffle?

truffle migrate --network ropsten

Using network 'ropsten'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: insufficient funds for gas * price + value
    at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41484:16)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:329530:36
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176186:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:325200:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:328229:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176415:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176705:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176860:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176820:24)
    at emitNone (events.js:111:20)

truffle.js:

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      network_id: 3,
      host: "127.0.0.1",
      port: 8545,
      gas: 9900000
    }
  }
};


texts: Truffle 3.0 upgrade changes, migration and javascript errors

texts:
Hey I'm trying to upgrade to Truffle 3 and it's a complete mess. The migrations wont work as there are two errors:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Migrations error: contract binary not set. Can't deploy new instance.

Also after following the sample javascript file I get this error:

SyntaxError: Unexpected token import


texts: How to decode input data from tx using python3?

texts:
I am trying to decode input data from token sale transactions. This is one of the transactions I am trying to parse 0xf7b7196ca9eab6e4fb6e7bce81aeb25a4edf04330e57b3c15bece9d260577e2b
Which has the following input data:
0xa9059cbb00000000000000000000000067fa2c06c9c6d4332f330e14a66bdf1873ef3d2b0000000000000000000000000000000000000000000000000de0b6b3a7640000

I know that the first 4 bytes represent the function (0xa9059cbb --> transfer)

The first parameter is the _to address (0x00000000000000000000000067fa2c06c9c6d4332f330e14a66bdf1873ef3d2b)

The second is _value who's type is uint256 (0x0000000000000000000000000000000000000000000000000de0b6b3a7640000).

How do I decode _value in python to get the amount of tokens being moved? I understand that for javascript there is abi-decoder which does something similar but I would like to know how to perform this myself in python.

I have read that the value is stored as a big endian int but when I try to read it, I do not get the value listed on etherscan for the transaction (https://etherscan.io/tx/0xf7b7196ca9eab6e4fb6e7bce81aeb25a4edf04330e57b3c15bece9d260577e2b)

The information I have about the parameter coding is from here: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI


texts:
Today I bought some btc and eth on coinbase.  All I had to give for verification was my name, email, and debit card info.   I was verified and allowed to by btc and eth instanly.  My dashboard shows both btc and eth amounts I bought in my wallet.

I am a novice and just want to know if I'm good to go because it seems everyone is saying the first time shouldn't be instant and the process should take longer.

Also, why didn't I have to open an ethereum wallet to buy one like people seem to suggest?


texts:
I was wondering if there is a way for a user to pay transaction fees for another user, meaning user A sign the transaction and user B send it to the network and pays the gas fees.
I found a solution here :
https://docs.openzeppelin.com/learn/sending-gasless-Transactions
But it is very coplicated and Technical, I just need a simple way to pay fees for other user.


texts: Distribution of mined Blocks, its verification and the Longest Chain Rule

texts:
Hi all I am in need of a clear understanding of the distribution of mined blocks, the verification mechanism and the longest chain rule.

How is a freshly new mined Block being distributed to the network?
My understanding, a miner node distributes this to a fixed set of connected nodes. These nodes again distribute it to the nodes they are connected.

What happens in the case of simultaneous mined blocks are being send to the nodes for verification, if a node is in the process of verifying a new Block and another Block comes in, does the node ignore the other block?

How long does the miner node wait after it was the first to finish mining a block? When does the node knows, that its block has been verified by others and it can start mining a new block?

How often will be simultaneous finished mined blocks send to the network?

How is the longest chain be verified, will a node only verify the current block, which it has been received or does the node verifiy the new received block with its own copy of the blockchain?

How is the process of an orphanized chain, when decides a node to forget its copy of the blockchain and starts using the forked chain? Here I do not understand how a node is getting the information of another fork chain, since it always only gets 1 Block send to it and not the rest of the a possible fork chain.


texts: How does all testnets (kovan, rinkeby & ropsten) get onto the latest release of Ethereum - Homestead, Metropolis (to-be) and Serenity (to-be)?

texts:
How does testnets (kovan, rinkeby & ropsten) get onto the latest release of
Ethereum - Homestead, Metropolis (to-be) and Serenity (to-be)?

What does the process look like? In my mind, all the clients (geth, parity) in these networks will upgrade and voila! The testnets are magically upgraded.

Does it work like that?


texts: OMG Tokens locked in smart contract - onlyPayloadSize

texts:
My OMG Tokens are locked into a smart contract due to modifier - onlyPayloadSize

Line #93 - https://etherscan.io/address/0xd26114cd6EE289AccF82350c8d8487fedB8A0C07#code

I had stored dozens of ERC20 tokens on a smart contract and easily get them all back but Tx fails whenever try to get back OMG tokens so dug out their token contract and found onlyPayloadSize which is not usual in any other ERC20 token contracts.

Following is the piece of code to collect ERC20 tokens on my smart contract:

function CollectERC20(address tokenAddress) onlyAdmin public {
    token tokenFunctions = token(tokenAddress);
    uint256 tokenBal = tokenFunctions.balanceOf(address(this));
    tokenFunctions.transfer(msg.sender, tokenBal);
}


texts: How Could I pull out smart contract bytecode using web3 and contract address?


texts: Are there readable reference implementations for the cryptographic primitives used by Ethereum?

texts: For example, this Python file implements SHA3 in a compact and very readable form in Python. I wonder if we have those compact implementations for the primitives used on Ethereum, in special Keccak (not SHA3) and ECDSA (signing and recover).


texts:
Is transaction log also called trnsaction receipt?
My account address on Remix IDE is 0xCA3…a733c and wallet address is 0x147…C160C. Following is my code obtained from Solidity Tutorial

pragma solidity 0.5.4;
contract MyContractEtherEvents {
   mapping(address => uint256) public balances;
   address payable wallet;
   event Purchase(
    address indexed _buyer,
    uint256 _amount
   );

   constructor(address payable _wallet) public {
    wallet = _wallet;
   }

   function() external payable {
     buyToken();
   }

   function buyToken() public payable {
    balances[msg.sender] += 1;
    wallet.transfer(msg.value);
    emit Purchase(msg.sender, 1);
   }
 }
 I got the following Ether log:

  transaction hash
    0xa4484b15bd6e83c5377bbc4e21f69e8c208a02c3ea0187ffa77cb29c9352df6e
  from  0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c  to
    MyContractEtherEvents.balances(address)
  0x692a70D2e424a56D2C6C27aA97D1a86395877b3A  transaction cost  23832
  gas (Cost only applies when called by a contract)  execution cost
    1152 gas (Cost only applies when called by a contract)  hash
    0xa4484b15bd6e83c5377bbc4e21f69e8c208a02c3ea0187ffa77cb29c9352df6e
  input     0x27e...a733c  decoded input    {   "address ":
  "0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c" }  decoded output    {
    "0": "uint256: 4

The 'from' address is: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c (correct) but 'to' address is: 0x692a70D2e424a56D2C6C27aA97D1a86395877b3A, which is the address at which the contract is deployed. But the remix image does not show the deployed address instead it shows the address : 0x147…C160C which is the address of Wallet. Is the log information correct? I have also added the image, the image does not show the 'to' address

Some body please guide me.
Zulfi.


texts: Writing to contract struct via function parameter, memory vs storage, "memory outside of storage"

texts:
This is my first contract ever (building on an own example learning case I made up).

Given this Contract (simplified):

unit gEval = 0;

contract Group {
  struct Grp {
    string    name;
    uint      orgId;
    Contrib[] contribs;
  }

  struct Contrib {
     uint id;
     uint grpId;
     Evals[] evals;
  }

  struct Eval {
    uint id;
    address evaluator;
    uint result;

  }

  function  evalContrib(Contrib c, uint res) public {
    require(msg.sender != c.contributor);

    Eval eval = Eval(gEval++,msg.sender, res);

    c.evals.push(eval);
  }
}

I get :

  Error: Member "push" is not available in struct
  Group.Eval memory[] memory outside of storage.
      c.evals.push(eval);
      ^----------------^

This is what I understand: The Contrib c param in the evalContrib function is a memory parameter, as it is a function parameter, while I am trying to call c.evals.push(eval) which would be storage I guess.

I tried several combinations of assigning storage or memory pointer but I haven't been able to solve this.

How can I implement something like that? Can I only get a reference by Id maybe, e.g. contribs[id].evals.push(eval)?

Note: My design may be utterly inefficient for solidity (lots of structs with arrays), so I am happy for any suggestion.


texts: Event result parameters and arguments in console

texts:
I read about using events from this source http://solidity.readthedocs.io/en/latest/contracts.html#events
I used a simple multiply contract:

contract test1{
    uint a;
    event event_res(string msg,uint x);
      function test1(){
          a = 1;
      }
      function multiply (uint b){
          a = a*b;
        event_res("the value after multiplying is:",a);
      }
      function getval()  returns(uint){
          return a;
      }
}

and executed sendtransaction as:

var testing = web3.eth.contract(interface).at(address);
var event = testing.event_res(function(error, result) {
    if (!error)
        console.log(result.args);
    else
        console.log(error);
});
var result = testing.multiply.sendTransaction(5,{from : web3.eth.coinbase},function(err,result){
        if(err)
        console.log(err);
});

I got multiple parameters as output in console as following:

{ msg: 'the value after multiplying is:',
  x: { [String: '5'] s: 1, e: 0, c: [ 5 ] } }

Can anyone tell me what these parameters(s,e and c) are and what they mean?


texts: JavaScript code to deploy a contract (authentication)

texts:
When I run my contract deploy code in a browser (even if MetaMask is installed), I get this error:

authentication needed: password or unlock

The code follows:

var owner = $('#account').val();
var contract = web3.eth.contract(abi);
var contractInstance = contract.new(
    tokenName, tokenSymbol, { data: bytecode, from: owner, gas: 6721975 }
);

Please, please, explain how to do authentication for the user to be able to deploy my contract.

web3.js 0.20.6.

I connect to network with the following code:

    var provider = new Web3.providers.HttpProvider('http://localhost:8545');
    var web3 = new Web3(provider);