texts: Can I use Coinbase API in place of Metamask?

texts:
I have an application (www.arbol.app) where certain individuals who are new to crypto (and not necessarily technology experts) need to call various payable functions in my smart contract.

The way people would use my application is 1. they would create a coinbase.com account 2. deposit fiat 3. purchase Ether, 4. transfer said Ether to an address saved in their Metamask, and 5. call my smart contract's payable functions while sending ether.

I would like to cut Metamask out of this process as it is prohibitively complicated for the demographic we are targeting (regular people). Is it possible to do this by using the Coinbase API's "send ether" function on behalf of the user targeting our smart contract, and simultaneously executing some web3 code that specifies which specific payable function we want? I know next to nothing about how Metamask works under the hood, so anything is appreciated.


texts: Use bytes32 instead of string for token metadata

texts:
I'm writing a contract for an ERC-20 token, and I've been trying to optimize for gas (since the fees are ridiculous at the moment).
I was wondering if instead of using a string, I could use a bytes32 for the token metadata, and if it would still be able to read the name on etherscan, and anywhere else my token might be registered.
I would be changing from this:
string public constant name = ".....";
string public constant symbol = "...";
string public version = "1.0";

to this:
bytes32 public constant name = bytes32(".....");
bytes32 public constant name = bytes32("...");
bytes32 public version = bytes32("1.0");

I've already tested the two versions, and the second one does save on a lot of gas. Just wondering if I'll run into issues later because of this.
Thanks!


texts: How to get the Etheruem contract init code hash by using remix.ethereum.org?

texts:
How to get the Etheruem contract  init code hash by using remix.ethereum.org ?
It's a little fuzzy with bytecode and deployedBytecode, I use the contract code deploy on mainnet by others, I try to test to get the init code hash, but it got different with others people deployed.
How to get the right init code hash ?  Thank you very much!


texts: (1) Parity: why does syncing fall behind, (2) Why are events missing events because of (1)

texts:
Background:

I have multiple parity nodes setup on Digital Ocean and AWS and event
watchers attached to these nodes.
I also have a service to query
block numbers and compare versus etherscan's current block number.
I have real-time event watchers (event().watch()) attached to these nodes that monitor real-time events on various contracts.

Observations & Problems

From time to time, the nodes fall behind or get stuck, but they
eventually usually catch up.  In rare cases, a restart is required.
If there is an event that is logged in this period where the node
has fallen behind and is catching up, the event watcher misses that
event.

For example, if the node gets stuck on block 5,000,000 (and
say current block is 5,000,100), when the node "catches up" to
5,000,100, any events that were emitted in between (5,000,001 to
5,000,099) are missed and not logged

Questions

Any ideas on why do the nodes fall behind?  When checking, the nodes are
usually connected to 25 peers.  AWS instances are t2.large, 250gb SSD so it
should have sufficient resources (I suspect it's not a disk write issue)
Why are events "lost" during "catching up"?  Basically event().watch() does not catch any events if the node falls behind.


texts: How can I decode a raw transaction using Go / go-ethereum ? There is no method/function to read the raw bytes or the hex into a transaction https://godoc.org/github.com/ethereum/go-ethereum/core/types . Basically I just want to extract the destination address and the amount sent.


texts:
I am parsing the blockchain via Go and I am facing a questionable issue.
Although the transactions are passing all the tests, meaning that I am getting most of the fields, there was a contract that the recipient was nil.
Block number : 12155082
Transaction : link at etherscan
Why does this kind of transaction does not have a recipient at geth(is nil)?
As I understand, upon contract creation, you invoke a constructor of a contract, but still the contract exists so I should get its address, whereas in my case I can't.
Is it some sort of special case in transactions? Is there a way to get this number via Go or do I manually need to search this address?
Thanks in advance!!


texts: Truffle how to test with reference to mainnet smart contract - Error: while migrating VM Exception while processing transaction: revert

texts:
I would like to run a truffle test on a smart contract that includes a smart contract address deployed on mainnet. However, this results in the following error

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

It seems like the migration process running before the actual test fails because the mainnet contract can obviously not be found on my local test chain.

contract WhitelistAdvanced {
    Whitelist internal whitelistContract = Whitelist(0x6198149b79AFE8114dc07b46A01d94a6af304ED9);

    constructor() public {
        address[] memory subscriberList = whitelistContract.getSubscriberList();
        for (uint256 i = 0; i < subscriberList.length; i++) {
            _subscribe(subscriberList[i]);
        }
    }

EDIT:
deploy_contracts.js

const Whitelist = artifacts.require("Whitelist");
const WhitelistAdvanced = artifacts.require("WhitelistAdvanced");

module.exports = function (deployer) {
  deployer.deploy(Whitelist);
  deployer.deploy(WhitelistAdvanced);
};

EDIT:
console output

$ truffle test test/TESTWhitelistAdvanced.js

Compiling your contracts...
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/Whitelist.sol
> Compiling ./contracts/WhitelistAdvanced.sol

Error: Error: Error: while migrating WhitelistAdvanced: Returned error: VM Exception while processing transaction: revert
    at Object.run (/Users/X/.nvm/versions/node/v8.9.4/lib/node_modules/truffle/build/webpack:/packages/truffle-migrate/index.js:92:1)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
Truffle v5.0.33 (core: 5.0.33)
Node v8.9.4


texts: Can the block number be set back in ganache?

texts:
I know about tools like ganache-time-traveler that let you advance the block number.

But is it possible to go back to a lower value?


texts:
I would like to store tokens somewhere else than my wallet due to security reasons. I made a voting system contract and when more than 50% of authorized voters vote for yes, contract transfers limited amount of tokens from safe address to the admin wallet. So if the code is not bugged it's almost impossible to steal tokens, because it would need to hack 2 wallets (where voters' wallets are not associated with each other) at the same time.

function sendTokens(address pAddress, uint pAmount)
    external onlyVotingContract
{
    require(isAdmin(pAddress));
    transferWorker(address(this), pAddress, pAmount);
}

My question is, can this successfuly work if I store tokens at 0x0 instead of address(this)? I must synchronize two contracts to set the same address of total tokens balance in the constructor, so the 0x0 would be the easiest way.


texts: How to Add a Function to an Already Deployed Smart Contract

texts:
I have already deployed a contract on Binance Smart Chain. I now would like to add time lock functionality to this contract to lock some of the tokens for a time period. I know that smart contracts are immutable so there is no way to change the already deployed contract. My question is that : Can I deploy a new contract that only has the time lock function that interacts with my already deployed contract and lock some tokens of the already deployed contract ? In a nutshell, what I want to do is to add a new function to an already deployed contract with a new contract. Is this possible ?
I think it should, because otherwise there won't be any ways to add new functionalities to a deployed contract but I couldn't find any tutorials on that. If there is a way, can you guys point me in the right direction ?
Thank you very much.


texts: Web3Py - How to convert from Gwei to Wei or Ether

texts:
i know there is web3.fromWei('myamount','ether') to convert from Wei to Ether.

But what if i have only the GWei amount?


texts:
I am running in a private ethereum network which I init with a genesis.json file that contains

"gasLimit": "31415926"

Now I am wondering how I can read that via web3, any suggestions? (I want to make sure the limit is set correctly).


texts: "abuse" contract initialization explanation

texts:
I've found this item on the Subtleties page https://github.com/ethereum/wiki/wiki/Subtleties:

  If contract initialization returns an empty array, then no contract will be created. This allows you to "abuse" contract initialization as an atomic multi-operation, which might be useful in some protocols where you want to do multiple things but you don't want some of them to be able to process without others.

Can anyone explain what it means? In particular the 2nd sentence.


texts: JS Testing and Web3 referencing contract at deployed address

texts:
I have a Contract Factory and a sub contract, and now i want to test the newly created sub contract.  This one should be pretty simple, I hope.

it("test CoinNewCoin - Test Created Coin ", function (){

    var fromOwner = accounts[0];
    var coinFactory;
    var coinNewCoin;
    return CoinFactory.deployed().then((instance) => {
        coinFactory = instance;
    }).then(() => {
    return coinFactory.getCoinAddress(fromOwner, {from: fromOwner});
    }).then((result) => {
        console.log(result);
    return CoinNewCoin.at(result).then((instance) => {
    }).then((instance) => {
        console.log(instance); // this is the undefined.
        coinNewCoin = instance;
        return coinNewCoin.getAuthorizationKey();
    })
    }).then((result) => {
        console.log(result);
    });
});

edit: scripting updated.


texts: Malicious smart contract and stolen tokens from other contracts?

texts:
I'm wondering if by interacting with a contract, it could affect my ETH or tokens on other contracts.

I'm asking because I'm seeing many EOS airdrops on ethereum that require us to send a 0 ETH transaction, some with data, to their contract address to claim their tokens.

And because I never heard of such a scam ever happening, I participated in an airdrop that required me sending 0 ETH but no data to a contract. I received their tokens immediately after sending it, but I can't help but wonder if it could later mess with any of my other tokens.

The contract was the following: https://etherscan.io/address/0xb562ec0261a9cb550a5fbcb46030088f1d6a53cf#code


texts: TypeError: value.forEach is not a function when calling a function

texts:
I am using Truffle to deploy a contract on Ganache and retrieve the contract in an express app.
While I can get the contract instance and it can console.log a list of function object, the function cannot be called in the code.
Here is my contract:
contract Vote{
    uint dem = 0;
    uint pub = 0;

    constructor() public {
        dem = 0;
        pub = 0;
    }

    function vote(uint v) public {
        if(v == 1){
            pub += 1;
        } else {
            dem += 1;
        }
    }

    function getWinner() public view returns (uint) {
        if(dem > pub){
            return dem;
        } else {
            return 0 - pub;
        }
    }
}

Code call the function:
var voteAbi = [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":false,"inputs":[],"name":"getWinner","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256[]","name":"v","type":"uint256[]"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
web3.eth.defaultAccount = web3.eth.accounts[0]
web3.personal.unlockAccount(web3.eth.defaultAccount)
var voteContract = web3.eth.contract(voteAbi);
var voteInstance = voteContract.at("0x0711217536458a37580e669de781554ce33236c24711d351d446a437e16ae058");
voteInstance.vote.call(1)
voteInstance.vote(1)
voteInstance.vote.sendTransaction(1,{from:web3.eth.accounts[0]})

All the three lines call the function vote result in the Foreach problem.
I am new to web3 and blockchain! Any ideas on what could go wrong here?


texts: How to change the crypto-currency that is used in paying for gas fees in a private network

texts: I have deployed my own network of blockchain that is based on the ethereum network. I wanted to know if one could change the currency used to pay for the gas on the private network.


texts:
I need to convert my eth key to a geth key.

eth put the key in %appdata%\roaming\Web3\keys, and I see it as a .json file. If I move that to the %appdata%\roaming\Ethereum\keystore directory, geth still doesn't recognize it. If I try to do geth account import keyname.json, that fails with:

Fatal: Could not create the account: encoding/hex: invalid byte: U+007B '{'"

I also tried altering the .json file to look more like the geth key by adding "address":"[address]" to no avail.

Backstory: I created an account using eth, moved some ether into it (verified using etherchain.org), but my eth install was always broken, wouldn't connect to peers, etc., so I want to move the account to geth. The account was generated from eth 0.9.41. I haven't tried to reinstall eth yet in case there is something that needs to be preserved in order to proceed. Safety first...


texts: When is Vyper going to be production ready?

texts:
At a high level, Vyper seems like a much more adoptable language compared to Solidity. Everywhere I look, Vyper is still considered to be "experimental".

Any idea of when it will be production ready? Are there testing protocols to determine when it will no longer be classified as "experimental"?


texts: How to mock an ethers provider while testing with jest?

texts: In the real app, I'm using the web3-react hook to inject the provider, etc. How do I best mock that/replicate that in a Jest Typescript environment?


texts: How to guarantee IPFS file access based on Non Fungible Token ownership (or security)?

texts:
The file is too big to be stored on the blockchain, so it is stored on IPFS.
Only the person who owns a unique Non Fungible Token (or a Security Token) can access it.

Of course I can encrypt the file in such a way that only the token owner can read it. However, when the owner sells the token, he must lose the access to it, and IPFS does not guarantee that the file will disappear from the network immediately.

Is it possible to implement such an access control?

Edit: Any tools are welcome if they allow to solve the problem, such as Zero Knowledge Proof protocols or other cryptographic (or non) tools which I 'm not aware of.


texts: web3.js function contract.once() not working on Kovan, but working on ganache

texts:
I am subscribing to an event (just once, queued after an update) of a contract to reload the data like this on my react frontend:

const instance = new web3.eth.Contract(abi, address)
instance.once(
    'Confirmation',
    {filter: {sender, txnId}},
    () => dispatch(loadConfirmations(address, txnId))
)

it works perfectly when I am on my custom network with ganache. But when I try the same thing on Kovan, the callback does not fire. I tried other methods to subscribe to events, but none of them work. Getting past events works.

Web3 is provided via window.ethereum and I use metamask to inject the web3.

Any idea why I can't subscribe to events on Kovan like this?


texts:
i'm new to ERC721 tokens so this may be a stupid question.

Following the Opensea docs and other docs (for example openzeppelin ones), I just create a simple ERC721 token that i called "avatar" which have some properties (gender, eyes, mounth, etc) and if i understand good, this properties will be server by an API server. So in the player profile page on the future website i will need to code something that will call this API server to get for example the picture of this avatar.

My question is: if i want to implement also Items (for example glasses) that player can buy to wear it to their avatar, where i have to code this items?
It will be inside the Metadata?


texts: Solidity function returns [object Object]

texts:
When I run my solidity function, it's supposed to return a string - but it returns [object Object]
I'm calling the function in my frontend and logging the result of the function call.

Here is my solidity function call

function getResult() returns(string) {
  return result;
}

This is what I have on the frontend

async getResult() {
  let contractInstance = await MyContract.at(this.state.contractAddress)
  let result = await contractInstance.getResult()
  console.log(`This is the result ${result}`);
}


texts:
I can easily interact with metamask via web3 js like this (JS):

web3 = new Web3(web3.currentProvider);

Is it possible to interact with metamask via php? For example (PHP):

$ethereum = new Ethereum('127.0.0.1', 8545);

Javascript equivalent (JS):

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

But the PHP one posted above can only connect to a server node via IP address and I'm not sure if its possible / how to connect with a metamask user in PHP.

I dont think its possible because PHP is server side but if anyone has some insight on this I would appreciate it..


texts:
I know I can backup the keystore files from my running ethereum client which holds my accounts.

But how can I backup wallets created with mist? Is it enough to write down the public address where the wallet contract is stored?


texts:
When I run my code ，it told me that

“TypeError: Cannot read property 'abiDefinition' of undefined”

The error code is：

console.log(calcCompiled["info"]["abiDefinition"]);

The code that I am using is:

let source = "
pragma solidity ^0.4.0;

contract Calc {
  uint count;

  function add(uint a, uint b) returns(uint){ count++; return a + b; }
  function getCount() constant returns (uint){ return count; }}

";

let calcCompiled = web3.eth.compile.solidity(source); console.log(calcCompiled);
console.log("ABI definition:");
console.log(calcCompiled["info"]["abiDefinition"]);

What should I do？


texts: Paradox - I need two deployed contracts to refer to one another

texts:
I have two contracts. #1 creates tokens and sends them to my address. #2 does some other stuff.

'#1 contains a reference to, say, 0xMyAddress (known in advance, of course) in order to grant it special permission for dealing with the tokens. It also needs to contain a similar reference to the address of contact #2.

Contract #2 needs to contain a reference to the address of contract #1, in order to know what tokens it's dealing with.

How do I reconcile this? I have to deploy each contract before I find out what its address will be, so I can't include #1's address in #2, while also including #2's address in #1.

Am I thinking along the right lines here:

Choose which contract will be deployed first, and in that one, include:

function set_otherContractAddress(address _address) public{
    require(msg.sender == 0xMyAddress);
    otherContractAddress = newVal;

}

Then I can deploy that contract, find out it's address, hard code that address into the other contract, deploy it and find out it's address, and then go back and add it to the first contract with that function ^

I hope that makes sense!


texts: Ethereum private network get initiated on 127.0.0.1:8545 and not on my specified ip and port

texts:
I am creating a private blockchain network for testing by doing all the initial steps like creating genesis block and data folder etc.

  Here are some initial commands I have used

geth --datadir "./data" init genesis.json

after running this command I Got following output

WARN [01-15|17:37:00] No etherbase set and no accounts found as default
INFO [01-15|17:37:00] Allocated cache and file handles         database="E:\\my node\\data\\geth\\chaindata" cache=16 ha
ndles=16
INFO [01-15|17:37:00] Writing custom genesis block
INFO [01-15|17:37:00] Successfully wrote genesis state         database=chaindata                            hash=629461
.8c5a75
INFO [01-15|17:37:00] Allocated cache and file handles         database="E:\\my node\\data\\geth\\lightchaindata" cache=
16 handles=16
INFO [01-15|17:37:00] Writing custom genesis block
INFO [01-15|17:37:00] Successfully wrote genesis state         database=lightchaindata                            hash=6
29461.8c5a75

After that I executed following command

geth --networkid 1020 --datadir "./data" --nodiscover --port 30307 --rpc 8105 --rpcaddr 10.37.1.75 --rpccorsdomain "*" --rpcapi "eth,net,web3" console

and got following output

WARN [01-15|17:37:47] No etherbase set and no accounts found as default
INFO [01-15|17:37:47] Starting peer-to-peer node               instance=Geth/v1.6.7-stable-ab5646c5/windows-amd64/go1.8.
3
INFO [01-15|17:37:47] Allocated cache and file handles         database="E:\\my node\\data\\geth\\chaindata" cache=128 h
andles=1024
WARN [01-15|17:37:47] Upgrading chain database to use sequential keys
INFO [01-15|17:37:47] Initialised chain configuration          config="{ChainID: 1020 Homestead: <nil> DAO: <nil> DAOSup
port: false EIP150: <nil> EIP155: <nil> EIP158: <nil> Metropolis: <nil> Engine: unknown}"
INFO [01-15|17:37:47] Database conversion successful
INFO [01-15|17:37:47] Disk storage enabled for ethash caches   dir="E:\\my node\\data\\geth\\ethash" count=3
INFO [01-15|17:37:47] Disk storage enabled for ethash DAGs     dir=C:\\Users\\User(LPT-APR2015-02)\\AppData\\Ethash coun
t=2
WARN [01-15|17:37:47] Upgrading db log bloom bins
INFO [01-15|17:37:47] Bloom-bin upgrade completed              elapsed=4.000ms
INFO [01-15|17:37:47] Initialising Ethereum protocol           versions="[63 62]" network=1020
INFO [01-15|17:37:47] Loaded most recent local header          number=0 hash=629461.8c5a75 td=1024
INFO [01-15|17:37:47] Loaded most recent local full block      number=0 hash=629461.8c5a75 td=1024
INFO [01-15|17:37:47] Loaded most recent local fast block      number=0 hash=629461.8c5a75 td=1024
INFO [01-15|17:37:47] Starting P2P networking
INFO [01-15|17:37:47] RLPx listener up                         self="enode://900958e9480389b0abf1b41152f174fdbe6221fd9f7
8c72f1cfc4bf4c092933fced964356b20314faa3fdc4258fcd7eddcf30d8a68fb589d67ab6b0ab7d81258@[::]:30307?discport=0"
INFO [01-15|17:37:47] IPC endpoint opened: \\.\pipe\geth.ipc
INFO [01-15|17:37:47] HTTP endpoint opened: http://127.0.0.1:8545

Now the issue is I have specified IP addess as 10.37.1.75 and port as 8105 then why the end point is opened at 127.0.0.1:8545

  Note:I have done it several times before this at that time the endpoint was
  started at 10.37.1.75:8105


texts: Why doesn't the Metamask wallet reflect internal transactions in its ledger, but does in its summed balance?

texts:
Metamask wallet has no problem showing on its ledger (inflow and outflow amounts) normal transactions that appear on Etherscan.io for that wallet address. But Metamask fails to reflect the inflows due to Internal Transactions, which appear on a separate tab for the wallet on Etherscan.
Yet, Metamask sums up the true balance fine, although this sum obviously won't correspond with Metamask's apparent ledger, which would be missing the internal transactions accurately shown on Etherscan.
Why is this, and is there a computational work-around?


texts: can't call function in one contract from another contract

texts:
I'm trying to call a function in one contract from another contract with the following simple example:

Untitled.sol:

pragma solidity ^0.4.16;

contract helloworld {
function returnint() returns (uint) {
return 15;
}
}

And the second contract:

pragma solidity ^0.4.16;

import "./Untitled.sol";

contract pullother {

function callFunctionInContractOne (address _address) returns (uint) {
    helloworld contractOne = helloworld(_address);
    contractOne.returnint();
}
}

When calling callFunctionInContractOne() in the second contract, the address of the deployed Untitled.sol is given as a parameter, then the returnint() function in the first contract is called (which should return 15). When I try this in the remix editor I get the following returned instead:

I am copying from calling simple function from another contract but getting a different result. I've also tried running a function on one contract from another on a private blockchain in a similar way but am unsuccessful.

Adding a return value I get the same thing:


texts: What does it mean that if particular wallet has more of particular erc20 token than ever recieving it via transactions? How dit it get there?

texts:
I know this is basic question, but would like to know answer anyway :-) Example is here:
https://etherscan.io/token/0x4dc3643dbc642b72c158e7f3d2ff232df61cb6ce?a=0xd56b96cf1856f839a8fe9b1431ff2b0a782f0e80

This address recieved 5000 tokens, but ballance is 10000, was it some token generation event?


texts: Truffle constant functions run out of gas, how to simulate a local node

texts:
I am new to solidity and web3. I am getting familiar with Truffle, testrpc and web3 1.x. I am also using React as a front end.

I know that functions that don't change the smart contract state can actually run for free if they are executed from a local node. I have a function that would be very costly to run, but I only plan to use it from a local node since it doesn't change the state of the smart contract and is declared as a constant function.

I have been trying to run some automated tests using truffle and I keep getting out of gas errors. So I also tried to run this from React and (not surprisingly) I have the same error.

var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
myAbi = [...]
myAddress = "0x..."
var myContract = new web3.eth.Contract(myAbi, myAddress);

class App extends Component {
  componentWillMount() {
    myContract.methods.myFunction().call().then(console.log).catch(console.error);
  }
  ...
}

  Error: Returned error: VM Exception while processing transaction: out of gas

Is there a way to simulate a local node? I would like to know what causes this problem and what the workaround is. I am mostly interested in getting React to work but I hope there is a generic solution that would also solve this for truffle tests. Any references would also be very much appreciated.


texts:
I am trying to install web3 on ubuntu 16.04 vm and I get the below error.

npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
npm WARN deprecated tar.gz@1.0.7: ⚠  WARNING ⚠ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar

> scrypt@6.0.3 preinstall /home/ltu/web3/node_modules/scrypt
> node node-scrypt-preinstall.js

> scrypt@6.0.3 install /home/ltu/web3/node_modules/scrypt
> node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ltu/web3/node_modules/scrypt/build'
gyp ERR! System Linux 4.13.0-38-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ltu/web3/node_modules/scrypt
gyp ERR! node -v v9.10.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/home/ltu/web3/package.json'
npm WARN web3 No description
npm WARN web3 No repository field.
npm WARN web3 No README data
npm WARN web3 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ltu/.npm/_logs/2018-04-20T10_50_03_804Z-debug.log

Any help please!!!


texts: Geth 1.4.12 not finding any peers on Ubuntu 16.04 LTS

texts:
I am trying Linux for the first time and try to run Geth 1.4.12 but it can not find any peers.

UPnP works fine, the clock sets itself correctly and the firewall is disabled.

Do you have any idea what should I do?

Thanks

I try to run geth --fast --verbosity 6. Here is the console log:

I0925 16:55:52.656800 p2p/server.go:556] Listening on [::]:30303
I0925 16:55:52.657545 p2p/server.go:430] new task: discovery lookup
I0925 16:55:52.657902 node/node.go:296] IPC endpoint opened: /home/d1v1d4v1d/.ethereum/geth.ipc
I0925 16:55:52.659738 release/release.go:116] Release oracle not found at fa7b9770ca4cb04296cac84f37736d4041251cdf
I0925 16:55:52.664050 p2p/discover/database.go:183] failed to retrieve node a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c: leveldb: not found
I0925 16:55:52.665334 p2p/discover/table.go:473] Bonding a979fb575495b8d6: known=false, fails=0 age=409670h55m52.665323259s
I0925 16:55:52.666259 p2p/discover/udp.go:453] >>> 52.16.188.185:30303 discover.ping
I0925 16:55:52.664050 p2p/discover/database.go:183] failed to retrieve node 979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9: leveldb: not found
I0925 16:55:52.666484 p2p/discover/table.go:473] Bonding 979b7fa28feeb35a: known=false, fails=0 age=409670h55m52.6664752s
I0925 16:55:52.667544 p2p/discover/udp.go:453] >>> 5.1.83.226:30303 discover.ping
I0925 16:55:52.664157 p2p/discover/database.go:183] failed to retrieve node de471bccee3d042261d52e9bff31458daecc406142b401d4cd848f677479f73104b9fdeb090af9583d3391b7f10cb2ba9e26865dd5fca4fcdc0fb1e3b723c786: leveldb: not found
I0925 16:55:52.667727 p2p/discover/table.go:473] Bonding de471bccee3d0422: known=false, fails=0 age=409670h55m52.66771807s
I0925 16:55:52.668256 p2p/discover/udp.go:453] >>> 54.94.239.50:30303 discover.ping
I0925 16:55:52.664195 p2p/discover/database.go:183] failed to retrieve node 1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082: leveldb: not found
I0925 16:55:52.668411 p2p/discover/table.go:473] Bonding 1118980bf48b0a36: known=false, fails=0 age=409670h55m52.668402743s
I0925 16:55:52.668917 p2p/discover/udp.go:453] >>> 52.74.57.123:30303 discover.ping
I0925 16:55:52.733620 p2p/nat/nat.go:111] mapped network port udp:30303 -> 30303 (ethereum discovery) using UPNP IGDv1-IP1
I0925 16:55:52.861670 p2p/nat/nat.go:111] mapped network port tcp:30303 -> 30303 (ethereum p2p) using UPNP IGDv1-IP1
I0925 16:55:53.169090 p2p/discover/table.go:389] no seed nodes found
I0925 16:55:53.169184 p2p/server.go:469] <-taskdone: discovery lookup


texts:
Let's say that I have made a function foo() in the js console on node A:
function foo() {return 42;}

I would now like to execute this from node B remotely. Is this possible?
I have tried to use web3.eth.call. However, this does not seem to work.


texts: Error deploying smart contract with web3.js and Truffle HD wallet provider

texts:
My web3 version is 1.0.0-beta.41,
node version is 10.15.1
solc compiler is 0.4.25

compile.js is successfully compiled with interface and bytecode exports.

My deploy.js file

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const { interface, bytecode } = require('./compile');

const provider = new HDWalletProvider(
     "punch hello latin float quality thank armor shoulder quick daring tone tell",
    "https://rinkeby.infura.io/v3/c4683f6aea9f4e65a690b46d028dcc94"
 )

const web3 = new Web3(provider);

When i do

 node deploy.js

I get this following error

          Error: Please provide an valid Web3 provider
        at ProviderResolver.resolve (/home/feynman/Programs/Ethereum/Ethmarket/node_modules/web3-providers/dist/web3-providers.cjs.js:720:13)
        at Web3.AbstractWeb3Module (/home/feynman/Programs/Ethereum/Ethmarket/node_modules/web3-core/dist/web3-core.cjs.js:27:51)
        at new Web3 (/home/feynman/Programs/Ethereum/Ethmarket/node_modules/web3/dist/web3.cjs.js:30:68)
        at Object.<anonymous> (/home/feynman/Programs/Ethereum/Ethmarket/deploy.js:11:14)
        at Module._compile (internal/modules/cjs/loader.js:689:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
        at Module.load (internal/modules/cjs/loader.js:599:32)
        at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
        at Function.Module._load (internal/modules/cjs/loader.js:530:3)
        at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
        at startup (internal/bootstrap/node.js:283:19)
        at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)


texts: How to program a website to accept Ethereum payments

texts:
Assume I have a site and I want to give unique address to each of my users that generated by an HD wallet.
If each user, send a little amount to his/her address,that it was less than transaction fee, unlike Bitcoin, I can't spend them, by generate a transaction with multi input, I think it's so bad.
On the other hand, each contract has only one address, so I can't have a contract with multi address to give each address to each user. What is the best solution in Ethereum world?


texts:
Imagine you wright your own token following the ERC721 standard. Now you want to create 10,000 tokens of this type.

Do you need one contract to manage each token?
Do you have to deploy 10,000 token contracts?
Can you manage all tokens with one single contract?

The use case I was thinking about was creating for example 10,000 baseball cards, each one different. Then let users to trade, buy and sell. So, for the creator of the tokens, how would this be managed? I believe that using a recursive function will cost a lot of gas...

Thanks a lot


texts: How to spend ERC20 tokens where ETH is required?

texts: As in the title. How do i spend erc20 tokens in the same way that i would ethereum? they are interchangeable right?


texts: I recently saw a smart contract where the user used keccak256(address), is there any reason to do this, instead of just storing the address in the mapping?


texts: difference between metamask and ethereum provider

texts:
I found this image online but I can't tell the difference between metamask and an Ethereum provider. Also doesn't metamask use a provider to connect to the network?
I'm confused


texts: Unable to fetch getBalance of eth address

texts:
I am unable to get the balance of an eth address using web3.eth.getBalance, it returns error like "no suitable peers available". I connected the eth mainnet in light node.
My source code:
web3.eth.getBalance(to_address, function (err, ethbalance) {
   var balance = ethbalance;
   if (err) {
      res.json({status: false,message: err.message});
   }
   else{
      res.json({status: true,message: balance});
   }
});

Please suggest me solutions to rectify this issue.


texts: JSON-RPC command to get blockchain synchronization status

texts:
Is there some json-rpc command, so that I can get the blockchain synchronization status from geth.

I am trying to connect to the --testnet using get. Its taking forever to connect to the testnet, are there some reliable nodes to which I can connect to ?


texts:
I have create a contract, deployed it and used. My contract has created 4 blocks as of now.  Now i want to change the signature of one of my function. so after doing so i need to re-deploy my contract.  After re-deploying my contract will start creating the blocks from number 0 again.  How do i make my new contract link to the previous block i have created and continue building on that chain.

For example, I have a contract with below function.

function createStudents(string fname, string year, string hash, uint256 _ipfsHash) public {
Student memory student = Student(fname, year, hash);
students.push(student);
studentInfo(fname, year, hash);
ipfsHash.push(_ipfsHash);

}

this function is pushing value in public variable Students. After deploying the above contract when i call the function the new value is getting pushed and my transaction data is stored in the block (i am using Ganache). So for example if i have called this function 3 times then each time i call, it will push the value in the variable and stores my transaction in the block.  Now after pushing values for 3 times, i want to change the year parameter from string to uint256 for some business reason. So after changing the signature of the function i re-deployed the code.  After re-deploy the contract address and ABI is changed so i updated my code. Now when i call the same function it is pushing the values in the same variable but i lost the transactions which i pushed before the re-deployment.  So i wanted to know is there any way i can have my old data and create new data on top of that. For example if pushed 2000, 2001, 2002, before re-deploying then i would like to have them and my new push should get on top of that.  Since the contract address itself has changed i am not sure if this is even possible.  But i am thinking about real time problem where will need to change the functions based on the business logic but then in this case how do you get your old data.

I am new in this technology stack.

thanks for your help.


texts: Is it possible to have nested proxy call in solidity?

texts:
I want have a design that allows me to change the implementation contract by only call upgradeTo() on 2nd layer proxy once. However, when I call real implementation function on 1st layer proxy, It prompt an error that the implementation is not exist.
How can do this kind of nested delegate call in solidity?


texts:
I'm not sure what each geth directories means, in particular dapp and nodes. I consider these as following. Could you tell me it is correct or not?

chaindata：blockchain data
dapp：?
history：history of commands that user typed
keystore：the storage of private keys for the ethereum client
nodekey：the private key of node
nodes:?


texts: Programmatically send ERC20 tokens to user wallet. How does transfer work?

texts:
I have been researching how to securely send and transfer ERC20 tokens from the contract address to a new user wallet. Tokens will be earned through participation on my platform. Based on results I would want to programmatically initiate the transfer of the tokens to the user wallets. For this I believe I need the private key of the contract address to be hosted within my application.

It seems as if this is a vulnerability on Eth, especially when some ICO’s are demonstrating thousands of pounds worth of value on the contract.

How do exchanges manage the buying and selling of your tokens for you? Do you have to provide them with the private key of the contract? It sounds insane to do this..

What’s the best and most secure approach to this?

Thanks in advance


texts: How can one start a ETH mining pool? [2021]

texts:
Most of the documentation on this topic seems to be very outdated. I'm looking to set up my own private pool, and I'd like to use stratum so I can use some rental rigs in addition to my own, but I can't seem to find any way to get geth to speak stratum.
Is there a correct way to set up my own pool?


texts: How to link token vesting with crowdsale?


texts: when we create ethereum HD wallet through a mnemonic phrase, we always need derivation path. is it fix for a particular currency or we can put whatever we like (ex- m/0/n, m/4/3/n or anything else)?


texts: Does successful mining require the block's transactions in advance?

texts:
Typically a miner decides which transactions go inside a block. But does this have to be so? Is the actual mining process just a process to find the right nonce regardless of block contents or does it depend on the included transactions? So: can included transactions be decided after a right nonce has been found?
I was trying to find an article which clearly explains this but obviously I failed.


texts:
What is the cheapest way to roundup() or ceil() to multiple of 1000?

For example if cheapest way to roundup is implemented in the ceil function:

function ceil(uint a, uint m) returns (uint) {
    //some cheap roundup to muliple function
}

then it is expected that:

ceil(123456,1000) == 124000
ceil(1,1000) == 1000
ceil(0,1000) == 0
ceil(123000,1000) == 123000


texts: Documentation For Token Smart Contracts with JSON RPC

texts:
This is the documentation for the Ethereum Json RPC:

https://github.com/ethereum/wiki/wiki/JSON-RPC

Pretty straight forward, but where is the documentation for dealing with tokens via this protocol?

In particular, I need to understand how the eth_call method works. I understand that I need to send some ABI, and get back some ABI. Here is the documentation for this:
https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI

What I need is a spec of all the messages I can send, and get back.


texts: (node:207476) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1):

texts:
Here is where error appears:

> Using network 'ropsten'.
>
> Running migration: 1_initial_migration.js
Deploying Migrations...
> ... 0x53526c506e2e43ee2be615375a11b8507a1e50ccc7a70e7ee5bd4fc745ec6f96
> Migrations: 0xe26a476c08385fccaf0aacb5b08126ef9d134965
Saving
> successful migration to network...   ...
> 0x72b8a0c6d09346ac205582041fbdc3a6853eab5523fd9c2de156ea0fc0cad1c5
> Saving artifacts... Running migration: 2_deploy_contracts.js Saving
> successful migration to network...
Deploying XYZCoinCrowdsale...
> ... 0x41d927717c89355dd0faa95cd6bf9421ff01c4c8c35c033d31f31e7d923b52e7
> ... 0x9c09d068e7d39de04d60546f167ba1c3b96544deba1e8c57389610e6106dcb2b
> Saving artifacts... (node:207476) UnhandledPromiseRejectionWarning:
> Unhandled promise rejection (rejection id: 1): Error: The contract
> code couldn't be stored, please check your gas amount.
>(node:207476)
> [DEP0018] DeprecationWarning: Unhandled promise rejections are
> deprecated. In the future, promise rejections that are not handled
> will terminate the Node.js process with a non-zero exit code.

Tried everything mentioned on various questions here, none of them worked.
I attempt to replica the guide here, https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 except on ropsten using hdwallet-provider.

I edited   xyzcoincrowdsale.sol(removed line // Crowdsale(_startTime, _endTime, _rate, _wallet) which was in the gustavocoincrowdsale.sol because it gave an error.)

pragma solidity ^0.4.13;

import './xyzcoin.sol';
import 'zeppelin-solidity/contracts/crowdsale/Crowdsale.sol';

contract XYZCoinCrowdsale is Crowdsale {

  function XYZCoinCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, address _wallet)
   // Crowdsale(_startTime, _endTime, _rate, _wallet)
    {
  }

  // creates the token to be sold.
  // override this method to have crowdsale of a specific MintableToken token.
  function createTokenContract() internal returns (MintableToken) {
    return new XYZCoin();
  }

}

My truffle.cfg looks like this:

require('dotenv').config();
const Web3 = require('web3');
const web3 = new Web3();
const Wallet = require('ethereumjs-wallet');

var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = "Infura API HERE";
var mnemonic = "12 words here";

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*", // Match any network id
      from: '0x00000000000000000000000000000000000'
    },
    ropsten: {
      //host: "localhost",
      //port: 8545,
      //nonce: 20,
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
      network_id: 3,
      gas: 472388,
      gasPrice: 100000000000
    }
  }
};


texts:
I've been trying to get BSC sycned up in a node that I can use.  I can't seem to get it to start syncing after downloading and extracting the chaindata from Binance, https://docs.binance.org/smart-chain/developer/snapshot.html  If I start it from scratch without the restore, it starts the sync.  WHat could I be doing wrong?  Here's the two logs, one from the terminal and the other from bsc.log.  It seems to get stuck at "Allocated cache and file handles"  I simply ran unzip chaindata.zip, allowing it to overwrite the existing files in chaindata.
Terminal
darthg8r@Node:/datadrive2/bscnode/bsc$ geth --config ./config.toml --datadir ./node --pprofaddr 0.0.0.0 --metrics --pprof --verbosity 6 --nousb --cache=8192                            INFO [04-18|06:47:58.072] Starting pprof server                    addr=http://0.0.0.0:6060/debug/pprof
INFO [04-18|06:47:58.072] Starting Geth on Ethereum mainnet...
WARN [04-18|06:47:58.072] Sanitizing cache to Go's GC limits       provided=8192 updated=5337
DEBUG[04-18|06:47:58.072] Sanitizing Go's GC trigger               percent=20
INFO [04-18|06:47:58.072] Enabling metrics collection
INFO [04-18|06:47:58.076] Maximum peer count                       ETH=30 LES=0 total=30
INFO [04-18|06:47:58.076] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
DEBUG[04-18|06:47:58.076] FS scan times                            list=24.4µs set=700ns diff=1.2µs
TRACE[04-18|06:47:58.076] Started watching keystore folder         path=/datadrive2/bscnode/bsc/node/keystore

bsc.log:
t=2021-04-18T06:50:30+0000 lvl=info msg="Starting peer-to-peer node" instance=Geth/v1.0.7-46d185b4-20210403/linux-amd64/go1.16.3
t=2021-04-18T06:50:30+0000 lvl=info msg="Allocated trie memory caches" clean="800.00 MiB" dirty="1.30 GiB"
t=2021-04-18T06:50:30+0000 lvl=info msg="Allocated cache and file handles" database=/datadrive2/bscnode/bsc/node/geth/chaindata cache="2.61 GiB" handles=524288


texts: Does it make a difference to index an event with one parameter?

texts:
Is there any difference between the two?

event NewEvent(address addr)
event NewEvent(address indexed addr)


texts: Creating a function that calls another contract

texts:
What is the minimum amount of information you need to know to call a contract from another contract?

In this re-entrancy tutorial we see the following source code to "attack" a contract.

pragma solidity ^0.4.8;

import './Victim.sol';

contract Attacker {
  Victim victim;

  function Attacker(address victimAddress) {
    victim = Victim(victimAddress);
  }

  function attack() {
    victim.withdraw();
  }

  // Fallback function which is called whenever Attacker receives ether
  function () payable {
    if (victim.balance >= msg.value) {
      victim.withdraw();
    }
  }
}

This Attacker contract is able to call the Victim contract with access to its source code. Is it possible to call another contract's functions if the ABI is known, but not the source code itself. Is that possible with Solidity and how?


texts: How do I add more gas to the ganache-cli

texts:
I started the ganache-cli with 'ganache-cli -l 800000000'

I deployed my contract with 'truffle --network development' which is defined in the truffle-config.js file as:

networks: {
    // Useful for testing. The `development` name is special - truffle uses it by default
    // if it's defined here and no other network is specified at the command line.
    // You should run a client (like ganache-cli, geth or parity) in a separate terminal
    // tab if you use this network and you must also set the `host`, `port` and `network_id`
    // options below to some value.
    //
    development: {
     host: "127.0.0.1",     // Localhost (default: none)
     //port: 8545,            // Standard Ethereum port (default: none)
     //gasPrice: 0x01,
     //gas: 470000000,
     port: 8545,            // Standard Ethereum port (default: none)
     network_id: "*",       // Any network (default: none)
    },

My contract runs out of gas on the very first contract call.  What do I need to do to fix this?

HD Wallet
==================
Mnemonic:      pond hockey few young elder pave lyrics bargain twenty broken coil group
Base HD Path:  m/44'/60'/0'/0/{account_index}

Gas Price
==================
20000000000

Gas Limit
==================
800000000

2_invoice_tracker.js
====================

   Deploying 'InvoiceTracker'
   --------------------------
   > transaction hash:    0xe1d189e01fcab83903598296e288895e578428332659fa6ef1e5f0da5ee181d4
   > Blocks: 0            Seconds: 0
   > contract address:    0x71f793b0cA149a8FC877522D6891FB3f9092D01f
   > block number:        3
   > block timestamp:     1591887444
   > account:             0x731a5d3CD32a531e5215CFAb7f0B9D413eFB9132
   > balance:             99.94790756
   > gas used:            2373870
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.0474774 ETH

   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:           0.0474774 ETH

Summary
=======
> Total deployments:   2
> Final cost:          0.05125242 ETH

This is the output from the ganache-cli:

   eth_sendTransaction

  Transaction: 0x72316a32488d09e25eb79c64fcd73dc96f95b9918a916ea29b0d30320375f8ff
  Contract created: 0xb22c9c54032f45fbd74b944bc67c1f42b6c1bd7e
  Gas usage: 188751
  Block Number: 1
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getCode
eth_getTransactionByHash
eth_getBlockByNumber
eth_getBalance
eth_getBlockByNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0x2d513c6a1d3b2e8a2ea25591dc4b0062ed3f348c33aad3db1ca43f4b90025dfc
  Gas usage: 42001
  Block Number: 2
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getBlockByNumber
eth_accounts
net_version
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getBlockByNumber
eth_estimateGas
net_version
eth_blockNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0xe1d189e01fcab83903598296e288895e578428332659fa6ef1e5f0da5ee181d4
  Contract created: 0x71f793b0ca149a8fc877522d6891fb3f9092d01f
  Gas usage: 2373870
  Block Number: 3
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_getCode
eth_getTransactionByHash
eth_getBlockByNumber
eth_getBalance
eth_getBlockByNumber
eth_getBlockByNumber
eth_sendTransaction

  Transaction: 0xc089b49e44fc5b0979efcdeae20f935ae4a3ca088274f656b1de4a8066267495
  Gas usage: 27001
  Block Number: 4
  Block Time: Thu Jun 11 2020 10:57:24 GMT-0400 (Eastern Daylight Time)

eth_getTransactionReceipt
eth_call
eth_gasPrice
eth_sendTransaction

  Transaction: 0x76937ebee405e4f6de6ca02aa209fa25579036b60e3ab9de73def64da5e11f49
  Gas usage: 90000
  Block Number: 5
  Block Time: Thu Jun 11 2020 10:58:45 GMT-0400 (Eastern Daylight Time)
  Runtime Error: out of gas


texts: Why does the init code of a contract change for Solidity > 0.4.5?

texts:
I have a simple empty contract:

contract test {
}

That I compile on Remix using different versions. I notice that the compiled output is getting more and more complex with later compiler versions:

0.4.4:  PUSH1 0x60 PUSH1 0x40 MSTORE PUSH1 0xC DUP1 PUSH1 0x10 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN PUSH1 0x60 PUSH1 0x40 MSTORE PUSH1 0x8 JUMP JUMPDEST PUSH1 0x2 JUMP
0.4.5:  PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE PUSH1 0x0 JUMPI JUMPDEST PUSH1 0x9 DUP1 PUSH1 0x15 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN PUSH1 0x60 PUSH1 0x40 MSTORE JUMPDEST PUSH1 0x0 JUMP
0.4.9:  PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE ISZERO PUSH1 0xB JUMPI INVALID JUMPDEST JUMPDEST PUSH1 0x33 DUP1 PUSH1 0x19 PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x60 PUSH1 0x40 MSTORE JUMPDEST INVALID STOP LOG1 PUSH6 0x627A7A723058 SHA3 0xbb DELEGATECALL AND SWAP3 PUSH31 0x9A9ED68B77570A6681F22466F197FC4F1257401228E4A4722BDE9A00290000
0.4.12: PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE ISZERO PUSH1 0xE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST JUMPDEST PUSH1 0x36 DUP1 PUSH1 0x1C PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x60 PUSH1 0x40 MSTORE JUMPDEST PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 0xed SWAP6 0x4f CALLDATASIZE 0xc2 0xee 0xd1 PUSH17 0xCCD896EFE39A5BCBD2F6A71C61439DD674 0xad MSTORE8 SWAP3 0x26 PUSH8 0x6C8D002900000000
0.4.13: PUSH1 0x60 PUSH1 0x40 MSTORE CALLVALUE ISZERO PUSH1 0xE JUMPI PUSH1 0x0 DUP1 REVERT JUMPDEST JUMPDEST PUSH1 0x36 DUP1 PUSH1 0x1C PUSH1 0x0 CODECOPY PUSH1 0x0 RETURN STOP PUSH1 0x60 PUSH1 0x40 MSTORE JUMPDEST PUSH1 0x0 DUP1 REVERT STOP LOG1 PUSH6 0x627A7A723058 KECCAK256 PUSH21 0x1D73368737655E9A09C3993DB87B5BCD07A9C28FC7 0xe3 JUMPI LT 0xdf 0xae SWAP9 PUSH23 0xF56780029000000000000000000000000000000000000

Only looking at the init code (everything that precedes the second PUSH1 0x60 PUSH1 0x40 MSTORE) I see an increase in complexity. This seems important as everyone is paying gas for this and I would like to understand why this is necessary.

EDIT:
I assume that the section CALLVALUE ISZERO PUSH1 0xE JUMPI is a conditional jump to the first JUMPDEST at 0xE if no Ether have been sent along, otherwise we run into a REVERT which seems to require two 0x0 (?) on the stack. But then it gets weird with the two JUMPDEST that follow each other and a lot of things that are getting pushed onto the stack around the CODECOPY.


texts: How do I connect the geth console to an INFURA endpoint?

texts:
Rather than have a local node on my PC, I'd like to be able to attach the geth cli console to INFURA and then issue requests within geth's java console, e.g. web3.eth.getBalance(<address>)

I signed up for INFURA and received an email with some endpoints to use, but I am unclear what specific commands I should use so that my geth console attaches to one of those endpoints.

Thanks


texts:
I'm new to the whole crypto currency chain.
I have a question that keeps bugging me and can't seem to find an answer to
My question is Do you need to create your own Contract Source/Smart Contract Code to be able to execute another one that is already on the blockChain?
For example
0x3301ee63fb29f863f2333bd4466acb46cd8323e6
If I wanted to transfer the tokens from the above contract what would I need to do to complete the transfer?
Also with Below ScreenShot
What fields need to be filled out?
Thank you


texts: ERC-20 Token Transfer Error : Bad jump destination

texts:
I'am trying to send ERC20 from 1 address to another but i'am getting that error :

  Blockquote
  Contract 0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a
   Warning! Error encountered during contract execution [Bad jump destination]
    ERC-20 Token Transfer Error (Unable to locate Corresponding Transfer Event Logs), Check with Sender.
  Blockquote

Here my code, can you help me to find the issue please ?

  var address = req.body.address;

  var contractAddress = "0x557e4cca38277b9bf9f1f1bf333dfe4b0ac5541a"
  var fromAddress = myaddress
  var privateKey = privatekey
  var toAddress = req.body.address
  var transferAmount = 1;

// Create an async function so I can use the "await" keyword to wait for things to finish
const main = async () => {
  // This code was written and tested using web3 version 1.0.0-beta.26
  console.log(`web3 version: ${web3.version}`)

  // Determine the nonce
  var count = await web3.eth.getTransactionCount(fromAddress);
  console.log(`num transactions so far: ${count}`);

  // This file is just JSON stolen from the contract page on etherscan.io under "Contract ABI"
  var abiArray = JSON.parse(fs.readFileSync(path.resolve(__dirname, './tt3.json'), 'utf-8'));
  // This is the address of the contract which created the ERC20 token
  var contract = new web3.eth.Contract(abiArray, contractAddress, { from: fromAddress });
  //var contract = new web3.eth.Contract(abiArray, contractAddress, { from: myAddress });

  // How many tokens do I have before sending?
  var balance = await contract.methods.balanceOf(fromAddress).call();
  console.log(`Balance before send: ${balance}`);
  // I chose gas price and gas limit based on what ethereum wallet was recommending for a similar transaction. You may need to change the gas price!
  var rawTransaction = {
      "from": fromAddress,
      "nonce": "0x" + count.toString(16),
      "gasPrice": 2000000000,
      "gasLimit": 300000,
      "to": contractAddress,
      "value": transferAmount,
      "data": contract.methods.transfer(toAddress, transferAmount).encodeABI(),
      "chainId": web3.eth.net.getId()
  };

  // Example private key (do not use): 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109'
  // The private key must be for myAddress
  var privKey = new Buffer(privateKey, 'hex');
  var tx = new Tx(rawTransaction);
  tx.sign(privKey);
  var serializedTx = tx.serialize();

  // Comment out these three lines if you don't really want to send the TX right now
 console.log(`Attempting to send signed tx:  ${serializedTx.toString('hex')}`);
  var receipt = await web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'));
  console.log(`Receipt info:  ${JSON.stringify(receipt, null, '\t')}`);

  // The balance may not be updated yet, but let's check
  balance = await contract.methods.balanceOf(fromAddress).call();
  console.log(`Balance after send: ${balance}`);
}

main();


texts:
My question is: Should I use uint40 for time in Solidity?

All the examples I've seen use uint256 for time, however, I think it's too wasteful -- while using uint32 is maybe a little aggressive due to its 86-year-till-overflow, the 34K-year-till-overflow from uint40 seems pretty safe to me.

Could there be any potential downfall from using uint40 that I'm not aware of?

Edit:

Sorry for not making myself clear enough earlier. Consider the following struct --

struct User {
    address user;   // 20 bytes
    uint40 userRegisterTime;    // 5 bytes
    uint40 userDepositTime;     // 5 bytes
    uint256 userBalanceWei;     // 32 bytes
}

Had the two time vars been defined as uint256, the struct would need 4 * 32-byte, while in the case of uint40, the first three vars can be packed into one 32-byte, saving 2 * 32-byte (reference, which I have verified -- https://medium.com/@novablitz/storing-structs-is-costing-you-gas-774da988895e )

Everybody agrees?


texts: Smart Contract execution time through Truffle

texts:
I would like to know if there is a way to obtain the smart contract execution time when you send it to the network through Truffle. Is it possible using the test tool? through an application? I know how to obtain the tx time with web3, but in my case, you need to deploy first an smart contract to the network.

A good example is pet-shop-tutorial. First, truffle deploys the smart contract to the network and then it is possible to obtain different values interacting with the contract using web3. I would like to know how to obtain the time of the first smart contract when is deployed.


texts:
This is the LSP3Account contract: https://github.com/lukso-network/standards-implementations/blob/master/contracts/Accounts/LSP3Account.sol
I want to create a contract on Remix that inherits from it. I tried this:
pragma solidity ^0.6.0;

import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/Accounts/LSP3Account.sol";

contract MyProfile is LSP3Account(msg.sender) {

}

But this results in: not found @openzeppelin/contracts/introspection/ERC165.sol
So I copied and pasted the entire LSP3Account.sol contract in Remix, to try to fix the imports manually.
I figured once these imports were fixed, I would finally be able to inherit from the LSP3Account contract.
However, when I fixed the ERC165.sol import, another import error showed up (UniversalReceiverDelegate.sol).
Once I fixed that, another import error showed up (UniversalReceiver.sol). I fixed that too.
But my imports started getting out of hand. Here's the top of my file. I used OLD and NEW to mark the fixed imports:
pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;

// interfaces
//import "../_LSPs/ILSP1_UniversalReceiver.sol"; OLD 3
import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/_LSPs/ILSP1_UniversalReceiver.sol"; // NEW 3
//import "../_LSPs/ILSP1_UniversalReceiverDelegate.sol"; OLD 2
import "https://github.com/lukso-network/standards-implementations/blob/master/contracts/_LSPs/ILSP1_UniversalReceiverDelegate.sol"; // NEW 2

// modules
import "erc725/contracts/ERC725/ERC725Account.sol";
//import "@openzeppelin/contracts/introspection/ERC165.sol"; OLD 1
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/docs-v3.x/contracts/introspection/ERC165.sol"; // NEW 1

contract LSP3Account is ERC165, ERC725Account, ILSP1 {

But guess what, now I get the error: not found @openzeppelin/contracts/cryptography/ECDSA.sol
This new import error isn't even from the LSP3Account contract. It's from one of the contracts it inherits from.
The only solution I see, would be to copy and paste the entire inheritance tree, and fix the imports from the bottom-up. But this seems ridiculously complicated.
I also know I can clone the project locally, run npm install, and all the dependencies will be installed. But:

I ran into problems because the dependencies have different compiler
versions.
It's much easier to deploy from Remix, rather than deploy from local files.

So a couple of questions:
1. Can I cancel imports from contracts my contract is inheriting from?
2. More importantly, isn't there a way to simplify these
inheritance and import problems on the Remix IDE?


texts: How to get constants value by using Contract name

texts:
for example:

contract A {
    uint constant public START_TIME = 10;
}

import "./A.sol"

contract B {
    function test() public {
        uint startTime = A.START_TIME;
    }
}

If I only need the value of constants, I do not need the actual instance, right?


texts: How to know address belongs to current Ledger, way to get path ? (By using Ledger inside browser - JavaScript)

texts:
Ledger can generate many wallet addresses,

Is there way how to find out that given public key address belongs to currently connected Ledger device ? (Using JavaScript API in web application)

And closely coupled question is also if there is way to get ledger path of given address eg. m/44'/60'/0'/166?


texts: miner.stop() returns null does not stop mining on private chain

texts:
I am using Version: 1.9.0-unstable of geth, and I noticed miner.stop() does not work anymore. I am sure it always worked.

> eth.blockNumber
901069
> miner.stop()
null
> eth.blockNumber
901130

miner.start() returned null but miner.stop() always returned true, but it is returning null. I am running private net. Any ideas?


texts: how can I run a truffle test in a debugger?

texts:
as a developer I want to run my javascript test in a debugger so as to be able to step through tests and inspect the values of variables.

The goal is to run it in a Mocha debug mode


texts: Swap tokens back to ether on Uniswap V2 Router 02 (Sell tokens)

texts:
I am trying to do the reverse action of what I did in this question:
Basically sell/swap some arbitrary token and receive ether on Uniswap V2 using IUniswapV2Router02.
Here is what I have done:
 contract SellTokens{

       IUniswapV2Router02 usi = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);

    function sellDai(uint256 daiQty , address cryptoToken) public payable returns(uint256){

//address cryptoToken = 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa;//0x00D811B7d33cECCFcb7435F14cCC274a31CE7F5d//multiDaiKovan;

    uint256 ethAmountDerivable = getEstimatedTokenForETH(daiQty , cryptoToken)[0];

  uint deadline = now + 300; // using 'now' for convenience, for mainnet pass deadline from frontend!

    usi.swapExactTokensForETH(daiQty , ethAmountDerivable, getPathForTokenToETH(cryptoToken), address(this), deadline);

   return ethAmountDerivable;

}

    function getEstimatedTokenForETH(uint daiQty , address crypto) public view returns (uint[] memory) {
        return usi.getAmountsIn(daiQty, getPathForTokenToETH(crypto));
      }

     function getPathForTokenToETH(address crypto) private view returns (address[] memory) {
        address[] memory path = new address[](2);
        path[0] = crypto;
        path[1] = usi.WETH();

        return path;
      }

    }

When I call sellDai from truffle console using:
c.sellDai(web3.utils.toWei('0.02'),'0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa',{value: 3000000000000000})

I get the following output
The status says:
Fail with error 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
What could be the issue, please?
EDIT
I changed the getAmountsIn function call to getAmountsOut, and the error changed from INSUFFICIENT_OUTPUT_AMOUNT to TransferHelper: TRANSFER_FROM_FAILED.
EDIT 2
After the admonition to approve the token before transfer, I did this:
function sellDai(uint256 daiQty , address cryptoToken) public payable returns(uint256){

//address cryptoToken = 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa;//0x00D811B7d33cECCFcb7435F14cCC274a31CE7F5d//multiDaiKovan;

  uint256 ethAmountDerivable = getEstimatedTokenForETH(daiQty , cryptoToken)[0];
  ethAmountDerivable = ethAmountDerivable.mul(10).div(11);// divide by 1.1

  uint deadline = now + 300; // using 'now' for convenience, for mainnet pass deadline from frontend!

  IERC20 dai = IERC20(cryptoToken);
  dai.approve(address(this), 0);
  dai.approve(address(this), daiQty);

    usi.swapExactTokensForETH(daiQty , ethAmountDerivable, getPathForTokenToETH(cryptoToken), address(this), deadline);

   return ethAmountDerivable;

}

But it still didnt work. Any ideas please. Here is the transaction
Thanks again


texts:
Is there any way I can use a local parameter within multiple functions?
The idea is to save gas when calling functions. A parameter wouldn't have to be copied and be returned every time.

Here's some pseudo code:

function A(uint[] array) public pure returns (uint[]) {
    B(*array);  // send a memory pointer?
    return array;
}

// B directly manipulates the array via the pointer => see no return value
function B(uint[] *array) internal pure {
    // something
}


texts: EVM is sandboxed program execution environment

texts:
I read following content about EVM:

  It is vital to also note that EVM operates in a sandboxed environment- it is totally isolated from the main Blockchain network, and works perfectly as a testing environment. Therefore anybody who would want to create a smart contract using EVM can do so without interfering with other Blockchain operations.

Sorry I can't understand this. I think that we have developers which create Smart Contracts (SC) and we don’t do the development process in  EVM and EVM is basically used for the execution of SC. I can't understand what type of testing is mentioned above. For testing of SC we have several tools (like Oyente, Remix and so on) which are not part of EVM.

Somebody please guide me.

Zulfi.


texts:
I've deployed my contract with a UI to Ropsten via truffle and ran npm run build and npm run dev to start the server. As soon as I launch localhost (with the account in MetaMask selected) in the browser, I get the following error in the browser console.

GET http://localhost:8080/app.js net::ERR_CONTENT_LENGTH_MISMATCH

The static content shows up, but my dApp can't show the balance in the account and perform functions.

It's happened in the past, but it would go away after a few refreshes. Now it's happening every time and I can't get my dApp to run as expected. Everything was tested and worked with testrpc. Could this be a chrome extension interfering? I tried commenting out all my HTML code and still
got the same error.


texts: Networking - p2p connections through router

texts:
This isn't unique to Ethereum per se, but I'm curious how p2p clients (e.g. geth) allow peers to receive messages from the outside world with default router configurations. I have tried running the tests in this NAT port mapping module, but I believe they are failing because my router is not configured for port mapping.

So if routers don't allow port mapping by default, how do peers exchange data? Would a peer connect to a bootstrap node, who would read that peer's externally facing IP/port and then send a message with that information?

Where is this process captured in an Ethereum client? I would prefer if you could show it in a python or javascript client/library (since I can read those more easily), but geth is okay too.


texts:
How To Transfer Token From MultiSigWallet To Another Account

I have token for multisigwallet in another contract like common token contract.So,How Can I transfer those token to another address or account.


texts: How to read uniswap TX input to find out what swap was made?

texts:
Look at this tx : https://etherscan.io/tx/0x9854f2249f86802cb0edcff0aa6747de6c49d89b0ba0dc2038b00372b949356b
it says 0.3RTH send to uniswap and 6,447.815435380239985848 L3P got from uniswap.
However at the end when you lookd at the input data there is only
#   Name    Type    Data
0   amountOutMin    uint256 6383975678594297015691
1   path    address[]   0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
0xdeF1da03061DDd2A5Ef6c59220C135dec623116d
2   to  address 0x71749AF1e6A25DdF6F5C9711eA46FcBEbfd1FB75
3   deadline    uint256 1616231233

How did it found out (etherscan) that 0.3 eth were swapped for 6,447.815435380239985848 L3P?
Thanks


texts: What is the corresponding web3 type to solidity bytes when using Typescript?

texts:
I want to call a solidity function a passing a parameter bytes b.

function xyz(address a, bytes hexData)

We front end code in Typescript is like that

if (hexData) {

    let hexDataInBytes = Web3Utils.hexToBytes(hexData);
    console.log("hexDataInBytes ");
    console.log(hexDataInBytes);

    this.getAccounts().then(accounts => {
            let selectedAccount = accounts[0];
            let contract =  this.createContract(addr);

            contract.instance.methods.xyz(toAddress, hexDataInBytes)
            .send ({ from:selectedAccount, gas:500000 })
            .then (result => fSucess(result))
            .catch (error => fError(error));
        });

}

Passing hexData = 0x0123, I got hexDataInBytes = [1,35].
However, I got the error

RROR Error: Uncaught (in promise): Error: Given parameter is not bytes: "1,35"
Error: Given parameter is not bytes: "1,35"
    at SolidityTypeDynamicBytes.formatInputDynamicBytes [as _inputFormatter] (formatters.js:83)
    at SolidityTypeDynamicBytes.SolidityType.encode (type.js:188)
    at eval (index.js:255)

So, what is the correct way to call this function xyz?

Thank you!


texts:
I am trying to create an ERC20 token using the following workflow.

Create a new token, let's say 'XYZ' with an initial total supply of 1000 coins.
List them on exchanges and also create coin's own wallet for purchasing the coins.
When initial supply of 1000 coins is exhausted and a user tries to purchase more coins, let's say 150 coins, then my smart contract mints new tokens (150) on the fly and credits to user's wallet on successful payment. And the cycle continues. Obviously, the total supply will keep increasing accordingly.

In OpenZeppelin smart contracts, there are methods for minting and burning tokens but can they be used without any issues?

More importantly, I need to understand if there are any kind of flaws with the workflow mentioned above. Could be technical, financial or otherwise.


texts:
According to solidity docs,

pragma solidity ^0.4.0;

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

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

contract Base1 is mortal {
    function kill() public { /* do cleanup 1 */ mortal.kill(); }
}

contract Base2 is mortal {
    function kill() public { /* do cleanup 2 */ mortal.kill(); }
}

contract Final is Base1, Base2 {
}

    A call to Final.kill() will call Base2.kill as the most derived override, but this function will bypass Base1.kill, basically because it does not even know about Base1. The way around this is to use super:

My question is, Final.kill() will call Base2.kill because Final inherits Base2 next to Base1? In other words, Base2 comes after Base1?

If my understanding is correct, always the rightmost inherited contract is the most derived one?


texts: How to check for a mapping key that returns empty?

texts:
I want to check if I have stored a value for a specific key inside a mapping. I understand that "all keys exists" therefore I can't iterate the keys, but how can I know if there is a value attached to that key?
(I checked some answers, but everyone's solutions is to use a struct, although I could do that in the example bellow, there must be a way to do this without the struct. Otherwise it seems, to me, that the uses of mapping are very limited)
contract example {
    mapping (address => string) myMap;

    function someFunc() public {
        if (myMap[msg.sender] == ??????) {
        }
    }

}

I've tried myMap[msg.sender] == "", 0, '', string,
EDIT: I know I'm supposed to only ask a single question, but it's related to mapping and it seems silly to open a new question for this: Is there a way to initialize the mapping with some values already? Just as example, in python I would do something like this:
mapping_var = {
  'key': 'value',
  'another_key': 'another_value',
}


texts: Why ethereum dons't store transaction signature?

texts:
Ethereum doesn't store transaction signature (r,s,v) in its tries. The first answer in that it is state-based, not UTXO based: Retrieve the signature of a transaction on the blockchain

But there is no way to re-validate a transaction after it get mined. Is it good approach?


texts: return (bytes32,bytes32) , returns actual transaction address instead of the real data

texts:
I have attached my contract, which works fine on populus and compiles on geth. It is a simple source code: Test() function appends data into my linkedlist that is defined in my library. And get() function's goal is to retrieve the head nodes' data in byte32 format.

My goal is to pull head node's data(bytes32). Inside my contract I have this following functions Test() and get().

On populus; when I called Link Contract's get() function, I can see the value that is stored in Struct's data which is bytes32 type.

my_contract.transact().Test();
contract_address = unmigrated_chain.wait.for_receipt(set_txn_hash)
output = my_contract.call().get();
print(output[0] + output[1]);
abc111 //this is my output result. String that is stored in head node
       //printed correctly.

On the other hand, on geth (by using my private Ethereum Blockchain), when I call get() function, instead of returning (bytes32,bytes32) value it returns its transaction address value.

ret_value = link.get({from: eth.accounts[0]})
"0xb508d62ce8c32d792cccf41f04f607d93c672e3a7e53e3e9fedb433ecc1f7a83"

[Q] On geth how could I get the nodes' data (like on populus as "abc111") value since on geth when I call get() function it returns transaction's address value instead of (bytes32, bytes32).

Note: Returning string might be a solution so also in library if I change data's type from "bytes32" with "string" type, I have faced with following error: Error: Return argument type inaccessible dynamic type is not implicitly convertible to expected type (type of first return variable) string memory.

Thank you for your valuable help and time.

The example code as follows from this original implementation (https://github.com/ethereum/dapp-bin/blob/master/library/linkedList.sol):

library LinkedList {
      struct data {
        uint80 head;
        uint80 last;
        uint80 count;
        Item[] items;
      }
      uint80 constant None = uint80(0);
      struct Item {
        uint80 prev;
        uint80 next;
        bytes32 data;
        bytes32 data2;
      }

  /// Appends `_data` to the end of the list self. Pushes the _data.
  function append(data storage self, bytes32 _data, bytes32 _data2) {
    var index = uint80(self.items.push(Item({prev: self.last, next: None, data: _data, data2: _data2})));
    if (self.last == None)
      {
    if (self.head != None || self.count != 0) throw;
    self.head = self.last = index;
    self.count = 1;
      }
    else
      {
    self.items[self.last - 1].next = index;
    self.last = index;
    self.count++;
      }
  }

  function get_head_data(data storage self) returns (bytes32,bytes32) {
    var it = iterate_start(self);
    return (iterate_get(self, it));
  }

  function get_head_iterate(data storage self) returns (uint80) {
    var it = iterate_start(self);
    return it;
  }

  // Interface of Iterator
  function iterate_start(data storage self) returns (uint80) { return self.head; }
  function iterate_next(data storage self, uint80 _index) returns (uint80) { return self.items[_index - 1].next; }
  function iterate_get(data storage self, uint80 _index) returns (bytes32, bytes32) {
    return (self.items[_index - 1].data, self.items[_index - 1].data2); }
}

contract Link {
  using LinkedList for LinkedList.data;
  LinkedList.data public list;
  function Test() {
    list.append("abc","111");
    list.append("def", "222");
    list.append("ghf", "333");
  }

  function get() returns (bytes32, bytes32) {
    return (list.get_head_data());
  }
}


texts: How to add ICONS to our tokens on test network?

texts:
I have seen several questions about adding icons to the existing Tokens in main net. But is it possible to add icons and other information to tokens on test network  ??

((just for testing purpose))


texts: Is there a way to extract ABI from a deployed contract?

texts: I am building a web UI for testing smart contracts and currently I have to supply the ABI for a contract I test. Is there a way to extract the ABI from a deployed contract (preferably programmatically)?


texts: "The contract code couldn't be stored, please check your gas amount." while deploying a simple Faucet contract

texts:
I'm trying to deploy the following simple contract to a private Ethereum chain using Geth 1.5.4-stable-b70acf3c:

pragma solidity ^0.4.0;

contract Faucet {
    address owner;
    uint256 sendAmount;

    function Faucet() {
        owner = msg.sender;
        sendAmount = 1000000000000000000;
    }

    function getBalance() returns (uint) {
        return this.balance;
    }

    function getWei() returns (bool) {
        return msg.sender.send(sendAmount);
    }

    function sendWei(address toWhom) returns (bool) {
        return toWhom.send(sendAmount);
    }

    function getSendAmount() returns (uint256) {
        return sendAmount;
    }

    function killMe() returns (bool) {
        if (msg.sender == owner) {
            suicide(owner);
            return true;
        }
    }

    function () payable {}
}

Here are the commands I run in Geth console to deploy the contract:

> var faucetSource = "pragma solidity ^0.4.0; contract Faucet { address owner; uint256 sendAmount; function Faucet() { owner = msg.sender; sendAmount = 1000000000000000000; } function getBalance() returns (uint) { return this.balance; } function getWei() returns (bool) { return msg.sender.send(sendAmount); } function sendWei(address toWhom) returns (bool) { return toWhom.send(sendAmount); } function getSendAmount() returns (uint256) { return sendAmount; } function killMe() returns (bool) { if (msg.sender == owner) { suicide(owner); return true; } } function () payable {} }"

> var faucetCompiled = eth.compile.solidity(faucetSource)

> var faucetContract = eth.contract(faucetCompiled.Faucet.info.abiDefinition);

> var faucetInstanceTransaction = faucetContract.new({from:eth.coinbase, data:faucetCompiled.Faucet.code, value:1000000000000000000, gas:1000000}, function(err, contract){if(err){console.error(err);}else{console.log(contract.address);}});

And here is what I'm getting:

undefined
undefined
> Error: The contract code couldn't be stored, please check your gas amount.

I double checked and eth.coinbase is unlocked, and it has ether:

> web3.fromWei(eth.getBalance(eth.coinbase), 'ether');
8279.53125

Any idea of what's going wrong and how to troubleshoot that kind of issue?


texts: contract does not gets deploy to rinkeby via Infura

texts:
I am trying to deploy my contract to Rinkeby network via Infura. But it actually does not get deploy to network when i run node deploy.js terminal does not spit out the address at which it is deployed. On screen i see it stuck. Please have a look at below screenshot. almost i kept it for a hour, but still same state.

Upon disconnecting the internet i get the below error, from this i can assume something was going on. there is no feedback system which shows the progress.

is there any way to know what is going wrong?

below is my deploy.js code

const HDWalletProvider = require('truffle-hdwallet-provider');
const Web3 = require('web3');
const compiledFactory = require('./build/CampaignFactory.json');

const provider = new HDWalletProvider(
    secret_key,
    'https://rinkeby.infura.io/v3/<infura_key>'

);

const web3 = new Web3(provider);

const deploy = async () => {
    const accounts = await web3.eth.getAccounts();
    console.log('Deploying from account', accounts[0]);
    //console.log('Bytecode is 0x'+compiledFactory.bytecode);
    const result = await new web3.eth.Contract(JSON.parse(compiledFactory.interface))
        //.deploy({ data : '0x' + bytecode})
        .deploy({ data : '0x' + compiledFactory.bytecode})
        .send({gas : '1000000', from : accounts[0]});
   // console.log(interface);
   console.log('Contract deployed to ', result.options.address);
};

deploy();


texts: Geth syncing for 24 hours, still not done

texts: I downloaded Geth 1.6.6 and ran it to sync the blockchain. It's been 24 hours, the chaindata folder is 12.4gb and it's still going. When should I expect it to be done? Is this normal (the website that I reading from said it would take "from 20 minutes to several hours") or have I done something wrong? I used the command geth --rpc --fast --cache=1024, if that helps. Fairly new to this, so not 100% sure what's happening.


texts:
I'm using Windows OS and is my private computer.

Norton Internet Security says :

  Firewall rules were automatically created for geth and Intrusion
  Prevention is monitoring network traffic.

Can someone tell me whether Geth is safe to install especially on a private computer.?


texts: How to enforce that 1 copy of an NFT has a unique meta data that no other copies of that NFT can also have?

texts:
If I wanted to create an NFT that contains the Username of a person to prove their address ownership, what is the best practices or suggested ways to enforce that no 2 copies of that NFT can have the exact same Username meta data?
Example meta data:     "name": "bob"
Only 1 NFT instance could ever have the name "bob". If another was attempted to be created, it should fail to be created due to "bob" already exists as a name in an existing NFT.
Is there a particular NFT standard this should follow such as 721 or 1155?
Or is this something that can only be controlled centrally by the code that is allowed to mint new NFTs? If centrally only, is there is a best practices way to look up all existing NFT data?


texts: How to transfer Ether to ERC20 token contract?

texts:
I have a function that needs to make transfers to a token smart contract as well as personal accounts upon satisfaction of some conditions.

function completeSale() onlyOwner public {
        if (something == true && balance >= requested) {
            tokenContract.transfer(requested/100);
            seller.transfer(requested - (requested/100));
            buyer.transfer(balance - requested);
            assert(address(this).balance == 0);
            complete = true;
        }
    }

However, looking at the ERC20 standard, transfer is implemented as a token method:

 function transfer(address to, uint tokens) public returns (bool success) {
         balances[msg.sender] = balances[msg.sender].sub(tokens);
         balances[to] = balances[to].add(tokens);
         emit Transfer(msg.sender, to, tokens);
         return true;    }

How does one then transfer value in ether to an ERC20 smart contract? Is this possible without writing another function that then requires a low level call (i.e. tokenAddress.myPayMethod.value(x) or tokenAddress.call.value(x)())?


texts: How to call an overloaded function in Truffle with ABIEncoderV2?

texts:
How do you call an overloaded function in Truffle when passing a struct using pragma experimental ABIEncoderV2;?

contract MyContract {

  struct MyStruct {
      address param1;
      address param2;
      address param3;
  }

  function init(address owner) public {}

  function init(MyStruct memory myStruct) public {}
}

Calling MyContract.init(myStruct) tries to call the first init function.


texts: Is it possible to make a call to contract function with varying arguments or an array List?

texts:
In C++11 we have Variadic functions that we can call with varying number of arguments. https://stackoverflow.com/a/1657930/2402577

  void myfunc( int i = 0, int j = 1, int k = 2 );

// other code...

myfunc();
myfunc( 2 );
myfunc( 2, 1 );
myfunc( 2, 1, 0 );

I have point out that it is not possible, instead could we just sent an array list into the function, and embedded arguments into the list:

function foo(uint hello[]){
     uint x = hello[hello.len];
     return x + 1;
}

[Q] Is it possible to make something similar inside Solidity with an array-list[] as an argument to the function?


texts: Ethereum light client and verifying proofs in Go programming language

texts:
I am looking to write or integrate a toy Ethereum light client in Go-based applications to see how easily other (Tendermind / Cosmos) based blockchains could verify proofs from Ethereum main chain. This is not on-chain light client, similar to one in NEAR Rainbow Bridge, but just having a module running within a full node that can also verify proofs against Ethereum network.
What would be a good place to start looking for this?
I found a very easy to read implementation for verifying proofs in JavaScript: https://github.com/zmitton/eth-proof - but this still leaves the question of downloading Ethereum block headers as a light client.


texts: How to call function with two different signatures/parameters?

texts:
In my contract I have two functions with the same name, but with different number of parameters, like so:

function computeVote(uint sku, uint sellerId, uint8 _rating) public {...}

and

function computeVote(uint sku, uint sellerId, uint8 _productRating, uint8 _sellerRating) public {...}

So far so good.

But in my tests, if I call the first function like this:

await contract.computeVote(1, 1, 1, {from: this.accounts[1]});

I get an error saying Error: Invalid number of arguments to Solidity function.

If I comment out the second function, it works.


texts: Access to smart contract's value in Node-js

texts:
I am working on a simple Truffle project that just shows "Yerevan is love". My contract code:

pragma solidity ^0.5.12;
contract TEST{
   bytes note="Yerevan is love";
   function fname() public view returns(string memory){
      return string(note);
   }
}

And by app.js i could create a communication between the contract and JavaScript but i don't know what is an appropriate code to show "Yerevan is love" in Node-js .My app.js code:

var Web3=require("web3");
var web3= new Web3('ws://localhost:8545');
var fs=require('fs') ;
var jsonFile="C:/Users/lenovo/node_modules/Yerevan/build/contracts/TEST.json";
var parsed=JSON.parse(fs.readFileSync(jsonFile));
var abi=parsed.abi;
var myContract= new
    web3.eth.Contract(abi,"0xEC3B8e1607C92D5695dE5FaCdE3db76EBff7f5eA" );

This app.js has not a code to show "Yerevan is love" because i don't know that. Please provide the appropriate code and a guide for a beginner man.


texts:
I want to exec a script in the truffle console.
script
const artifacts = require('./build/contracts/Message.json')

const contract = require('truffle-contract')
const Message = contract(artifacts);
Message.setProvider(web3.currentProvider);

module.exports = ()=> {
  creator = web3.eth.accounts[0];
  purchaser = web3.eth.accounts[1];
  web3.personal.unlockAccount(creator);
  var messageInstance = null;
  Message.deployed().then(inst => { return messageInstance = inst}).then( () =>{ console.log("Creating Message"); return messageInstance.createMessage(creator, "message.newMessage") }).catch((error)=> { console.error("error", error) }).then( ()=> { return console.log("End");} )
}

Manually
When I manually insert the script (just the part inside module.exports), line by line it works and I get the last console.log.
With exec
When I run exec ./run.js: the script gets stuck at the second Promise without any error.


texts: Geth - reading public address[] from contract

texts:
After setting up testrpc and attaching geth:

testrpc -a 10
geth attach rpc:http://localhost:8545

I initialise the following contract on the geth command line:

pragma solidity ^0.4.6;
contract AddressList {
    event addressregistered(address addy);

    uint public NoMembers;
    address[] public MemberAddresses;

    function registerAddress() {
        MemberAddresses.push(msg.sender);
        NoMembers = MemberAddresses.length;
        addressregistered(msg.sender);
        }
}

var addresslistContract = web3.eth.contract([{"constant":false,"inputs":[],"name":"registerAddress","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"NoMembers","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"MemberAddresses","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"addy","type":"address"}],"name":"addressregistered","type":"event"}]);
var addresslist = addresslistContract.new(
   {
     from: web3.eth.accounts[0],
     data: '0x606060405234610000575b610260806100196000396000f30060606040526000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680631832425f14610054578063525af8601461006357806392fecc4714610086575b610000565b34610000576100616100e3565b005b34610000576100706101f1565b6040518082815260200191505060405180910390f35b34610000576100a160048080359060200190919050506101f7565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6001805480600101828181548183558181151161012c5781836000526020600020918201910161012b91905b8082111561012757600081600090555060010161010f565b5090565b5b505050916000526020600020900160005b33909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506001805490506000819055507feb8ae6c1136c030439e9ea9ffc5cfb3d6daa418c8a5463bc839c4dd4d8382eab33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a15b565b60005481565b600181815481101561000057906000526020600020900160005b915054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815600a165627a7a723058207e10191d65bf6dfd6a5c15d4fd564ad9b5659a037257ac3d50e20147b3a1fe010029',
     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 then store 10 addresses:

for (var x = 0; x < 10; x++){
    addresslist.registerAddress({from:eth.accounts[x],gas:3000000})
}

Finally I attempt to read the MemberAddresses list:

> addresslist.MemberAddresses()
"0x50522be14817f1e774e9077f58e7ef4f8d50137f"

As you can see, it returns a single address; the first element. If I pass a number it will return that element. I'd like a list. Can I return all array elements without a loop, on the geth console?


texts: Why aren't bootnodes responding to my ping?

texts:
I have impemented custom Ethereum node and I've been trying to ping bootnodes, but sometime in the past three months they stopped responding to me. The specific bootnode I've been trying to ping is

enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303

The format of the ping is

(Ping version:3
    Me:(EndPoint IP:52.4.20.183 TCP:30303 UDP:30303)
    Them:(EndPoint IP:5.1.83.226 TCP:30303 UDP: 30303)
    Expiration: 1527312518.72)

When RLP encoded this is

['\x03', ['4\x04\x14\xb7', 'v_', 'v_'], ['\x05\x01S\xe2', 'v_', 'v_'], '[\x08\xf0\x86']

I can send this type of ping to other nodes and I get responses, specifically pongs, as expected. However, when I send this message to the bootnodes, I get back nothing. Has there been a recent change to the P2P protocol? If so, what was it? It doesn't seem to be documented in any places I would expect.

Are bootnodes running v5 of the discovery protocol without any documentation??


texts: What’s the Ethdev contract and what’s the purpose?

texts:
Everything is in the title : What’s it’s purpose ; The addresses paid with this contract belong to who ?

Additionally, since it’s ᴀʙɪ is public, is it the same for it’s exact source (I already guess it’s parity multisig) ?


texts: I keep reading about chain spec json files and genesis .json files.  I'm in the last stages of firing up a private network with a unique chain spec, and I wonder if I also need a genesis.json?  Or does the "genesis" section of the chain spec cover it?


texts: Tech challenges related to coinbase account recovery

texts:
I am trying to reacquire access to a coinbase account that I used as the repository for ethereum I was mining almost 2 years ago.  I have the json file corresponding to the correct address. I have verified that the balance I expected the account to have is still there using the Etherscan.io website. My questions are:

1) Do I need to wait for geth to download the entire blockchain before I can expect the correct balance to show up in response to an eth.getBalance command in the console? Obviously I haven't completed the downloading of the complete blockchain yet so I am trying to determine why the getBalance command is giving me a zero now.

2) I have a .ethereum folder from a now defunct operating system that I used some to ago. The chaindata folder contains over 18,000 items. The current operating system has geth installed but the chaindata folder contains only 6700 items. Can I expedite the blockchain synchronization by moving the blockchain data from the old install to the current one .... I'm referring to the contents of the chaindata folder specifically.  If so are there files outside of the chaindata folder that also need to be moved with it, like a folder with index files ... or something like that?

3)When I started mining ethereum I made sure to take careful notes and to make backups of anything that might prove to be important later so I backed up the.json file and also a file with a name that starts with "UTC--2015-09-07". I am running Kubuntu 16.04. I added the 3 ppa's for ethereum, updated the packages database and then installed the ethereum and cpp-ethereum packages. To import my old account into this new installation I moved the json file and the UTC.. file into the ~/.ethereum/keystore/ folder.  When I run eth.accounts at the console I now see two accounts one of which is the correct eth address I am trying to recover. When I run

geth --etherbase  --unlock 0 console 2>> geth.log

I am prompted for a password which I expected because my notes include the password that I specified when I set up the account.  When I type in the password though I see the error message "Failed to unlock account 0 (could not decrypt key with given passphrase"

I have spent hours looking for a clue regarding what I am doing wrong. Any assistance or advice you can offer me would be most appreciated.

Thank you,
markoff


texts: How to empty uint array after value is assigned?

texts:
Here is an uint array defined in smart contract:
uint256[] public bidderItemID;

And bidderItemID is assigned value in contract:
bidderItemID = [1,2,3];

How can I empty bidderItemID after it is assigned a value? That is, bidderItemID.length is 0 and there is no element in bidderItemID. I tried bidderItemID=[] and it throws an error.


texts: Is there any way to return multiple structs (or the fields from them) in Solidity when one of the struct fields is of type `bytes`?

texts:
I would like to return structs keys from my contract to display on the frontend, ideally 10 at a time. I understand that if I make keyByOwner public I can return a single key at a time with the getter that is created, but I need 10 keys and don't want to call the getter function 10 times.

I've tried to use the approach detailed here to return a tuple of arrays:
https://medium.com/coinmonks/solidity-tutorial-returning-structs-from-public-functions-e78e48efb378
I think this would be the way to proceed, except that it doesn't seem to work with the Key's data field being of type bytes(it works fine if I change type byes to type bytes32), giving me this error:

TypeError: This type is only supported in the new experimental ABI encoder. Use "pragma experimental ABIEncoderV2;" to enable the feature.
    returns (uint[], bytes[])
                     ^-----^

Is there any way to return multiple structs (or the fields from them) in Solidity when one of the struct fields is of type bytes?

Here is my function:

struct Key {
  uint expirationTimestamp;
  bytes data;
 }

 mapping (address => Key) internal keyByOwner;

 address[] public owners;

  function getKeysByPage(uint _startIndex)
    external
    view
    returns (uint[], bytes[])
  {
    require(outstandingKeys() > 0, "No keys to retrieve");
    require(_startIndex >= 0 && _startIndex < outstandingKeys(), "Index must be in-bounds");
    uint endOfPageIndex;

    if (_startIndex + 9 > owners.length) {
      endOfPageIndex = owners.length - 1;
    } else {
      endOfPageIndex = _startIndex + 9;
    }

    address[] memory ownersByPage = new address[](10);
    uint[] memory timestampsArray = new uint[](10);
    bytes[] memory keyDataArray = new bytes[](10);
    Key memory tempKey;
    uint pageIndex = 0;

    // Build the specified set of owners into a new temporary array
    for (uint256 i = _startIndex; i <= endOfPageIndex; i++) {
      ownersByPage[pageIndex] = owners[i];
      pageIndex++;
    }

    // Loop through ownersByPage & build the requested keys into 2 new temporary arrays
    for (uint256 n = 0; n < ownersByPage.length; n++) {
      tempKey = keyByOwner[ownersByPage[n]];
      timestampsArray[n] = tempKey.expirationTimestamp;
      keyDataArray[n] = tempKey.data;
    }

    return(timestampsArray, keyDataArray);
  }