texts: Can't call function from contract using web3.js due to gas issue

texts:
I'm building a smart contract and dapp using ganache and web3.js.
In my smart contract I have a function (named "add_pilot") which gets 4 parameters and add them to a mapping. It looks like this:

pragma solidity ^0.4.0;
contract Transaction {

    uint num = 0;
    bytes32 [] storedKeys;
    uint [] x;

    struct Pilot {
        string details;
        uint expected_time;
        address creator; //loc 0 is original creator
        uint amount;
        address [] listenrs;
        address [] reporters;
    }

    mapping (bytes32 => Pilot) _accounts;

    function  get_details_by_name(string key) public returns(string){
        return _accounts[stringToBytes32(key)].details;
    }

    function  get_pilots_names() public constant returns(bytes32 []){
        return storedKeys;
    }

    function stringToBytes32(string memory source) private returns (bytes32 result) {
        bytes memory tempEmptyStringTest = bytes(source);
        if (tempEmptyStringTest.length == 0) {
            return 0x0;
        }

        assembly {
            result := mload(add(source, 32))
        }
    }
    function  get1() public constant returns(uint){
        return num;
    }

    //new pilot as listner
    function add_pilot(string s1, string det, uint hours_till_exp, uint am) public  {
        bytes32 s = stringToBytes32(s1);
        _accounts[s].creator = msg.sender;
        _accounts[s].amount = am;
        _accounts[s].details = det;
        _accounts[s].expected_time  = now + (hours_till_exp * 3600);
        _accounts[s].listenrs.push(msg.sender);
        num+=1;
        storedKeys.push(s);
    }
}

When calling "add_pilot" from web3.js I'm getting the following error:

> Uncaught Error: Exceeds block gas limit
    at Object.InvalidResponse (web3.min.js:1)
    at n.send (web3.min.js:1)
    at l.t [as sendTransaction] (web3.min.js:1)
    at u.sendTransaction (web3.min.js:1)
    at u.execute (web3.min.js:1)
    at HTMLButtonElement.<anonymous> (index.html:151)
    at HTMLButtonElement.dispatch (jquery-3.2.1.slim.min.js:3)
    at HTMLButtonElement.q.handle (jquery-3.2.1.slim.min.js:3)
InvalidResponse @ web3.min.js:1
n.send @ web3.min.js:1
t @ web3.min.js:1
u.sendTransaction @ web3.min.js:1
u.execute @ web3.min.js:1
(anonymous) @ index.html:151
dispatch @ jquery-3.2.1.slim.min.js:3
q.handle @ jquery-3.2.1.slim.min.js:3

When I tried to increase the gas limit in the ganache, it still failed and I got this error:

> web3.min.js:1 Uncaught Error: sender doesn't have enough funds to send tx. The upfront cost is: 4000000000000000000000 and the
sender's account only has: 99989875220000000000
    at Object.InvalidResponse (web3.min.js:1)
    at n.send (web3.min.js:1)
    at l.t [as sendTransaction] (web3.min.js:1)
    at u.sendTransaction (web3.min.js:1)
    at u.execute (web3.min.js:1)
    at HTMLButtonElement.<anonymous> (index.html:151)
    at HTMLButtonElement.dispatch (jquery-3.2.1.slim.min.js:3)
    at HTMLButtonElement.q.handle (jquery-3.2.1.slim.min.js:3)

This is how I'm calling the function from web3.js:

var Coursetro = CoursetroContract.at('...');
Coursetro.add_pilot(($("#pilot_id").val()), $("#pilot_descp").val(), $("#hours_till").val(), $("#amount").val());

Another thing I haven't mentioned is that from remix it's executing the function properly. This problem appears only from the web3.js (the UI).

What am I doing wrong?


texts: 12.5 Mh/s on Gigabyte HD 7950, is that normal? Shouldn't it be higher?

texts:
As the title says.
Windows 7 64bit. Gigabyte HD 7950.
I tried qtminer, ethminer and Claymore
I also tried downgrading from 16 to catalyst 15.12 as recommended.
However I can never get more than 12.5 Mh/s
I actually bought this card because I saw everyone hashing with it at 20+ Mh/s.
What could be my problem? Or is this actually normal?


texts: Is it possible to check string variable's length inside the contract?

texts:
I want to sent a string as an argument to a function. But some user may enter maybe 100 size string or even larger.

[Q] Inside the function is it possible to check the size of the string and return false if it exceeds the length limit that I have specified.

For example, a user is only allowed to send string which has length of 64 characters, and the contract's function returns throw if the string exceeds the limit of 64 character.

Test.transaction().setVariable("very_large_size_string_entered_65_chars");

For example:

Contract Test{
   String data;
   function setVariable(string str) {
       //check somehow does the string exceeds the character limit.
       data = str;
   }
}

Thank you for your valuable time and help.


texts: How do I ensure that `1 << n` is executed as a 256-bit operation?

texts:
In other words, how do I ensure that 1 << n does not overflow for n < 256?

At present, I am using uint256(1) << n.

Is there a better way, or is it guaranteed that the expression uint256(1) is replaced with a constant value during compilation (and not computed during runtime)?

Thank you.


texts: uint doesn't return big number object if function is not constant?

texts:
So, I have a contract deployed which has a simple function which returns a uint.

If I make the function constant it returns the correct value set as a BigNumber object, but if I remove the constant keyword then it doesn't return a BigNumber object.

Can anyone throw some light as to why this happens? As far as I know, the constant keyword is used so that you don't have to pay gas for retrieving the value.

My contract function code :

function getMyNymber() returns (uint256) {
    return myNumber;
}

The above method doesn't return a Big Number object.

function getMyNymber() constant returns (uint256) {
    return myNumber;
}

This returns a Big Number object, the only difference being the constant keyword.


texts: How to connect local private geth nodes to the web page without using metamask or mist?

texts:
I'm developing a web wallet similar to meta mask that can make transactions or can create accounts from UI. Frontend is developed using React. Blockchain is implemented in geth.I'm using truffle react box.
        // Use Mist/MetaMask's provider.
        const web3 = window.web3;
        console.log("Injected web3 detected.");
        resolve(web3);
      }
      // Fallback to localhost; use dev console port by default...
      else {
        const provider = new Web3.providers.HttpProvider(
          "http://127.0.0.1:8545"
        );
        const web3 = new Web3(provider);
        console.log("No web3 instance injected, using Local web3.");
        resolve(web3);
      }
    });

according to this code, my local provider should work when there is no metamask extension. But, my codes work only when I installed meta mask extension. Are there any way to get connection to my blockchain and can control from web page?


texts:
can we directly add the token logo to the token smart-contract so that we can visualize it in Wallets and Exchanges and so that we don’t have to register it in another way
Please help
erc20 token standard


texts: Call `getPastEvents` with Drizzle raise error: "getPastEvents is not a function"

texts:
Calling getPastEvents with Drizzle will cause the exception:

  TypeError: this.drizzle.contracts.Contract.getPastEvents is not a function

How to get all the past events in an array (in-one-shot) when working with Drizzle?


texts: How to make token for exchange such as bittrex? I'm interested only in technical side of this question

texts:
Should I set a starting price for the token?
Is there a source code for the token for trading on the exchange?


texts: Reclaim Ether from Fail / Cancelled transaction

texts:
I tried to transfer Ether from my Coinbase account to somebody but the recipient declined it for a technical issue. Therefore, the status of the transaction is now cancelled with TxReceipt Status as “Fail” from Etherscan page.

However, the coin is NOT restored to my Coinbase account yet, and Coinbase support says that it is lost for good and there's no way that I can reclaim it.

Is this really true? Or can anyone tell me how can I reclaim this to my account?


texts: compiling solidity code using solc@0.4.10 on node.js

texts:
Trying to compile solidity smart contract on windows using solc@0.4.10.
But the code breaks with the below error, and this happens only for the contracts in which import statements are there, other contracts load fine.

My import statement:

import "second.sol";

And the error in the console is:

soljson.js:1(function (exports, require, module, __filename, __dirname)
{ var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||
{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key))
{moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";
var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";
var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof
require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;
var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;
if(ENVIRONMENT_IS_NODE){if(!Module["print"])
Module["print"]=functionprint(x){process["stdout"].write(x+"\n")};
if(!Module["printErr"])Module["printErr"]=function printErr(x)
{process["stderr"].write(x+"\n")};var nodeFS=require("fs");
var nodePath=require("path");Module["read"]=function read
(filename,binary){filename=nodePath["normaliz

Any suggestions on how import statement is to be written. I have tried with absolute path and by putting ./ as well, it just does not work.


texts: TheDAO hack FAQ: How did the attack happen on 17 June 2016?

texts:
Can anyone explain that how the DAO attack happened? Vitalik Buterin explained here that it was performed by splitting a DAO from the main DAO but calling the split function recursively.

We know that recursive function is a kind of function that makes a call to itself but I am not sure that it is the same case as happened in DAO attack.

Can anyone explain what does it mean calling a function recursively and how exactly it happened in the recent attack to the DAO?


texts: How dependent is the ethereum client on the router and DNS being trusted?

texts:
Another way to put it: what is the root of trust for a full client on a network that has a potentially untrusted (or "owned") router+DNS?

As I was going through the ethereum wiki semi-randomly, I came across this, it says:

  "[...] it allows a node given only the last block, together with some assurance that the last block actually is the most recent block, to [...]".

Similarly, this says:

  "[...] if a node receives a state root from a trusted source [...]".

I am trying to understand where that assurance comes from or why I should trust that source.  I'm trying to figure out how much a knowedgeable attacker can do to me if he "owns" the DNS and/or router I am using.

The traditional protection against this is PKI.  Yes, PKI is imperfect, there are too many CAs in the browser, lack of trust agility (I've read/watched many of Moxie Marlinspike's posts/talks), and several other issues, but for what it is worth, it is there, and under specific conditions, with the proper TLC, can do the job.

I just don't know what's the equivalent here, or even if there is one at all.

Edited to add:

I don't have enough rep to comment, but to Ethan: authenticated encryption prevents MITM only if you already know whom you are talking to; in this case we don't know that for sure.  (Which is why I mentioned PKI as the thing to compare against, despite its flaws).

To A. Frederick Dudley: thank you!  "confirm the state root out of band" is what I was thinking; appreciate the confirmation.


texts: How long you can consider a pending transaction as invalid?

texts:
I saw here that the time that a transaction can be at pending status changed, but didn't say how much

  Due to overwhelming amounts of pending transactions during ICOs, many public nodes (etherscan, MEW, infura) adjusted their settings in order to keep more transactions in a pending state for a longer period of time.

Currently I'm studying relations in pending transactions over Ethereum blockchain, so I'd like to know how much time I can stop searching for a pending transaction, as it may cause ripple in my database, since new transactions with same data can happen.


texts: Trying to send ERC20 token with Javascript button without success

texts:
I am trying to send an ERC20 token with the following code via web3.js. It was working until a week ago and then it stopped. Am I doing something wrong? Upon clicking it no longer interacts with Metamask. Thanks in advance for the help. Moses.

<script>
    window.addEventListener('load', function() {
    // Check if Web3 has been injected by the browser:
    if (typeof web3 !== 'undefined') {
        // You have a web3 browser! Continue below!
        startApp(web3);
        //alert("Web3");
    } else {
        //alert("No hay web3");
    }
})
const abi = [{
    "constant": false,
    "inputs": [
        {
            "name": "_to",
            "type": "address"
        },
        {
            "name": "_value",
            "type": "uint256"
        }
    ],
    "name": "transfer",
    "outputs": [
        {
            "name": "success",
            "type": "bool"
        }
    ],
    "payable": false,
    "type": "function"
}]
const contract_address = '0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359'
const etherValue = web3.toWei(10, 'ether');
var addr = '0xd7B9A9b2F665849C4071Ad5af77d8c76aa30fb32'
var amount = '200'
function startApp(web3) {
    //alert("entro");
    const eth = new Eth(web3.currentProvider)
    const token = eth.contract(abi).at(contract_address);
    listenForClicks(token,web3)
}
function listenForClicks (miniToken, web3) {
    var button = document.querySelector('button.transfer')
    web3.eth.getAccounts(function(err, accounts) { console.log(accounts); address = accounts.toString(); })
    button.addEventListener('click', function() {
        miniToken.transfer(addr, amount, { from: address })
            .then(function (txHash) {
            console.log('Transaction sent')
            console.dir(txHash)
            waitForTxToBeMined(txHash)
        })
            .catch(console.error)
    })
}
async function waitForTxToBeMined (txHash) {
    let txReceipt
    while (!txReceipt) {
        try {
            txReceipt = await eth.getTransactionReceipt(txHash)
        } catch (err) {
            return indicateFailure(err)
        }
    }
    indicateSuccess()
}
</script>
<br>
<button class="transfer">Send 200 tokens!</button>
</center>

edited: Edited to fix typo


texts: How to find the contract wallet JSON and ABI

texts:
I'm trying to find the JSON and ABI for one of my contract wallets here:

  0x1Fa0926C69eEe89d212F0848803e4Ee2E548fE4D

The reason is that there is some ETC locked up in it that I'm trying to dump, via myetherwallet now that they have the functionality to interact with contracts on the ETC chain...but in order to do that I need the ABI/JSON. Where do I find that? The wallet contract is a multi-sig contract with 2 owners.

Thanks!


texts: Transfer token to wrong adress that have been created by the transaction

texts:
I have used etherdelta to transfer tokens instead of the withdraw option and they transfer tokens from my personal wallet to a new one that doesn't exist .The destination adress (automatically fill on etherdelta) looks like mine but only one character is different from my personal wallet . I didn't pay enough attention and the tokens ended up on a new wallet that have been created by the transaction :

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

Do you know if the private key have been generated during the transaction and if it s stored somewhere ?Is there any solution or the tokens are locked up for ever?


texts: calculate average network hashrate and block time in geth

texts: If you visit ethstats you see two cards named AVG NETWORK HASHRATE and AVG BLOCK TIME, How can i get them in geth?


texts: Interacting with an ethereum smart contract via Java

texts:
I am interested in interacting with a smart contract via a Java application. I found that there is a library called web3j (https://docs.web3j.io/) for which this should be possible, however there is not much documentation on how to install it. I expect that I should import Web3j with "import Web3j", but first I would have to install the package from the downloaded Git repository. In the documentation it just says "Add the latest web3j version to your project build configuration.", and then mentions "Maven" and "Gradle", but I have never heard about these before. Can't I just link the files to my project in eclipse without using some third party programs? So, to summarize, my question is:

How do I easiest link Web3j so I can import it into a java project in eclipse?


texts: Getting error on sending ether/wei in payable function

texts:
error:
transact to CampaignFactory.createCampaign errored: VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. Debug the transaction to get more information.

code:

 function createCampaign(uint deposit, address ll) public payable{
   // dpst = deposit;
    require(msg.value > (40*deposit)/100 wei);
    address newCampaign = address((new Campaign).value(msg.value)(deposit, ll, token_address, 1));
    token_instance.setAllowance(deposit, token_holder, newCampaign);

    deployedCampaigns.push(newCampaign);

}

Campaign constructor declaration:

    constructor (uint depositInWei, address ll, address addressOfTokenUsed, uint weiCostOfEachToken) public payable{


texts: What is the address and balance of The DAO's extraBalance account

texts:
From The DAO - Creation:

In the first 14 days, The DAO tokens are created at a rate of 1 ether = 100 tokens
In the subsequent days before the end of the creation period, the number of ethers for each 100 tokens created increases until the final rate of creation is 1.5 ethers = 100 tokens.
The excess ethers over the 1 ether = 100 tokens is transferred to an extraBalance account.

What is the address and the balance of this account?


texts: How to concatenate two bytes16 to bytes32

texts:
I'am trying to concatenate tow bytes16 to form a bytes32

    func concat(bytes16 t1, bytes16 t2) public returns (bytes32)

I'am not finding anything in solidity documentation!
Is anyone have an idea about this?


texts: Who is msg.sender in a nested call chain?

texts: I read about who is msg.sender when calling a contract from a contract, but who is msg.sender when calling a contract from a contract that calls another contract and so on and so forth?


texts:
I am trying to fully grasp the concepts of the ethereum network. Therefore I want to setup a simple website which can manage ethereum wallets. I'm using the geth client with the following configuration:

geth --light --rpc --rpcapi personal,web3,net,eth --rpccorsdomain "*"

I've read a lot of documentation, but still not all the concepts are clear to me.

Do I need to have a node to create a wallet for a user and manage the private keys?
How does the geth --light mode work? When I create a new account, how can I know the account is created on the global ethereum network? etherscan.io shows an amount of 0, but that might be the default behaviour of a non-existing address number?
Also for existing addresses, when using the eth_gethBalance rpc method, it always returns 0, while etherscan.io shows another amount.
What is the difference with a local account and a public address?
What does 'unlocking' an account actually do? Can I send transactions to a non-unlocked account?


texts:
Consider the following Truffle Unit Test written in JavaScript:

const Lease = artifacts.require("./Lease.sol");
contract("Lease", async (accounts) => {
    it("Rinkeby delay problem", async () => {
    let instance = await Lease.deployed();

    // let's check the initial state
    let state0 = await instance.tenantState();
    console.log("initial state: " + state0);

    // let's change the state
    let tx = {from:accounts[2], to:instance.address, value:2000};
    web3.eth.sendTransaction(tx);
    await instance.updateTenantState();

    // let's check if the state changed
    let state1 = await instance.tenantState();
    console.log("resulting state: " + state1);

    // let's wait for one second and check the state again
    setTimeout(async () => {
        await instance.updateTenantState();
        let state2 = await instance.tenantState();
        console.log("resulting state after 1 second: " + state2);
    }, 1000);

    });
});

When I run this test on my GanacheUI instance with zero block delays, I get the following results:

$ truffle test test/delay.test.js --network dev
Using network 'dev'.

Compiling ./contracts/Lease.sol...
Compiling ./contracts/LeaseMock.sol...
Compiling ./contracts/Logic.sol...

  Contract: Lease
initial state: 1
resulting state: 0
    ✓ Delay problem (196ms)

  1 passing (226ms)

resulting state after 1 second: 0

However, when I add a 15 second block delay in GanacheUI (which is about the same block delay as the mainnet), I get this:

$ truffle test test/delay.test.js --network dev
Using network 'dev'.

Compiling ./contracts/Lease.sol...
Compiling ./contracts/LeaseMock.sol...
Compiling ./contracts/Logic.sol...

  Contract: Lease
initial state: 1
resulting state: 1
    ✓ Delay problem (30212ms)

  1 passing (30s)

resulting state after 1 second: 0

This has disastrous effects on my unit tests: around 70% of them fail with very diverse errors.

I got similar results with AragonOS's repository using GanacheUI: without block delays all test pass, but with a 15 second block delay many fail. (They have an option to test on Ropsten, Kovan and Rinkeby using Infura, but I didn't try that).

So what are the best practices? Should I ignore block delays altogether? In that case, how am I supposed to test my contracts on the testnets? Or should I design my tests so that they handle block delays properly? If so, how? And finally: are there security implications of ignoring block delays in unit tests?


texts: Truffle migrate:The method eth_accounts does not exist/is not available

texts:
I have both my local geth node and geth console running in the background.

geth console command :

geth --rinkeby --rpc --rpcapi = "personal,eth,network,web3,net" --ipcpath "~/Library/Ethereum/geth.ipc"

local geth node command :

geth attach ipc:\\.\pipe\geth.ipc

which allows me to connect to the geth console

Welcome to the Geth JavaScript console!

instance: Geth/v1.8.3-stable-329ac18e/windows-amd64/go1.10
coinbase: 0xc496398f167316e763523503b9d7cedd7f47d0a4
at block: 0 (Wed, 12 Apr 2017 22:59:06 +08)
 datadir: C:\Users\Syed\AppData\Roaming\Ethereum\rinkeby
 modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

However, when I run truffle migrate --reset --compile-all --network rinkeby

I get this error saying that :

Error: The method eth_accounts does not exist/is not available
    at Object.InvalidResponse (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\errors.js:38:1)
    at C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\requestmanager.js:86:1
    at C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\truffle-provider\wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\web3\lib\web3\httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:509:1)
    at IncomingMessage.<anonymous> (C:\Users\Syed\AppData\Roaming\npm\node_modules\truffle\build\webpack:\~\xhr2\lib\xhr2.js:469:1)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

truffle-config.js

require('babel-register')

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    rinkeby: {
      host: "localhost", // Connect to geth on the specified
      port: 8545,
      network_id: "4",
      gas: 4612388 // Gas limit used for deploys
    }
  }
};

I'm following the steps in this video : https://www.youtube.com/watch?v=_rumMSlrmiI&t=892s
My suspect is something to do with webpack or truffle. But i have added both packages.


texts: How is the storage trie of a user account which does not belong to any contract?

texts: We know that storage trie (stored in the leaf node of state trie) is storing the contract's data related to an account. Then, what will be stored in the storage trie of a user account which does not belong to any contract? Is it empty in this case?


texts: duplicate function name with different signatures

texts:
I have a contract that handles insurances and I would like to be able to get a single instance either by index or by address. To this end I wrote two functions:

function getInsurance(uint index) constant returns (string, InsuranceStatus) {
    Insurance insurance = insurances[insuranceList[index]];
    return (insurance.name, insurance.status);
}

function getInsurance(address insuranceAddress) constant returns (string, InsuranceStatus) {
    Insurance insurance = insurances[insuranceAddress];
    return (insurance.name, insurance.status);
}

when I test this, the second function (the one with the address parameter) does not return any data.

The compiler does not complain but I'm wondering if this is this supposed to work.


texts:
I have a geth node up and running but I want to be able to connect to it via https.  For example https://eth-node-domain.com:8545 or https://121.213.231.24:8545  How can I go about doing this?  I have been google searching for the past week but cant seem to find anything about this.

I am running Ubuntu on digital ocean

I have tried to install lets encrypt cert but that did not work.

sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot
sudo certbot certonly --standalone -d mynodesite.com


texts: Correct Open Zeppelin contract for external agent contract that handles sales logic on behalf of an ERC721 contract?

texts:
I just finished this article on the Open Zeppelin ERC721 token implementation:

https://medium.com/blockchannel/walking-through-the-erc721-full-implementation-72ad72735f3c

I about to start implementing.  The article states that the ERC721 token works with external contracts that handle the spend logic and the address for that "agent" contract ends up in the main contract's "allowed" map.  If I understand things correctly, the ERC721 token acts as the managing entity for token ownership record-keeping and facilitating the integrity of token transfer and allowances.

So, should I assume that logic for whether or not a token is transferred (e.g. - a sale, or escrow release, etc.) should reside in an external contract instead of deriving a new contract from one of the ERC721 contracts and putting that logic in the body of the derived contract?  If so, is there an Open Zeppelin contract that I should look at and use either as a template for my external "agent" contract that I should derive that contract from?

My situation, at least for now, is very simple where the price for a token is fixed and once the buyer pays for it, the token should be transferred from the current owner (the seller) to the buyer.  The one major nuance I will need to handle is whether or not the buyer wants to put the token up for sale.  If not, it should not be sellable to anyone until the current owner decides to put it up for sale.


texts: Are the terms consensus mechanism and consensus algorithm the same?

texts: I have seen that the terms consensus mechanism and consensus algorithm are used interchangeably sometimes. Are they really the same or there is a subtlety to it?


texts:
If I want to airdrop the token to 10,000 addresses can we do it all under 1 transaction rather than 10,000 separate transactions all incurring separate fees.

Thanks
Amit M


texts:
Ethereum uses Accounts instead of UTXO (Bitcoin). I would like to know how does the ledger keep the account state (technical details if possible)?

Does it modify the ledger (accounts) by incrementing or decrementing the balances?
Or does it use the cumulative (sum) of received amounts and send to verify users have a proper balance?
Where does the Patricia-Tree used stand in all of this?


texts: Compilation Error: Error: Expected identifier but got '(' msg.sender.transfer(uint(amount));

texts:
I am compiling the following code on solc & remix ide:

pragma solidity ^0.5.1;
    contract Signed1 {
        uint val= 0;
        function withdrawOnce(int amount) public returns (uint){
           revert();
        }
        msg.sender.transfer(uint(amount));
        transferred[msg.sender] = true;

    }

I got the following error:

  D:\SolidityContractsSelf\Remix\From Remix Site\Integer Bugs>solc
  sign1.sol sign1.sol:7:24: Error: Expected identifier but got '('
      msg.sender.transfer(uint(amount));

Can some body please guide me how to get rid of this error? Is revert() still used?

Zulfi.


texts: How to successfully connect to a localhost blockchain node?

texts:
I have a localhost blockchain node successfully working and my contract deploys OK using truffle. Geth works too. But when I try and access the node via React and the Chrome console when running React I am not getting anything meaningful. Even web3.eth.coinbase does not work.

Example code -

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

var x = web3.eth.coinbase;

And x is undefined.

Here is the connection string -

  geth --datadir ~/blockchain/mybc1 --rpc --rpcaddr "localhost" --port
  8545 --rpcport 8545 --networkid 1234 console 2> consolemybc1.log

Has anyone any ideas about this?


texts: Is it common practice to have multiple wallets?

texts:
Is it common practice to store your Ether in multiple wallets?  For example, generating 10 wallets on myetherwallet.com and distributing your Ether among them?

What are the practical reasons for doing so?


texts: What is the exact meaning of a transaction's new receipt 'status' field?

texts:
In this answer (https://ethereum.stackexchange.com/a/6010/1529) it seems to say that the status field will always be '1' unless the transaction failed, in which case it will be '0'.

In the summary section of this answer (https://ethereum.stackexchange.com/a/28078/1529), it seems to imply that the status field is only set to zero when 'revert' was called.

What is the exact meaning of the status field?

Does receipt.status of '0' indicate errors of all kinds or only reverts?

Does receipt.status of '1' always indicate a successful transaction?

Here's an example of a transaction with a 'Fail' status (i.e. '0') and an 'out of gas' reported error: https://etherscan.io/tx/0xeec4ccd13fe05907f9d732a8ad245bcb7f918217157b89baaa23895c12eb329a. What happened here?

Related question: Does the new receipt status field report all errors all the way down the call chain?


texts: Should I use Node.js server along with ethereum smart contracts to make Dapps?

texts: I want to make a Dapp using ethereum. So, should I use a Node.js server and a database to store some user's data and store rest of the data on the smart contract that needs to be decentralized or should I keep all the data on the smart contract?


texts:
So I've updated my framework and with it the web3,js lib. When I run the console and attempt to get an account from my test network by web3.eth.accounts, it won't display a list of the accounts like before and instead shows the interface to some methods and objects, and none of them seem to be what I'm looking for. Also web3.eth.coinbase returns me undefined.

Yes, the provider is set correctly (I can even interact with my deployed contracts) and it has those generated accounts. So what might be wrong?

Web3.js 1.0.0-beta.37

Ganache CLI v6.1.8 (ganache-core: 2.2.1)

Truffle v5.0.1 (core: 5.0.1)

Solidity v0.5.0 (solc-js)

Node v8.15.0


texts: Remix compiler is not loading and gives "Compiler not yet loaded." message when attempting to force

texts:
This issue is occurring on both chrome and firefox. I have not changed anything from a week ago when it worked fine. The remix compiler works on Edge browser but not the other 2.

If anyone has any reason for this or fix, that would be greatly appreciated. Thank you.


texts: Is this function transfering from contract address or from msg.sender?

texts:
The basic idea is to have list of say 10 pre-approved addresses that can call this, but I'm trying to figure out if the balance will be deducted from their balances or from the contract? 10x!

function transfer(address _to, uint256 _value) public onlyapprovedaddr returns (bool)
{
    return super.transfer(_to, _value);

}


texts: How can I measure the gas used in a block of code?

texts:
This answer explains well how to measure the gas used in a block of code.

I had actually been using this method before I found that answer:

pragma solidity 0.4.26;

import './IERC20Token.sol';

contract Tester {
    uint256 public gasUsed;

    function transfer(IERC20Token _token, address _to, uint256 _value) public {
        uint256 bgn = gasleft();
        require(_token.transfer(_to, _value));
        uint256 end = gasleft();
        gasUsed = bgn - end;
    }
}

Then, simply from a Truffle 4.1.16 test:

const token = await ERC20Token.new('name', 'symbol', 18, SUPPLY);
const tester = await Tester.new();
await token.transfer(tester.address, AMOUNT);
await tester.transfer(token.address, accounts[0], AMOUNT);
const gasUsed = await tester.gasUsed();
console.log(gasUsed.toFixed());

However, it seems that it doesn't take into account gas-refund for changing storage variables from nonzero to zero.

Reading a little bit about this refund, I believe that it is sent back to the sender (msg.sender) or even all the way back to the original sender (tx.origin).

So I'm looking for a more accurate method.

I don't mind if the solution involves the off-chain, for example (using web3.js):

const balanceBefore = await web3.eth.getBalance(myAccount);
const response = await myContract.methods.myFunc().send({from: myAccount, gasPrice: myGasPrice});
const balanceAfter = await web3.eth.getBalance(myAccount);
const gasUsed = response.receipt.gasUsed;
// now do something with balanceBefore, balanceAfter, myGasPrice and gasUsed

But the result should reflect only the gas-cost of the actual block of code in the contract.

For example, it should avoid taking the cost of the transaction itself into account.

Does anybody have a leading clue on this?

Thank you!


texts:
I want to access a single value of a mapped struct from another contract. For now, I know how to return all values of the struct by using the following code:

function getUnitById(uint256 _id) public view returns (uint256 id, string name, uint256 attack, uint256 defense, uint256 heal, uint256[] questsCompleted) {
    return unitsContract.tokenToUnit(_id);
}

but what do I have to do to access only one single value?

return unitsContract.tokenToUnit(_id).questsCompleted;

would make sense in my opinion but that does not work at all.

Did anyone get a working solution?


texts:
I would like to create a generic ERC-20 token with identification. The token would only be transferred to previously identified addresses. The way identification is implemented should be as decoupled as possible from the token itself.
We also want to reuse this token in different scenarios (with different business rules). Is there any standard or reference to this goal?


texts: How I compile dapp in browser just like I used to compile my Visual Studio code using xampp in my browser?

texts:
Whenever I create/ edit some project on my Visual studio code, I put it  inside htdocs of xampp folder. Then I start Xampp control panel and give it some localhost port number so that I would compile that code using localhost:xxx url on my browser.
I was wondering, what is the equivalent process after I create some dapps using heroku, IPFS (heroku, IPFS is not my part of question here). What I mean is how I see it in browser its end result.
Sorry for being a noob as decentralized apps concept is relatively new.
I will be happy to share additional details that is needed to make this question complete.


texts:
So my Mix-ide install seems irrevocably crashed and given that there's no other IDE with integrated UI, I'm forced to face the inevitable learning of authoring HTML UI without much of a web dev background. Though there's plenty of material out there about backend DAPP development, I find almost nil regarding front end DAPP UI development.  I'd like to start learning how to integrate with Mist.  But that aside....

I have the web3.js package in Node and I have web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); in my UI html.

Q.  For the purposes of a local test chain, where am I suppose to store this page and what serves it to what URL?


texts:
STATICCALL provides protection against reentrancy attacks.

How can I use this functionality from within Solidity?


texts: Error! Unable to locate Contract Code at 0x6... Is this a valid Contract Address?

texts:
I have the problem now that etherscam does not let me verify my contract and I get the following errors, I have left a GitHub link with my codes to see who could really help me, thank you very much!
Now I have the following the following problem when I try to verify the contract:

Error! Unable to generate Contract ByteCode and ABI (Compiler
Exception)
Compiler Warning (s):
myc: 1: 1: ParserError: Expected pragma, import directive or contract
/ interface / library definition. 0x60806040523480156200001157600080f
... 92209400902b5e2bb346ea9977ab3d70029 ^
------------------------------------------------- ------------------------ ^ Compiler Version: v0.4.26 + commit.4563c3fc Optimization Enabled: False Runs: 200 ByteCode (what we are looking
for):

Here I leave the links of the Bytecode and ABI code that I am using in etherscam:
ByteCode: https://github.com/wannaditoken/Wannadi-Contract/blob/Contract-code/bytecode
ABI: https://github.com/wannaditoken/Wannadi-Contract/tree/Abi-code


texts: tx.origin to block contracts from call my game

texts: Its possible to use tx.origin instead of msg.sender to block the contracts from playing and revert the calls?


texts: Extend old contract or deploy new after fixing, recommendation?

texts:
Unfortunately, we used different transfer function name in our smart contract which causes issues for us to list it on some exchange, transfer function name should be transfer but we used transferTokens which is not erc20 now :(
I want to ask, to use transfer function so should we extend the old contract somehow or should we deploy new contract on ethereum? Which approach is better? If we need to extend then how can we do it and what are the major issues of contract extend?

Thank you.


texts: Gas requirement of function "testCompile.showString() high: infinite"

texts:
I have written simple function in remix.

pragma solidity ^0.5.0;

    contract testCompile{
        string myString = "Hello World";

        function showString() public view returns (string memory){
            return myString;
        }
    }

but it shows warning about infinite gas price. How can i resolve this case!


texts: How to decode a transaction to verify its signature in Javascript?

texts:
I noticed that it's possible to sign a transaction with a wrong private key. I took the following example found at https://github.com/ethereumjs/ethereumjs-tx

const EthereumTx = require('ethereumjs-tx').Transaction
const privateKey = Buffer.from(
  'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109',
  'hex',
)

const txParams = {
  nonce: '0x00',
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: '0x0000000000000000000000000000000000000000',
  value: '0x00',
  data: '0x7f7465737432000000000000000000000000000000000000000000000000000000600057',
}

// The second parameter is not necessary if these values are used
const tx = new EthereumTx(txParams, { chain: 'mainnet', hardfork: 'petersburg' })
tx.sign(privateKey)
const serializedTx = tx.serialize()

This code does sign the transaction, but how do I verify that the transaction has been correctly signed?

How to use or decode serializedTx and verify that the signature is correct?


texts: DeclarationError: Identifier not found or not unique and Undeclared identifier

texts:
I am trying to create a crowdsale contract using zeppelin. But i am facing following errors.

CrowdSale.sol:6:46: DeclarationError: Identifier not found or not unique.
contract EdCoinCrowdSale is CappedCrowdSale, RefundableCrowdSale {
                                             ^-----------------^
CrowdSale.sol:24:51: DeclarationError: Undeclared identifier.
    function setCrowdsaleStage(uint value) public onlyOwner {
                                                  ^-------^

I have imported contract using import.

import "node_modules/zeppelin-solidity/contracts/crowdsale/distribution/RefundableCrowdSale.sol";

I have looked at other solutions but i am still facing above mentioned errors.


texts: How to find the contract wallet JSON and ABI thanks

texts:
I'm trying to find the JSON and ABI for one of my contract wallets with multi key here:

73fd0499558056bede6b5f7b31ca59936deda1d4 -

d38b4e14167a75adb77d19acd5ebdf59473ffb4c -

3da3e8c60a70aa94ce9b50f4288f05e078948ea7

and or
a80c0ec73d34421c4b901f496a81c651c29c3050

The reason is that there is some ETC locked up in it that I'm trying to dump, via myetherwallet now that they have the functionality to interact with contracts on the ETC chain...but in order to do that I need the ABI/JSON. Where do I find that? The wallet contract is a multi-sig contract with 2 owners.

Thanks!


texts: How much data can I store in a smart contract, what is the cost and how it is implemented?

texts:
If I suppose I use a smart contract as a database, how much data can I store?
speaking only of strings and integers, save them in contract data structures does it cost in addition to the gas used for the variable store?

The contract size must be a maximum of 24576 bytes, as also written in the  yellow paper, but that refers to the weight of the contract code; the memory is represented as an array of 2 ^ 256 32 bytes slots, but can I really use all this memory?

If I have a contract with data structures that contain thousands of elements, when I update a variable and then change the status of the contract, how is the updating of this contract implemented on all nodes?

Making calls on a contract with lots of data saved in it has a higher cost?

Sorry for the many questions, I know that this type of operations are expensive, but I would like to understand how the smart contract memory is managed.

Thanks!


texts:
Tried making three separate transactions from two separate wallets (Coinme and Coinbase) each in relatively small amounts (less than $50) to fund my Ethereum Wallet 8.0 for Mac. None have appeared after approximately 15 hours.

Earlier, in test mode on another machine (Ethereum Wallet 8.0) was able to mine 3000 ETH, but the funds disappeared when I quit and restarted the app. Since then, attempts to mine in test mode have not been successful.

Both wallets use Geth node.

Double-checked all addresses each time before sending.

Would anyone recommend to switching to Ethereum Wallet 9.0? Or am I better off just using the CLI tools?


texts: Is there a way to capture the require / revert failure reason?

texts:
In my contract, I have a bunch of checking at the start of a public function. It looks something like this:

require ( prx < 1e18, "Value prx too high")
require ( prx != 0, "Value prx cannot be zero")
if (!validAmt(amt)) { revert("Value amt invalid"); }

Obviously I would like the user to see the failure and the reason text, is this possible in web3.js, or perhaps web3.py?

I know I can capture events, but I don't want to log events on these kind of failures.


texts: Using web3.js to do base58 (ipfs) encoding and decoding?

texts:
Is it possible to use the web3.js libary to do base58 encoding and decoding?

It seems that web3.js includes the bignumber library, but I'm unsure as to whether this can handle the base58 encoding used, for example, by ipfs.

I'm hoping for a function that looks a bit like this (which fails):
E.g. (based on this)

web3.utils.toBN('QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU', 58) //web3 v1.x

or

web3.toBigNumber("QmXGTaGWTT1uUtfSb2sBAvArMEVLK4rQEcQg5bv7wwdzwU",58) //web3 v0.x

which returns a bignumber integer from the base58 number.
Is it possible to do base58 encoding and decoding using the web3.js library?


texts: does geth have timeout options for json and websocket servers?

texts:
Does anyone know a way to set a timeout value for hung websocket connections? sometimes i will get a hung connection that never closes and i have no way to kill it. i dont see any timeout values in geth config files. i could put a load balancer in front of geth but thats kind of a pita.
thanks!


texts:
New to Smart Contract development and am wondering if there is anyway to do a timed countdown inside a contract.

Basically I want to see if it's possible to trigger a process inside a contract that decrements or increments a value in the contract every x amount of seconds or minutes.

I wanted to see if this was possible to do internally? Or if the only way was to have some backend bot running to perform increment/decrement transactions.

Any insight is much appreciated! Thank You!


texts: how do I know when my testnet node is fully synchronized, significance out output text

texts:
I've started my geth node with the following command:

$ geth --testnet --fast --cache=512 console

Now my console looks something like this:

How will I know when my node is fully synchronized?

INFO [07-20|13:32:48] Imported new state entries    count=384  elapsed=14.509ms  processed=1610372 pending=101560
INFO [07-20|13:32:48] Imported new block receipts   count=282  elapsed=66.980ms  number=1317825    hash=1085ad…37a592 ignored=0

Why are those two entries above different?

Is it that Imported new block receipts represents a block and Imported new state entries represents a transaction?

Is this node, as it was initiated with the command above, by default mining and proposing blocks to the network?


texts: Hashing Algorithm - Multiple choices in Solidity

texts: Is it possible to choose another SHA algorithm - say SHA256 - in Solidity?  Anyone having issues with NIST compliance?


texts: How is a private blockchain secure from a 51% attack?

texts:
How does a private blockchain such as VaultOS protect from a 51% attack? Is it somehow piggybacking on the public blockchain, or (I assume) are they running separate servers they control?

It seems if they are running their own hardware, that it is distributed but not protected by a huge volume of independently-run servers. I imagine they would run the servers independently but it's still a central authority running them so that has its limits.

Would someone please educate me?


texts:
Hi I'm trying to update this code from solidity 0.4.X to 0.5.X and am currently stuck on this bug

    struct JediBet {
    uint guess;
    address payable addr;
    BetStatusEnum status;
    uint betAmount;
}

//the 'game' structure
struct Game {
    uint pot;
    uint outcome;
    GameStatusEnum status;
    JediBet originator;
    JediBet taker;
}

//bet status event
event BetStatus (
    GameStatusEnum gameStatus,
    BetStatusEnum originatorStatus,
    address originatorAddress,
    uint originatorGuess,
    address takerAddress,
    BetStatusEnum takerStatus,
    uint takerGuess,
    uint betAmount,
    uint actualNumber,
    uint pot
);

//the game
Game game;

//fallback function
function() external payable {}

function resetGame() private {
    //reset game
    game.status = GameStatusEnum.STATUS_NOT_STARTED;
    game.outcome = 0;
    game.pot = 0;

    game.originator.guess = 0;
    game.originator.betAmount = 0;
    game.originator.addr = 0;
    game.originator.status = BetStatusEnum.STATUS_UNKNOWN;

    game.taker.guess = 0;
    game.taker.addr = 0;
    game.taker.status = BetStatusEnum.STATUS_UNKNOWN;
}

Error Message:

    Compiling your contracts...
===========================
> Compiling .\contracts\Bet.sol
> Compiling .\contracts\Migrations.sol

/C/Users/Michael/ethereum/p60/contracts/Bet.sol:53:32: TypeError: Type int_const 0 is not implicitly convertible to expected type address payable.
        game.originator.addr = 0;
                               ^
,/C/Users/Michael/ethereum/p60/contracts/Bet.sol:57:27: TypeError: Type int_const 0 is not implicitly convertible to expected type address payable.
        game.taker.addr = 0;
                          ^
,/C/Users/Michael/ethereum/p60/contracts/Bet.sol:106:13: TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address".
            origAddress.transfer(origPot/2);


texts:
I am making  an appointment system using Ethereum network where users can book appointments and service providers can approve these appointments. My question is how can i show users the schedule of a particular service provider.
here is a view of appoinment contract.

//pragma solidity ^0.4.23;
contract Appointment{
  enum AppointStatus {
    CREATED,
    CONFIRMED,
    IN_SESSION,
    COMPLETED,
    CANCELLED
  }

address public owner;
uint public id;
string public title;
AppointStatus public status;
uint public timeNow;
uint public timeBookedFor;

constructor(
uint _id,
string _title,
uint _timeNow,
uint _timeBookedFor
)
public {
    owner = msg.sender;
    id = _id;
    title = _title;
    doctor = _doctor;
    timeNow = _timeNow;
    status = AppointStatus.CREATED;
    timeBookedFor = _timeBookedFor;
}

}


texts: Accepting bitcoin during crowdsale and making refund if soft cap not reached

texts: I'm gonna make some api to allow my crowdsale to accept bitcoin, however I ran into a problem.  Because I will make refunds if soft cap not reached. What the best way to refund everything that was bought with btc?


texts: The logs bloom filter in the block header has a size of 2048 bits. How many messages will it accommodate before the false positive rate is too high for it to be useful anymore? If a formula could be provided that would be excellent.


texts:
Running geth on clean ubuntu 14.04 x64

After running geth --fast syncing stoppes on some point, like that:

I0321 11:31:39.971284 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 188 txs in 3.539956421s. #178700 [f77611b1 / 81122e65]
I0321 11:31:46.274148 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 570 txs in 6.300590994s. #178956 [6dd11d8f / dba1d24d]
I0321 11:31:51.141699 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 252 txs in 4.864679475s. #179212 [bd22d2ba / 95e5cd8a]
I0321 11:32:07.463688 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 941 txs in 16.316555449s. #179468 [d8d6ad74 / 9d3820b7]
I0321 11:32:12.135834 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 256 txs in 4.66919216s. #179724 [c43d0171 / 3ce5ce4d]
I0321 11:32:17.759139 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 199 txs in 5.617463517s. #179980 [e4844648 / 602a284b]
I0321 11:32:24.569821 core/blockchain.go:959] imported 256 block(s) (0 queued 0 ignored) including 195 txs in 6.807623198s. #180236 [7b5c8d4b / 8e9051e3]
I0321 11:32:25.599760 core/blockchain.go:959] imported 60 block(s) (0 queued 0 ignored) including 45 txs in 1.029029976s. #180296 [ec5742fb / 7b71e76e]

It continue after Ctrl+C and run again. But what is the problem?


texts: Truffle when is deployer.link required for migrate

texts:
In truffle quick start, its contract MetaCoin has dependency of library ConvertLib. Then in the deployment file, deployer.link(ConvertLib, MetaCoin) is manually added, and if deployer.link is deleted, there is failure when do migrate.
However, if I add a library called MySafeMath(its content is the well-known SafeMath), and import it to contract MetaCoin, then add a line using MySafeMath for uint256, and a function
function getBalanceInMath(address addr) public view returns(uint) {
    return balances[addr] * 2000;
}

and do truffle migrate again, there is no failure.
So why MySafeMath does NOT need a deployer.link?
Do I need to recursively find out all the dependencies which could be a lot of work for a large project?


texts: Error: intrinsic gas too low while deploying contract

texts:
I am trying to setup a contract in my private ethereum network. For that, I picked up a sample contract code from the internet:

pragma solidity ^0.4.19;

contract getSchwifty {
  string internal constant seeWhatYouGot = "I want to see what you got!";
  string internal contestResult;

  // Contract constructor that takes a string param
  function getSchwifty(string _contestResult) public {
    contestResult = _contestResult;
  }

  function showMeWhatYouGot() external pure returns (string) {
    return seeWhatYouGot;
  }

  function enterContest(string _contestEntry) external view returns (string) {
    // completely disregard the _contestEntry ;)
    return contestResult;
  }
}

I compiled the abi and bytecode for this and am using it to deploy the contract.

var getSchwifty = eth.contract(<ABI generated from solc --abicommand>)
var bytecode = '0x<bytecode generated from solc --bin command>'

and then did

var deploy = {from:eth.coinbase, data:bytecode, gas: 4000}
var getSchwiftyPartialInstance = getSchwifty.new("DISQUALIFIED!", deploy)

basically here I am trying to create a new instance of the contract I wrote above I guess. However, the last step fails with the error:

> var getSchwiftyPartialInstance = getSchwifty.new("TEST", deploy)
Error: intrinsic gas too low
    at web3.js:3143:20
    at web3.js:6347:15
    at web3.js:5081:36
    at web3.js:3021:24
    at <anonymous>:1:34

I tried: eth.getBlock("latest").gasLimit. this gives 5003. I have set gasLimit to the same value in genesis.json as well.

I get the above error for different values of gas in var deploy = {from:eth.coinbase, data:bytecode, gas: 4000}. If I increase the value to something higher than the limit obtained from: eth.getBlock("latest").gasLimit, I get an error: exceeds gas limit.

Any suggestions on what could be wrong and what steps I could take. I did ensure that the peer is talking other peers.


texts: Web3 - Having problems getting address of account

texts:
I have a web provider class
const Web3 = require('web3');

const web3Provider = new Web3.providers.HttpProvider('http://localhost:7545');
const web3 = new Web3(web3Provider);

class Web3Provider {
    getAccounts(callback) {
      web3.eth.getAccounts((error,result) => {
          if (error) {
              console.log(error);
          } else {
              callback(result);
          }
    });
}

module.exports.Web3Provider = Web3Provider;

and import this in my app.js class
Web3Provider = require('./api/web3Provider.js').Web3Provider;

let web3Provider = new Web3Provider();

var accounts;
web3Provider.getAccounts(function(result) {
       accounts = result;
       console.log(accounts);
    });

console.log('Check2, ' + accounts);
...

With the second print statement, I'm getting undefined, but the first is printing the correct accounts. How can I get the actual list of accounts instead of undefined?
Thank you


texts: Is it possible to write an online browser game in ASP.net and integrate a smart contract to buy assets in that game for example?

texts:
I am fairly new to solidity, and i am exploring decentralized game development.

This said, let us go more into the details. Imagine i want to develop a 2d game, where you can buy for example assets, like a weapon or a potion or anything like this.

I can write this game let's say in ASP.net, combined with HTML5, JavaScript and Ajax, and it would work just fine in a webbrowser.

But is it possible to make this game from that point communicate with the Ethereum blockchain to exchange data and make transactions, like the purchasing example that i explained before?

If yes, where is the best way to start learning this? Does anybody have experience with this or can anyone share some good resources to get me started?

Thank you so much for your time and help!


texts:
https://github.com/rayonprotocol-research/solidity-upgradable-contracts/blob/master/contracts/Proxy.sol

I'm practicing proxy pattern but i dont know how to call function at logic contract from proxy contract. I think I should use Web3. so proxy pattern is for only web3 or can I call function from ethereum Wallet??
My english is not good sorry.


texts: When writing ERC20 token, could I use a different event name? Or must I use Transfer as the token transfer event name?


texts: Golang - alloc large Wei amount to address

texts:
Im modifying the puppeth genesis wizard file for my own use case. I want to be able to assign a pre-set amount in Wei to a few chosen addresses..

Im having some trouble figuring out how to format the number for these users, i would like to assign 50000000000000000000000000 but keep getting a lot of errors with numbers being too big etc.. anyone know a work around ? the original function looks like this

        genesis.Alloc[*addy] = core.GenesisAccount{
            Balance: new(big.Int).Lsh(big.NewInt(1), 256-7), // 2^256 / 128 (allow many pre-funds without balance overflows)
        }


texts: Does 'estimateGas' behave the same on Ganache and on mainnet?

texts:
I noticed that estimateGas behavior in Ganache has changed:

In version 6.4.1, it throws an exception if exceeding the gas-limit.

In version 6.5.1, it returns the estimation even if exceeding the gas-limit.

I've been testing my script, and I had to update it according to this change.

What behavior should I expect on the mainnet? (I ask before I start spending my funds there).

Thank you!


texts:
My understanding of Geth's trie pruning is based off this geth v1.8 release blog post: https://blog.ethereum.org/2018/02/14/geth-1-8-iceberg%C2%B9/

  Trie pruning is enabled on all --syncmode variations (including --syncmode=full). If you are running an archive node where you would like to retain all historical data, you should disable pruning via --gcmode=archive

But how many trie nodes persisted to disk, are the trie nodes on disk also garbage-collected? This next quote doesn't make it any clearer

  Geth v1.8.0 takes an initial stab at the problem by introducing an in-memory cache in which to store the recent trie nodes. As long as the nodes are in memory, they are cheap to reference count and garbage collect. Instead of writing each trie node to disk, we keep it around as long as possible, hoping that a future block will make it obsolete and save us a database write.

I started 2 Geth v1.8.17 nodes to try and understand:

--syncmode=full finished with ~113GB and a couple days later is ~134GB

--syncmode=fast also finished with ~113GB and a couple days later is also ~134GB

But how many trie nodes will it keep on disk? If it finished syncing around ~113GB and is now ~134GB just ~1.5 days later, then does that mean it's currently storing 134-113=21GB worth of trie nodes on disk?
If the state is ~7GB, then is the total state storage equal to the number of trie nodes * 7GB? (i.e. if we store 1500 trie nodes than do we have 10TB of disk? I know this isn't true, so what am I missing)?


texts: Can you obtain the ABI of a smart contract using the contract address and contract code?

texts:
I have an ABI I'm trying to use to execute a withdraw of Ethereum from a smart contract via MyEtherWallet, but I'm receiving an error of "Please enter a valid ABI."

I'm concerned the ABI I have is not correct so is there a way to generate the ABI myself using the contract address and contract code? Needless to say, I am new to smart contracts and not a programmer.


texts:
I don't know the required length of my array before execution of the function.. why technically can't I resize my memory array?

What is the common way to go around of this problem, if you are also facing it.

I could make a storage array, and clear it at the end of the function, but would it take more gas? I also know the upper bound of the required length, so I could allocate a memory array with the upper bound size but 95% of it would be unused most of the time.

To make it clear I'm designing a market, there are n buy and m sell orders, I want to match them, matchedOrders array can be up to the size of max(m,n).


texts: Sending a transaction with minimum gas; will it ever complete?

texts: About one day ago I sent a transaction with an average gas limit, but a set a price of 15 Gwei. The transaction is still pending nearly 24 hours later and is still pending; will it ever complete?


texts: My ethminer was working perfectly fine then my internet went out for a few minutes and this poped up within startup of ethminer DAG Generation Failure. Reason: Invalid argument   i mine on dwarfpool


texts: Is it possible to assign a name with Ethereum Name Service to a Smart Contract's address on a testnet? I found a description only for personal wallet.


texts: Testrpc - How to turnoff writing messages to the console?

texts:
Is there any way to force testrpc to stop writing messages to the console ?
Currently I am getting ton of messages  about getBlockByNumber

eth_getBlockByNumber
eth_getBlockByNumber
net_version

The most important thing I need in the moment is list of accounts ( public and private key ) and after some time it is lost. The only solution I have is to write output to the file.(testrpc > output.txt) This works, but would be easier if I can just force testrpc to stop writing useless messages to the console.

Thanks.


texts: Get rid of Metamask sign confirmation dialog

texts: I am using web3 for users to sign some random string from web application. I give user string, he/she signs it after Metamask dialog's "Sign" button. but there is a problem when i want user to sign about 1000 random strings separately. there are unhandled amount of confirmation dialogs. what is the solution?


texts: Where can I get list of open Ethereum nodes so I can use the RPC calls?

texts:
In Bitcoin I can use the rpc calls to manage the node or broadcast transactions. How can this be done with Ethereum?

Is there a list of public open nodes I can use?
How can I do this in the browser using javascript?


texts: After loading the solidity script, i get null [object Object]. What should i do?

texts:
I wrote a contract greeter and mortal, they are as follows:

contract mortal {

    address owner;

    function mortal() { owner = msg.sender; }

    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}

contract greeter is mortal {

    string greeting;

    function greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* main function */
    function greet() constant returns (string) {
        return greeting;
    }
}

Then i compiled the code using Solidity online compiler. I copied the compiled code and pasted in a text file with name "helloworld.js" as follows:

var _greeting = /* var of type string here */ ;
var greeterContract = web3.eth.contract([
  {"constant":false,"inputs": [], "name":"kill", "outputs":[], "payable":false, "type":"function"},
  {"constant":true, "inputs": [], "name":"greet", "outputs":[{"name":"", "type":"string"}], "payable":false, "type":"function"},
  {"inputs": [{"name":"_greeting", "type":"string"}], "type":"constructor"}]);

var greeter = greeterContract.new(_greeting,
  {
    from: web3.eth.accounts[0],
    data: 'data (some numbers and alphabets)',
    gas: 4700000
  }, function (e, contract) {
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
      console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
  }
)

I went to the cmd and started my blockchain network. In geth console i unlocked my account with etherbase and used loadScript("C:/Rahul13615/blockchain/node1/contracts/helloworld.js")

Ideally it should return:
Contract mined! address: some address

but it returns:

  loadScript("C:/Rahul13615/blockchain/node1/contracts/helloworld.js")
  null [object Object]
  true

What should i do?


texts: Will it ever be possible to group multiple ERC20 tokens into a single transaction?

texts:
Specifically, if I wanted to send multiple different tokens to a smart contract, but it was important to the contracts function that all tokens arrive at the same time, could I put;
20 Token A
45 Token B
7.5 Token C
in a single transaction, or easily be able to create packages of different tokens to send out together and remain together when sent back and forth?


texts: Smart contract consensus - underpinned by transactions?

texts:
I can easily visualise how consensus can be reached on transactions in systems such as Bitcoin, but I struggle to understand how consensus can work in a smart contract platform - i.e how can nodes reach consensus that code has been executed correctly.

My hunch is that this is based on the fact that each function call of a contract needs to amend account balances - and it is this which is validated for consensus?


texts: How can i make a contract in which i need two address to call a function in a contract instead of just one, the first address is the owner of the contract which is compulsory which is known at the time of deploying the contract but the second address is not stated in the contract  because there are thousands of second address so including all of them in contract will consume alot of gas, so any better way to do this?


texts: (Truffle) how to call finalize() function after finishing crowdsale

texts:
I would like to call token.transferOwnership(msg.sender) after finishing timed crowdsale. So, I inherited FinalizableCrowdsale contract, then override finalization() function to call transferOwnership on the crowdsale contract.

Actually, I can test to call crowdsale.finalize() on Truffle console and it is working well, but I don't know how to call the function automatically after finishing crowdsale. When crowdsale started, the token ownership has been transferred to crowdsale contract. Um, Do I have to modify hasClosed() function in TimedCrowdsale? or is there any way to call the fucntion...?

I tried to call it on Etherscan after verifying the code, but I couldn't do cos the crowdsale contract has the ownership...

Crowdsale Migration.js

const DappToken = artifacts.require("./DappToken.sol");
const DappTokenCrowdsale = artifacts.require('DappTokenCrowdsale');

const ether = (n) => new web3.BigNumber(web3.toWei(n, 'ether'));

const duration = {
    seconds: function (val) { return val; },
    minutes: function (val) { return val * this.seconds(60); },
    hours: function (val) { return val * this.minutes(60); },
    days: function (val) { return val * this.hours(24); },
    weeks: function (val) { return val * this.days(7); },
    years: function (val) { return val * this.days(365); },
  };

// module.exports = function(deployer, network, accounts) {
module.exports = function(deployer, network, accounts) {
    const latestTime = Math.floor(Date.now() / 1000);
    const _token = DappToken.address;
    const _rate = 1000;

    const _wallet = accounts[3]; // Collecting Wallet
    const _openingTime = latestTime + duration.minutes(1);
    const _closingTime = _openingTime + duration.minutes(2);
    const _cap = ether(100);

    console.log("Open: " + new Date(_openingTime*1000) + " Close: " + new Date(_closingTime*1000));

    return deployer.deploy(DappTokenCrowdsale, _rate, _wallet, _token, _cap, _openingTime, _closingTime)
        .then(() => {
            return DappToken.deployed().then((token) => {
                return token.transferOwnership(DappTokenCrowdsale.address)
            });
        });
};

Crowdsale Contract.sol

pragma solidity 0.4.24;

import "./DappToken.sol";

import "../node_modules/openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol";
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol";
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/validation/CappedCrowdsale.sol";
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/validation/TimedCrowdsale.sol";
import "../node_modules/openzeppelin-solidity/contracts/crowdsale/distribution/FinalizableCrowdsale.sol";
// import "../node_modules/openzeppelin-solidity/contracts/crowdsale/validation/WhitelistedCrowdsale.sol";

contract DappTokenCrowdsale is Crowdsale, MintedCrowdsale, CappedCrowdsale, TimedCrowdsale, FinalizableCrowdsale {
    MintableToken public token;
    address public tokenAddress;
    address public crowdsaleOwner;
    address public founderWallet;

    bool public isFinalized = false;

    constructor(
      uint256 _rate,
      address _wallet,
      MintableToken _token,
      uint256 _cap,
      uint256 _openingTime,
      uint256 _closingTime
    )
    Crowdsale(_rate, _wallet, _token)
    CappedCrowdsale(_cap)
    TimedCrowdsale(_openingTime, _closingTime)
    FinalizableCrowdsale()
    MintedCrowdsale()
    public
    {
      founderWallet = _wallet;
      token = _token;
    }

    function finalization() internal {
      token.transferOwnership(msg.sender);
      super.finalization();
    }
}


texts: How to make sign tx for erc20 token transfer?

texts:
How can I make an erc20 token transfer in node, I know to transfer eth is like this for using ethers. Lib:

let privateKey = "0x3141592653589793238462643383279502884197169399375105820974944592"
let wallet = new ethers.Wallet(privateKey)

console.log(wallet.address)
// "0x7357589f8e367c2C31F51242fB77B350A11830F3"

// All properties are optional
let transaction = {
    nonce: 0,
    gasLimit: 21000,
    gasPrice: utils.bigNumberify("20000000000"),

    to: "0x88a5C2d9919e46F883EB62F7b8Dd9d0CC45bc290",
    // ... or supports ENS names
    // to: "ricmoo.firefly.eth",

    value: utils.parseEther("1.0"),
    data: "0x",

    // 这可确保无法在不同网络上重复广播
    chainId: ethers.utils.getNetwork('homestead').chainId
}

let signPromise = wallet.sign(transaction)

signPromise.then((signedTransaction) => {

    console.log(signedTransaction);
    // "0xf86c808504a817c8008252089488a5c2d9919e46f883eb62f7b8dd9d0cc45bc2
    //    90880de0b6b3a76400008025a05e766fa4bbb395108dc250ec66c2f88355d240
    //    acdc47ab5dfaad46bcf63f2a34a05b2cb6290fd8ff801d07f6767df63c1c3da7
    //    a7b83b53cd6cea3d3075ef9597d5"

    // 现在可以将其发送到以太坊网络
    let provider = ethers.getDefaultProvider()
    provider.sendTransaction(signedTransaction).then((tx) => {

        console.log(tx);
        // {
        //    // These will match the above values (excluded properties are zero)
        //    "nonce", "gasLimit", "gasPrice", "to", "value", "data", "chainId"
        //
        //    // These will now be present
        //    "from", "hash", "r", "s", "v"
        //  }
        // Hash:
    });
})


texts:
I tried creating genesis block. I have created a directory to store the chaindata. But on initializing genesis.json file I am getting this error:

  invalid genesis file:invalid character '<' looking for beginning of the value


texts: Solidity Truffle React TestRPC: Invalid address error while creating transactions through React app

texts:
I am writing a simple contract which is basically a registry. I am using testRPC for my ethereum testing.
Following is my contract on Truffle:

notary.sol

pragma solidity ^0.4.11;

contract notary {
    struct individual {
        bytes32 firstname;
        bytes32 lastname;
        uint yob;
        bytes32 pancard;
        uint aadhar;
    }
    mapping(address => individual) public user;
    function Register(address _to, bytes32 _firstname, bytes32 _lastname, uint _yob, bytes32 _pancard, uint _aadhar) returns (bool success) {
        if (user[_to].aadhar != 0) {
            return false;
        }
        user[_to].firstname = _firstname;
        user[_to].lastname = _lastname;
        user[_to].yob = _yob;
        user[_to].pancard = _pancard;
        user[_to].aadhar = _aadhar;

        return true;
    }

    function getDetails(address _to) constant returns (bytes32 _firstname, bytes32 _lastname, uint _yob, bytes32 _pancard, uint _aadhar) {
        return (user[_to].firstname, user[_to].lastname, user[_to].yob, user[_to].pancard, user[_to].aadhar);
    }
}

When I have deployed the contract using truffle compile and truffle migrate --reset everything is working as intended. I have already registered one entry on the contract:

Action through console

> notary.deployed().then(function(instance) {NOTR = notary.deployed.at(instance.address)})
> NOTR.Register(web3.eth.accounts[9], 'mukesh', 'kumar', 1987, 'fbjsdkfd67', 324234)
> NOTR.getDetails(web3.eth.accounts[9])

[ '0x6d756b6573680000000000000000000000000000000000000000000000000000',
  '0x6b756d6172000000000000000000000000000000000000000000000000000000',
  { [String: '1987'] s: 1, e: 3, c: [ 1987 ] },
  '0x66626a73646b6664363700000000000000000000000000000000000000000000',
  { [String: '324234'] s: 1, e: 5, c: [ 324234 ] } ]

Now, next I am trying to have this with React as an interface. My React code is longer than I would want to put in here. Mainly, the interface is simply like the below:

Basically, as I click Submit I want to create a new registration. I have declared ABI, Contract Address and other parameters as required in my React App, in addition to all proper import etc. as required therein. In fact the following actually work on my React interface:

  handleSubmit(event) {
    // alert(notaryContract.getDetails(ETHEREUM_CLIENT.eth.accounts[9]))
    // alert(JSON.stringify(this.state))
    // alert(ETHEREUM_CLIENT.isAddress(ETHEREUM_CLIENT.eth.accounts[0]))

But as soon as I try notaryContract.Register('0xcc82fa55789663402c013a497eac268172af7f9d', this.state.setFirstName, this.state.setLastName, this.state.setYearofBirth, this.state.setPanCard, this.state.setAadhar) it gives me an error as following (the _to address included is one of the testrpc ones:

    Uncaught Error: invalid address
        at inputAddressFormatter (http://localhost:3000/static/js/bundle.js:59056:11)
        at inputTransactionFormatter (http://localhost:3000/static/js/bundle.js:34345:27)
...long list...
        at dispatchEvent (http://localhost:3000/static/js/bundle.js:31505:20)

Apologies for a long question but I am sure I am missing something minor here and I had to add in step by step reproduction to allow others to point out the problem. I have tried entering address in string form, then also simply using web3.eth.accounts[x] for including the [_to] address, but to no avail. I am thinking possibly because getDetails is a constant function it is working since it does not expend any gas whereas Register doesn't creates a transaction and cause a state change. However, I can't seem to fathom why it works in truffle console whereas it doesn't in React app. I have checked the bundle.js from where invalid address error is coming from but given that there are no proper debugging logs yet to understand the issues, I am not able to get it running. Any help is very appreciated.


texts: ENS testnet contract - bad jump when following quickstart tutorial

texts:
Following the quickstart guidance using Ropsten testnet, I have done the following on a synced geth console:

> loadScript('/my/path/to/ensutils-testnet.js');
> new Date(testRegistrar.expiryTimes(web3.sha3('blipblop.test')).toNumber() * 1000)

<Date Thu, 01 Jan 1970 01:00:00 BST>

> ens.setResolver(namehash('blipblop.test'), publicResolver.address, {from: eth.accounts[0]});

"0x28f01d23b98a7b4fe1bc4324cb70e406714e1c14e64e632708f8ec44cebbde78"

When I look up the transaction on etherscan, it reports a bad jump destination and the name does no resolve:

> getAddr('blipblop.test')

"0x0000000000000000000000000000000000000000"

Am I doing something obviously wrong?

Should there be a delay between setting the resolver and being able to resolve the name?

Related (on main net): ENS setResolver bad jump destination


texts: Infura getFilterLogs api returns empty array

texts:
I am trying to filter transfer events using node.js for a contract address between a range of blocks. I am trying to filter the latest 7 transactions which can be shown in etherscan here. My code is as follows:
const Web3 = require('web3');
const fetch = require('node-fetch');

let infura_url = "https://mainnet.infura.io/v3/853346f695b740fe8bd7d8f583bcf55f"
let web3 = new Web3(new Web3.providers.HttpProvider(infura_url))

let fromBlock = web3.utils.toHex(10394853);
let toBlock = web3.utils.toHex(10399444);
let address = "0x683f6e80c378e57fea188d53f4440600e87abc46";
let blockHash = "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35"
let topic = ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"];

let body = {
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
        "toBlock": fromBlock,
        "fromBlock": toBlock,
        "address": address,
        //"blockHash" : blockHash
        "topic": topic
    }],
    "id": 1
};

fetch(infura_url, {
    method: 'post',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(body)
}).then(result => result.json())
    .then(response => {
        console.log(response);
    }).catch(err => res.json({ error: err.message }));

However it returns an empty array as result:
{ jsonrpc: '2.0', id: 1, result: [] }

Also, I want to understand how to pass the fromBlock and toBlock. The documentation says that the blockFrom can be an integer number but when I write it in integer it says the value should be hex  "0x". No address is working in the address filter. The only results I can get are with blockHAsh. Kindly help me in figuring out the issue. The contract address, toBlock, fromBlock and topic is mentioned in the code.


texts:
I would like to switch the smart contract compiler from Solidity to Viper. I'm following the Viper support page found in Populus documentation.

This is what I get at the final step:

Mac:tutorial admin$ py.test
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/__init__.py", line 397, in load_setuptools_entrypoints
plugin = ep.load()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2404, in load
self.require(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2427, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pkg_resources/__init__.py", line 875, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pytest 3.3.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.parse('pytest!=3.3.*,>=2.7.2'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/py.test", line 11, in <module>
sys.exit(main())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/config.py", line 50, in main
config = _prepareconfig(args, plugins)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/config.py", line 160, in _prepareconfig
pluginmanager=pluginmanager, args=args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/__init__.py", line 617, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/__init__.py", line 222, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/__init__.py", line 216, in <lambda>
firstresult=hook.spec_opts.get('firstresult'),
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py", line 196, in _multicall
gen.send(outcome)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
raise ex[1].with_traceback(ex[2])
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
res = hook_impl.function(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/config.py", line 943, in pytest_cmdline_parse
self.parse(args)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/config.py", line 1108, in parse
self._preparse(args, addopts=addopts)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_pytest/config.py", line 1071, in _preparse
self.pluginmanager.load_setuptools_entrypoints('pytest11')
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pluggy/__init__.py", line 402, in load_setuptools_entrypoints
"Plugin %r could not be loaded: %s!" % (ep.name, e))
pluggy.PluginValidationError: Plugin 'ethereum' could not be loaded: (pytest 3.3.1 (/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages), Requirement.parse('pytest!=3.3.*,>=2.7.2'))!

Thanks for your help!

UPDATE

I don't know why but py.test didn't work any longer after installing Viper.
That creates version conflicts solved with:

 pip3 install 'pytest!=3.3.*,>=2.7.2'


texts: Import address truffle console with private key

texts:
Im deploying to the BSC testnet:
bscTest: {
      provider: () => new HDWalletProvider(privateKey, `https://data-seed-prebsc-1-s1.binance.org:8545/`),
      network_id: 97,
      confirmations: 1,
      timeoutBlocks: 200,
      skipDryRun: false,
      from: "0x96122617199a33fd297cbBA77Bec8EAc0a745D67",
      gas: 10000000,

    },

All successfully deployed, I'm trying to interact with that contract with the imported address, but i'm getting:
Error: Unknown address - unable to sign transaction for this address: "0x32159ea969bf703cfe9655b526ec29d63c55abdb"\n'

This address comes from https://vanity-eth.tk/ and I filled it with BNB from https://testnet.binance.org/faucet-smart, how can I use this address in truffle console? how import the private key for that address.


texts: why does keccak256 in assembly require 2 arguments?

texts:
Why does keccak256() in assembly require 2 arguments? What is the second argument?

assembly {
let foo := keccak256(4)
}

returns error

Function expects 2 arguments but got 1.


texts:
I'm just getting into cryptocurrencies so forgive me if there are some basics I am missing out on.

I have got a bitcoin account up and running and will soon be buying a few just to test things out, the purpose of buying these is so that I can then buy Ether (Cant go straight from my currency to Ether).

So I have downloaded the desktop version of Mist, and have created an account in both the Main Network and the TestNet, but am not sure what the difference between the two are? Both accounts have the automatic name : Main Account (ETHERBASE). I dont really understand what the etherbase is either? Is that just the network?

I've read that the testnet is just for trying things out? But I'm not sure exactly what that entails.

But I'm presuming that if I have Bitcoin and want to buy Ether (using shapeshift.io for example), that I would need to add the account details for the account that is set up on the main network and not the TESTNET?


texts: Should I store an ENS domain asset in the same wallet address where I plan to resolve that domain to?

texts:
If I go to ens.domains and buy a .eth domain, that domain name will be purchased in my ethereum wallet address 0x1111...
Does it make sense to do this, given that I afterwards want to forward/direct/mask/resolve this domain name to that exact same address, 0x1111...? Or is this bad practice and susceptible to theft somehow? it worries me that this has an appearance of a circular activity
In other words, should I store the digital domain on a different wallet address (0x2222...) than the one I plan to resolve it to (0x1111...)?


texts: Is there a non-Electron based 100% open source wallet for Linux

texts: I have tried nearly all desktop wallets, they are either based on Electron which does not run great on a Raspberry Pi with X11 Forwarding or don't seem to be open source, some have at least some propriety code which I don't want to trust my coins to, Ether is open source so should the wallet. A QT based wallet like DOGE has would be great. Even a CLI based wallet would perfect.


texts: Remix error : The constructor should be payable if you send value

texts:
I got below piece of code from one site and trying to run it using Remix. But while creating the contract I am getting error message:

  The constructor should be payable if you send value

I assigned gas limit as 80000000000 and value as 1 ether while creating the contract, which didn't had any positive effect.

Please help, how I can solve this error?

/*
   WolframAlpha example

   This contract sends a temperature measure request to WolframAlpha
*/

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

contract WolframAlpha is usingOraclize {

  string public temperature;

  event newOraclizeQuery(string description);
  event newTemperatureMeasure(string temperature);

  function WolframAlpha() {
      update();
  }

  function __callback(bytes32 myid, string result) {
      if (msg.sender != oraclize_cbAddress()) throw;
      temperature = result;
      newTemperatureMeasure(temperature);
      // do something with the temperature measure..
  }

  function update() payable {
      newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
      oraclize_query("WolframAlpha", "temperature in London");
  }

}


texts: What is param of myMethod() in myContract.methods.myMethod().call(options[, callback])

texts:
I have this in Solidity

function getOrder(
        bool _orderType,
        bytes32 _id
    )
        public
        view
        returns (
            address maker,
            uint have,
            uint want,
            bytes32 prevID,
            bytes32 nextID
        )

I want to find what will return in block 1. I use this

myContract.methods.getOrder().call(undefined, 1)

What parameter should I pass into getOreder() ?


texts: How public key is recovered for signature verification?

texts: I see address everywhere in ethereum but not public key, and I understood that address is Keccak-256 of pubkey, and I do not think it is possible to derive pubkey from address. So, my question is during signature verification does the crypto engine somehow recover the pubkey from somewhere or it is able to verify using address directly?


texts:
I am new at ethereum.

I've been reading the white paper and it says that the smart contracts have public keys, but I found nothing on how to get them.

So my question is how to get a smart contract's public key in code ?  and is it possible for it to generate one ?


texts:
I am deploying my smart contracts using web3.js and compiling the code using solc. The contracts are deployed successfully with no issues however I am having a bit of a problem in verifying my contract code. Mostly the issue relies in the code flattening process as I am doing it manually and it seems to be generating a different byte code than the one I have compiled and deployed.

Basically here is how I deploy my multi file contract:

var inputs = {
        'Main.sol': fs.readFileSync('./Contracts/Main.sol').toString(),
    };

    // Assumes imported files are in the same folder/local path
    function findImports(path) {
        return {
            'contents': fs.readFileSync('./Contracts/' + path).toString()
        }
    }

    var output = solc.compile({sources: inputs}, 0, findImports);
    const bytecode = output.contracts['Main.sol:Main'].bytecode;
    const abi = JSON.parse(output.contracts['Main.sol:Main'].interface);

    const contract = web3.eth.contract(abi);
    let gasLimit = web3.eth.getBlock("latest").gasLimit;

const contractInstance = contract.new({
        data: '0x' + bytecode,
        from: web3.eth.accounts[0],
        gas: gasLimit/2,
        chainId: 3
    }, (err, res) => {
        if (err) {
            console.log(err);
            return;
        }

        // Log the tx, you can explore status with eth.getTransaction()
        console.log(res.transactionHash);

        // If we have an address property, the contract was deployed
        if (res.address) {
            console.log('Contract address: ' + res.address);
            // Let's test the deployed contract
            testContract(res.address);
        }
    });

The code above works and the contract is deployed and is fully functional.

Is there a way to automatically flatten the code and create a single sol file using web3 or any other tool.

EDIT: I tried using this utility but still etherscan complains that the flattened code's bytcode does not match the contract


texts: Where I can see my Transaction Hashes and Mining Addresses in Ubuntu?

texts:
I created a coinbase and i used that using passphrase whenever i required , i have all addresses regarding coinbase.

Where I can see my Transaction Hashes and Mining Addresses in Ubuntu ??, I created a private blockchain in my machine.


texts: How do I output the full account on the node?

texts:
http://etherscan.io/accounts/a list of all normal account on the node.
http://etherscan.io/accounts/c list of all contact account on the node.

How did obtain this information? Where did that information come from? (json rpc? java api?)
Is it possible in go-ethereum geth console? or cpp or ethereumj?

All I want is total account transparency. I expect transparency in my private node.  Please help me!


texts:
My contract has a lot of uint256 constant fields that are later used for various calculations. I am close to reaching the maximum allowed contract size and I am looking for optimizations.

I see that having some fields as uint8 instead of uint256 reduces size of the bytecode but at the same time, knowing that for uint8 operations need to downscale and cost more gas I don't want to trade contract bytecode size and the cost of deployment paid once for more expensive day-to-day contract function calls.

Is there any solution allowing storing smaller fields in non 256-bit slots and not paying the cost of downscaling later, during every single operation using those fields?


texts: Constantinople fork: my local Ropsten is not on the same branch of Etherscan

texts:
With the Constantinople fork few days ago (Oct 2018) my local ropsten node is not the same as Etherscan.
I have geth 1.8.3-stable

my node: block hash of 4248333 is 0xb24b6a6...
ropsten.etherscan: block hash of 4248333 is 0xe725eff6...

How do I get back on the same branch as ropsten.etherscan ?


texts:
I need urgent support with Ethereum Networking. A potential enterprise client is asking about the networking of Ethereum Node Peering. We have given them a lot of information about RLPx protocol and how it rides in Transport Layer being TCP based (Layer 4 of the 7 Layer OSI Model). However, the question being asked is “Explain/Describe how the connectivity between 2 peers works across each of the 7 layers of the OSI Model”. Can any one please help with an article or diagram? We can’t find anything covering this particular question.

Regards,
Manoj


texts: Call and Save Returned Value from Method in React

texts:
I am trying to call a method from my smart contract (myMethod) and save the result (result) as a state (this.state.result) in react. However, my state is not being updated to the result. My code is provided below. How can I fix this?

      await this.contractInstance.methods.myMethod().call({from: this.account, gas: 5000000}).then(result => {return this.state.result = result}).catch('That's a RIP');


texts: Could Malware Be Stored in the Blockchain

texts: So if my computer downloads and maybe reads the whole block chain can there be viruses etc. stored within the blockchain/dapps?


texts: call contract function without a fullnode?

texts: I have a contract that I deployed a while ago. My mist is like 6 months behind and I don't even think I have enough HD space for it to catch up. I can still launch it anyway to get contracts and wallets addresses etc. Is there anyway I can interact the same way I would when you click a contact and pick a function under the 'Write to contact' without having to download the fullnode?


texts: Can I easily generate a public address which has no private key?

texts:
I might be wrong in some of the facts that I state here, so please correct me if necessary.

My understanding:

Private key - 256 bits
Public key - 256 bits
Public address - the last 160 bits of a public key
Every private key is mapped to a public key, and hence to a public address

The facts above imply that some private keys are mapped to the same public address, but they do not imply that some private keys are mapped to the same public key.

I would like to ask the following questions:

Do we have any other knowledge as to whether or not some private keys are mapped to the same public key, and hence, some public keys have no private key which is mapped to them?
If the answer to the above question is yes, then there's a possibility that some public addresses have no private key which is mapped to them. Do we know of any such addresses, or if they even exist?

My motivation for asking this, is that I have an ERC20 contract which sometimes (depending on the current state) mints an additional amount of tokens which will later be distributed among (i.e., transferred to) some users.

Now, I need some address to hold these tokens, but I wish to avoid the case where someone has the private key of this address (as slim a chance as it may be).

At present, I am generating this address as follows:

address public constant MINTING_ACCOUNT = address(keccak256("MINTING_ACCOUNT"));

Ideally, I would like to replace this with a constant address which has no private key.

Thank you!


texts:
pragma solidity ^0.4.16;

contract FunctionTest {
    bool public foo = true;
    string public name;
    uint256 public counter = 0;

    function setName() public {
        //
    }

    function writeToStorage() {
        foo = !foo;
    }

    function readFromStorageConstant() public constant returns (bool) {
        return foo;
    }

    function readFromStorageView() public view returns (bool) {
        return foo;
    }
}

I need to accomplish this:
Modify the function setName in a way that would allow setting the value of name

How do I go about this? I have no clue as to how to proceed, any hints?


texts: claymore miner 9.6 gives error CUDA error - cannot allocate big buffer for DAG. Check readme.txt for possible solutions

texts:
i have 6 gpu nvidia 1060 6gb but when i run my batch file this error raise by claymore miner
CUDA error - cannot allocate big buffer for DAG. Check readme.txt for possible solutions.
i set my virtual memory min 16000 and max 20000 but still error raise and unable to mine eth


texts: What happens to ICO tokens on the Ethereum chain after a hardfork? Are they valid on both chains?

texts: With the Ethereum Metropolis hard fork coming up, what happens to ICO tokens like Steemit and all the others built on top of the Ethereum network? Do they automatically fork too?


texts: Why did the DAG file change in block 1080000?

texts:
I'm mining to dwarfpool, and all of sudden am getting this message on the account: "DAG file changed in block 1080000"

Does this mean that my DAG is out of sync and if yes, how do I resync it, tried just rebooting miners but doesn't seem to fix it.

Any help appreciated!


texts: Getiing error in remix while using oraclize

texts: Getting this error" called function should be payable if you send value and the value you send should be less than your current balance" even when i set value


texts:
Assume a miner selects 10 transactions where their total gas is equivalent to the block gas limit (e.g., 6 million gas). But once the miner executed those transactions, he figured out the actual used gas by those transactions is less than the block gas limit (say e.g., 4 millions). Will the miner be able to select other transactions in order to fill the block?

In other words, whether the block gas limit is calculated based on the total gas provided by transaction or by the total used gas, since a user can send a transaction with 1 million gas, but actually their transaction can only use 500,000 gas.

I hope i made it clear!

Thanks


texts: Can I compress a raw, signed transaction into 140 characters

texts:
I would like to basically Make SMS payments of Ether (or bitcoin). The basic Idea I'm thinking about is:

1) Private key signs a transaction on a mobile phone.

2) Raw transaction is 'compressed' somehow into 140 characters.

2) Compressed raw transaction is sent to some phone number where our servers give it to the network, and possible text the recipient that it went through.

Is it possible to get this down to 140 character?