texts: How to connect to my private ethereum network using web3?

texts:
I have setup my own private eth network. I wanted to connect to this. So first I have run

geth --datadir ./tolotolo --networkid 1115 --port 30304 console 2>>myEth.log

It generated geth.ipc file. Then I do

geth --ipcpath tolotolo/geth.ipc --networkid 1167 --port="56789"

Then in my node js I have installed web3 then I tried to connect

var Web3 = require('web3');
var web3 = new Web3("ws://192.168.1.99:56789");
web3.eth.net.isListening()
    .then(() => console.log('is connected'))
    .catch(e => console.log(e));

It produced output

Error: connection not open on send()
    at Object.ConnectionError (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\web3-core-helpers\src\errors.js:69:23)
    at Object.ConnectionNotOpenError (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\web3-core-helpers\src\errors.js:48:21)
    at C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\web3-providers-ws\src\index.js:181:37
    at Map.forEach (<anonymous>)
    at WebsocketProvider._onClose (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\web3-providers-ws\src\index.js:180:27)
    at W3CWebSocket._dispatchEvent [as dispatchEvent] (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\yaeti\lib\EventTarget.js:115:12)
    at W3CWebSocket.onConnectFailed (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\@web3-js\websocket\lib\W3CWebSocket.js:219:14)
    at WebSocketClient.<anonymous> (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\@web3-js\websocket\lib\W3CWebSocket.js:59:25)
    at WebSocketClient.emit (events.js:223:5)
    at ClientRequest.handleRequestError (C:\Users\karthik.KT\workspace\tolotolo\server\node_modules\@web3-js\websocket\lib\WebSocketClient.js:227:14)
    at ClientRequest.emit (events.js:223:5)
    at Socket.socketOnEnd (_http_client.js:440:9)
    at Socket.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  code: 1006,
  reason: 'connection failed'
}

What is the best way to connect to my private network using web3? Thank you.web3


texts:
Questions.
How to import an account in Metamask browser on Android?
or
How to use Metamask in Android?

Description:

I followed the link metamask.io
I clicked Get Chrome Extension.
The site redirected me to - https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn?hl=en
I clicked Install.
Result: the Metamask browser is installed.

Used by:

Android
Model - Mi PAD 3
Android Version - 7.0 NRD90M
MIUI Version - MIUI 8.3 by xiaomi.eu 7.5.25
Browser - Metamask


texts:
When we retrieve a file through IPFS, it caches the file in IPFS' repository. Later when we want to fetch the same file or its updated version, only block that contains the changed character will be fetched.

[Q] I was wondering does Swarm provide similar approach? or does it fetch complete file at each retrieve call?


texts: How to find out price of ETH and altcoin at which they were bought from the completed order

texts:
I know this might be a very mathematically retarded question, but I am trying to find out the price of ETH and the altcoin at the time I bought them from completed order history.
All it shows is the ratio of ETH/Altcoin, number of units got and bid/ask etc.


texts: Using contracts to create a pseudo-permissioned block chain

texts:
I've learned about permissioned block chains here. Is it possible to filter transactions to the contract's methods based on the sender's address. Something the lines of:

contract FilterByAddress {
    address[] addrs =  [0x36eaf79c12e96a3dc6f53426c, 0xf235aa56dd96bda02acfb361e];

    address controlAddr = 0x36eaf79c12e96a3dc6f53426c;

    function getSensitiveData() public return (string) {
         uint i = 0;
         for(i = 0; i < addrs.length; ++i)
            if(msg.sender == addrs[i])
               return "You got the secret";
            else
               return "You got nothing";
    }
}

Where the secret is a value encrypted with a key obtained through a secure channel.

Would it be also possible to control the list of allowed peers by their address? For example,

function addAddress(address addr) public return (uint) {
    if(msg.sender == controlAddr) {
        addrs.push(addr);
        return 1;
    } else
        return 0;
}

Now this isn't a fully permissioned block chain as any may sync with it and see the contract's contents and it's still susceptible to the 51% attack.

Will the contract's state change (the address filtering list) when updated from the controlAddr?


texts:
I'm new to smart contracts, so please be gentle ;)

I'm having trouble deploying a contract to testrpc using truffle.

$ truffle deploy

  Error deploying LFC:

  Error: VM Exception while executing transaction: out of gas

Here's my contract:

import "Mortal.sol";
import "Exchanger.sol";
import "ExternalStorage.sol";
import "DepositDB.sol";
import "ForexDB.sol";
import "OrderDB.sol";
import "ContractManagerDB.sol";

contract LFC is Mortal {

    // ForEx exchanger
    // Steve Huckle

    bytes3 private constant defaultBaseCurrency = "Eth";

    bytes32 private constant orderName = "Order DB";
    bytes32 private constant forexName = "Forex DB";
    bytes32 private constant depositName = "Deposit DB";

    Exchanger private exchanger;
    ExternalStorage private storageContract;
    OrderDB private orderDB;
    DepositDB private depositDB;
    ForexDB private forexDB;
    ContractManagerDB private contractManagerDB;

    //event ExchangerCreated(address ex, uint now);

    function createExchanger() public {
        exchanger = new Exchanger();
    }

    function createStorage() public onlyOwner {
        storageContract = new ExternalStorage();
        storageContract.changeOwner(exchanger);
    }

    function createContractManager() public onlyOwner {
        contractManagerDB = new ContractManagerDB();
        contractManagerDB.setStorage(storageContract);
        contractManagerDB.changeOwner(address(exchanger));
        exchanger.setContractManager(contractManagerDB);
    }

    function createOrderContract() public onlyOwner {
        orderDB = new OrderDB();
        orderDB.setStorage(storageContract);
        orderDB.changeOwner(address(exchanger));
        //storageContract.setAddressValue(sha3(managerName,orderName),orderDB);
    }

    function createForexContract() public onlyOwner {
        forexDB = new ForexDB();
        forexDB.setStorage(storageContract);
        forexDB.changeOwner(address(exchanger));
        //storageContract.setAddressValue(sha3(managerName,forexName),forexDB);
    }

    function createDepositContract() public onlyOwner {
        depositDB = new DepositDB();
        depositDB.setStorage(storageContract);
        depositDB.changeOwner(address(exchanger));
        //storageContract.setAddressValue(sha3(managerName,depositDBName),depositDB);
    }

    function addAdmin() public onlyOwner {
        storageContract.addAdmin(exchanger);
        storageContract.addAdmin(depositDB);
        storageContract.addAdmin(forexDB);
        storageContract.addAdmin(orderDB);
        storageContract.addAdmin(contractManagerDB);
    }

    function addContracts() public {
        contractManagerDB.addContract(orderName,orderDB);
        contractManagerDB.addContract(forexName,forexDB);
        contractManagerDB.addContract(depositName,depositDB);
        exchanger.setNames(orderName,forexName,depositName);
    }

    function setForexBase() public {
        forexDB.setBase(defaultBaseCurrency);
    }

    function getExchanger() public constant returns (address) {
        return exchanger;
    }
}

Any help and/or explanation as to how to overcome the issue and what I'm doing wrong would be very gratefully received. The problem appears to be with doing too many "new's". Is that approach unusual? Rather than doing it that way, instead, should I deploy the dependent contracts and then pass their addresses into the contract above?


texts: Can MyEtherWallet/Jaxx interact with a Mist generated Multisig wallet?

texts:
I've created a 3 fo 5 multisig wallet using the Mist browser. The first account was created in Mist, but the rest were on different computers (some offline) and I just typed in the public addresses in Mist when assigning owners.

So, now I'm trying to send Ether to The DAO, and I can only get the original Mist account to sign the transaction. I can't seemd to understand if MyEtherWallet will let me "Approve" the transaction from the Contract... and Jaxx won't even let me sign an arbitrary message let alone import an ABI.

So far it looks like I'll need Mist on each Computer and mobile signing will have to wait...


texts:
I wrote a smart contract PersonalInfo.sol. In this smart contract, I want to save an array of address. Each address is the place where smart contract were deployed. However, each time I deployed the smart contract the array cleaned the history of address that it has been deployed and only push the address right now. How can I fix this issue? Please help.

pragma solidity ^0.4.17;
contract PersonalInfo{
    address public userAddress;
    address[] public Users;
    string public email;
    string public userName;

    function PersonalInfo ()public{
        userAddress = msg.sender;
        Users.push(userAddress);
    }
    function SavePersonalInfo(string Name, string Email)public{
        userName = Name;
        email = Email;
    }

}


texts: I was going through the quorum docs and got stuck on how private transactions are mined? When two nodes, say Node A and Node B do a private transaction between themselves. Which node then mines the transaction and creates the block? Since no other node can see the payload of the transaction itself, does it mean that either of the two nodes can mine the transaction?


texts: Can't import Interface to another contract. (TypeError)

texts:
This is a snippet of my main code:

pragma solidity ^0.6.0;

import 'IERC20.sol';

contract Kaarya is IERC20 {

   uint public constant _totalSupply = 1000000;

   string public constant symbol = "KRY";
   string public constant name = "Kaarya Token";
   uint8 public constant decimals = 3;

   mapping(address => uint256) balances;
   mapping(address => mapping(address => uint256)) allowed;

   constructor() public{
       balances[msg.sender] = _totalSupply;
   }

   function totalSupply() external view returns (uint256) {
       return _totalSupply;
   }

   function balanceOf(address account) external view returns (uint256) {
    return balances[account];
   }

   function transfer(address recipient, uint256 amount) external returns (bool) {
       require (
        balances[msg.sender] >= amount
        && amount > 0
    );
    balances[msg.sender] -= amount;
    balances[recipient] += amount;
    Transfer(msg.sender, recipient, amount);
    return true;
    }

   function transferFrom(address sender, address recipient, uint256 amount) external returns (bool) {
       require(
           allowed[sender][msg.sender] >= amount
           && balances[sender] >= value
           && amount > 0
       );
       balances[sender] -= amount;
       balances[recipient] += amount;
       allowed[sender][msg.sender] -= amount;
       return true;
   }

   function allowance(address owner, address spender) external view returns (uint256) {
       return allowed[owner][spender];
   }

   function approve(address spender, uint256 amount) external returns (bool) {
       allowed[msg.sender][spender] = amount;
       Approval(msg.sender, spender, amount);
       return true;
   }

   event Transfer(address indexed from, address indexed to, uint256 value);

   event Approval(address indexed owner, address indexed spender, uint256 value);

}

I get the error: TypeError: Name has to refer to a struct, enum or contract. Contract Kaarya is IERC20 {

This is a snippet of the code for what I'm importing:

pragma solidity ^0.6.0;

interface IERC20 {

    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

I checked other similar questions in StackExchange but still doesn't work. Any help would be great!


texts: GETH node works on Apache but not on ExpressJs

texts:
I had a running GETH node linked to my localhost (hosted with Apache) , I had to migrate the project on a ExpressJs running on port 3000 and now I have

Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545

When I run the exact same code with the same GETH instance (but with Xampp) , everything works fine.

Any clue ? Thanks all

EDIT :

Apparently , it's maybe because NodeJS doesn't have the writing permission. Does anyone knows how to allow it on Linux ? Thanks


texts:
Is there a way to manage migrations with truffle ?
I mean by migrationa change to a new version of a smartcontract.
Let's suppose this smartcontract:
contract SimpleStorage {
  uint storedData;

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

  function get() public view returns (uint) {
    return storedData;
  }
}

In order to deploy it, i run:
$ truffle migrate

At this step, everything works fine: The contract is deployed and i can interact with it.
Now, let's suppose i add a function to this contract:
contract SimpleStorage {
  uint storedData;

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

  function get() public view returns (uint) {
    return storedData;
  }

  function inc() public {
    storedData += 1;
  }
}

I run again
$ truffle migrate

A new version of my contract is deployed to a new address. The previous contract is still deployed because we cannot delete anything on a blockchain.
Is there a way for truffle to "copy" storedData variable value from the old contract deployment to the new ?
What is the goal of "truffle migrations": Is it a version system management or something else ?
Thanks


texts: How to typecast keccak256 function with multiple arguments to uint256?

texts:
solidity ^0.4.19 (works)

uint256 randNonce++;
return uint256(keccak256(msg.sender, randNonce, now))

solidity ^0.4.24 (throws)

uint256 randNonce++;
return uint256(keccak256(abi.encodePacked(msg.sender, randNonce, now)));

throws:
Type uint256 is not implicitly convertible to expected type uint8


texts:
I am trying to deploy a smart contract in the ethereum testnet and in order to accomplish that I tried to sync the Ethereum testnet "ropsten" using geth. I used the command below to do it.

geth --testnet --syncmode "fast" --rpc --rpcapi db,eth,net,web3,personal --
cache=1024  --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --
bootnodes "enode://20c9ad97c081d63397d7b685a412227a40e23c8bdc6688c6f37e97cfbc22d2b4d1db1510d8f61e6a8866ad7f0e17c02b14182d37ea7c3c8b9c2683aeb6b733a1@52.169.14.227:30303,enode://6ce05930c72abc632c58e2e4324f7c7ea478cec0ed4fa2528982cf34483094e9cbc9216e7aa349691242576d552a2a56aaeae426c5303ded677ce455ba1acd9d@13.84.180.240:30303"

The testnet should have synced in 15-20 minutes (from what I read in a couple places) but I have been running for almost 18 hours. There is no error and not struck at any point.

When I tried eth.syncing from the geth console, This is what I got

{
  currentBlock: 1588913,
  highestBlock: 1589055,
  knownStates: 9029253,
  pulledStates: 9020460,
  startingBlock: 1588426
}

I thought I was almost there at the highest block. But this has been the situation for couple of hours. The known states and pulled states are ever expanding.

Is there any other alternative way to download the testnet chaindata which will make the process much faster than syncing it through the geth command?


texts: Reeusing a contract already deployed on remix

texts:
I am using with this contract https://pastebin.com/WCGNfbd8 and once I have compiled and deployed it on remix, there is functions that appear under "deployed contract" in "deploy and run transaction" so that I can interract with the contract.
But if I close remix and come back I am not able to find those function again, even if I try to reload the contract, isnt it is supposed to be keep on the blockchain and so I can call it whenever I want ?


texts: How to initialize address[] array with values

texts:
Is there any shorter way to do the following?

address[] memory myArray = new address[](2);
myArray[0] = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
myArray[1] = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

Ideally something like (not working)

address[] memory myArray = [0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE];

Or at least (not working)

address[] memory myArray = new address[](2);
myArray[0], myArray[1] = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2, 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE


texts:
I am working on a project and I am unable to figure out the architecture of a crypto exchange wallet in which I want to convert fiat currency to my own cryptocurrency which has same value

i.e, 1 INR = 1 cyr {cryptorupee}

I want to make the above conversion happen.


texts: My truffle tests use several accounts and send tokens between them, so how would I run such a truffle test on testnet, e.g. Rinkeby?


texts: mining with 2GB GPU with partial uploading

texts:
I see all older questions [*]. But I read in reddit

  Yes. But your efficiency is lowered. Use ethOS dagless mining.

My question is whether this is true and which software allows this? I see ethOS is mostly a collection of other programs. I don't want to use ethOS. Which exactly miner allows this?

old questions:

Can you mine with 2GB cards or less? Thinking about the DAG issues
Is it still possible to mine with a GPU with less than or = to 2GB of vram?
What is the current DAG size? When do we expect to hit GPU limits?
Is it still possible to mine with a GPU with less than or = to 2GB of vram?
What is the current DAG size? When do we expect to hit GPU limits?


texts: Decentralized Data Storage for IoT using Sia

texts:
For my Master research I want to make a proof-of-concept of decentralized data storage for an IoT scenario.
My idea is to receive measurement values from a raspberry pi and to store them using sia.
I think this minio gateway can allow me to realize this:
https://github.com/minio/minio/blob/master/docs/gateway/sia.md

I’m only aware of bluzelle that is aiming to build such a decentralized database, but i think it’s not available yet.
Also I’m thinking to later use an Ethereum smart contract to enable people to buy the anonymized data or to trigger certain actions depending on the measurement values.
Can someone give me some feedback to what I’m trying to achieve? Is it possible? Is it useful or are there better approaches or projects that I should use?

Just to clarify: The common way to store IoT data is currently to store it in the cloud for example by using AWS.
This has the drawback that I trust a single entity with my data. Decentralized storage such as Sia stores pieces of my data on different hosts redundantly, so that a single host is not able to make any sense of the data junks that he stores. Also if a host disappear my data is still available because it’s stored redundantly.


texts: Why was support for floating point numbers not natively added to Solidity (or Ethereum in general)

texts:
Remix usually shows that floating points are not fully supported yet, and even the external libraries avaiable for floating point calculations in solidity are under the hood still using integers. So, is there any limitation as such when dealing with a decentralized computer which led to avoidance of typical floating points?
P.S: Recently started working with smart contracts on Tezos blockchain, and there too the floating point type is absent. This got me thinking if it might be the case for decentralized computers in general.


texts: geth javascript console: web3.eth.subscribe ==> "Object has no member 'subscribe'"

texts:
I must be missing something -- I am trying to use the web3.eth.subscribe() function in my geth node's javascript console and there is no subscribe function.
    Welcome to the Geth JavaScript console!

instance: Geth/v1.9.23-stable-8c2f2715/linux-arm64/go1.15.3
coinbase: 0xc029cea32eb050a35c23e82ad1fecd20087283bc
at block: 7463930 (Sat Oct 31 2020 04:03:00 GMT+0000 (UTC))
 datadir: /home/rinkeby/.ethereum/rinkeby
 modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

web3.eth.subscribe('pendingTransactions')
TypeError: Object has no member 'subscribe'
        at <eval>:1:19(5)


texts: Mining stops after some time in my Hyperledger-besu Private blockchain

texts:
I have been using Hyperledger-Besu's quickstart guide to build my private blockchain (with ibft2 as consensus algorithm) on an AWS instance, which basically just clones that repo https://github.com/PegaSysEng/besu-sample-networks
and run the scripts, anyways everything works fine but suddenly maybe after some days the mining process gets stopped resulting in no response from the dapp.

I figured out I have to restart the network, without erasing the containers, then mining process works again.
But i can not figure out why the mining process stops or why it even works again after restarting, and this is annoying as there is no indicator when it will stop or any error handling.

Currently I have also modified the scripts here https://github.com/PegaSysEng/besu-sample-networks to make the network Free-gas as explained in that guide https://besu.hyperledger.org/en/stable/HowTo/Configure/FreeGas/ but I still have the same problem.

so If anyone had the same problem or can think of a solution it would be great, thanks.


texts: Can I use my ETH while waiting for it to process?

texts: I am a newbie. I purchased about $2,500 worth of ETH 4 days ago. I want to use it now. Is that possible or must I wait until it is in my wallet?  I could have made a quick profit if I was able to sell it!


texts: ERC20 Token tansfer through delegatecall throws

texts:
I'm trying to call the transfer() function on an ERC20 token through the use of delegatecall, my proxy contract however returns false from delegatecall.

When I try to call view functions like balanceOf() my proxy contract returns true. However since there are no possible exceptions in the balanceOf function I would also get 'true' even when returned "0" instead of "100000"

Token contract gets deployed through the constructor of the proxy contract. The owner of the token contract is the proxy contract. When deployed the proxy contract will mint 10000 tokens for the creator.

The imported token.sol contract is from open-zeppelin and works on its own.

pragma solidity ^0.4.20;

import './token.sol';

contract Test {
    Token public token;
    constructor () {
        token = new Token("Test", "TST", 18);
        token.mint(msg.sender, 10000);
    }

    function call(address _to, uint256 _value) returns (bool) {
       return  address(token).delegatecall(bytes4(sha3('transfer(address, uint256)')), _to, _value);
    }
}

status  0x1 Transaction mined and execution succeed
decoded input   {
        "address _to": "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C",
        "uint256 _value": "50"
    }
decoded output  {
        "0": "bool: false"
    }


texts: Smart Contract Design: 2-step Escrow Architecture

texts:
How can I architecture following in the most optimal way; I'm trying to have a flow between contract A, B, and C.
Contract C should be sending ERC20 to contract B.
Contract A should be sending Ether to contract B.
Contract B should accept the two values from contract C & A, and perform a swap between the two only if both contract C & A gives their consent to contract B to execute the swap of their sent values to contract B.   So in this specific scenario, we are dealing with a two-phase process.


texts: Why is the different "highest block" of --network id 3 and --testnet?

texts:
I think both of --network id 3 and --testnet mean to the Ropsten network.

But, The result of "eth.syncing" differ from each.

--testnet result "highestBlock: 3852529"

$ geth --testnet console 2>> geth-test.log
> eth.syncing
{
  currentBlock: 3788019,
  highestBlock: 3852529,
  knownStates: 18107905,
  pulledStates: 18107905,
  startingBlock: 3787849
}

--networkid 3 result "highestBlock: 6105050"

$ geth --networkid 3 console 2>> geth-test.log
> eth.syncing
{
  currentBlock: 1181005,
  highestBlock: 6105050,
  knownStates: 1529557,
  pulledStates: 1529557,
  startingBlock: 1181005
}

I do not know why this is the case...
Are not they the same?


texts: Invalid jump destination error when attempting to transfer The DAO tokens

texts:
I transfered DAO tokens from a Mist wallet to another address and got this error:

  The following error(s) were encountered : [323] invalid jump
  destination (PUSH1) 2

The TxHash is 0x368317115429c87184e9413e4777d7e986850cff339700ffe5f4a8e5db978af4 and the error [323] invalid jump destination (PUSH1) 2 is displayed in the VMTrace.

Why would a simple Mist wallet token transfer do this, and can I safely just re-transfer without concern about future execution of this first attempt (ie. is this transaction dead forever)?

NOTE: Saw this on ESE, but didn't seem to speak to my situation:
Error During Token Contract Execution.


texts: Can other nodes in system see the state of my contract?

texts:
I created a simple contract which has a simple state with a single int.

I gave it a value of 90 at the deployment time (constructor).

Now I went to the particular block in Rinkeby, and I could see the Bytecode of my contract code.

But I am not sure if other nodes can see that I had set the value to 90.

Or one can see it only if there is a getter for it?

I am sorry if my question is very basic. I have just got stared with Ethereum.


texts: Why is truffle migration failing to deploy contracts? "cannot read options of undefined"

texts:
I am trying to deploy a local version of SushiSwap on a local test Ethereum chain.
I am using Ganache and Truffle to deploy the smart contracts locally.
When I run truffle migrate and attempt to deploy any of the contracts, the second file in the migrations 2_deploy_contracts.js fails with an error:
TypeError: Cannot read property 'options' of undefined at Contract (C:\Users\O\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\contract\lib\contract\index.js:31:1)
For reference here is the code. I have added the SushiToken.sol contract to deploy.
var SushiToken = artifacts.require("SushiToken");

module.exports = function (deployer) {
  deployer.deploy(SushiToken()); //This new line throws the error
};

Some more context:
SushiToken() is an instance of SushiToken.sol. See line 1 in the above code. The code still fails if I add the .sol extension to the above code.
This leads me to my question:
Why is truffle failing to deploy the contract?


texts:
i have the code below:

    uint256 lastBlockNumber = block.number - 1;
    bytes32 hashVal = bytes32(block.blockhash(lastBlockNumber));
    bytes5 _byteData = bytes5((hashVal & 0xffffffff) << 216);

the last line bytes5((hasVal & 0xffffffff) << 216); was working perfectly with solidity 0.4.18 but once i am trying it with 0.5.2 its not working i am getting the error below:

  Operator & not compatible with types bytes32 and int_const 4294967295

i am not able to resolve this, any idea on how to resolve it? thank you


texts: How to split funds in single send transaction

texts:
Scenario:

Alice Account = 2 ETH
Admin Account = 0 ETH
Bob Account = 0 ETH

Alice wants to send 1 ETH to Bob using my application. Application will charge 0.01 ETH as it's commission and will be added to total transaction fee

Total Fee = Application Fee (0.01) + Network Fee (gas limit * gas price)

Suppose Network fee is calculated to 0.001008 ETH.

Total payable amount = 1.011008 ETH (1 + 0.01 + 0.001008)

After successful transaction following should be the account details

Alice Account = 0.988992 ETH
Admin Account = 0.01 ETH
Bob Account = 1 ETH

where as 0.001008 ETH will be paid to miners

Query:

Q1. How can I build an application where a funds of a single send transaction can be sent to two different addresses (Bob's address and Admin's address)?

Q2. Is it possible to build such an application without using smart contracts?


texts:
I have tried to install an ipfs node on my computer.
It works: I have stored files and i can get them with their hash.
Now, what i want to do is to "publish" my files to the "full network".
I want to access my files from this kind of url:
https://ipfs.io/ipfs/<myhash>

How can i do that ?
What is ipfs.io ? Is it a node ? Is it something centralized ?
Thanks


texts: Is it possible to mine on testnet using --light option?

texts: Iw ould like to get some testnet eth on my wallet, but don't want to download the testnet but start geth with --light. Would that be possible?


texts:
I want to allow my users to deposit funds, and have all those funds sent to a mainwallet cos its gonna be very small amounts of ether ($2-$5 worth) for alot of users. So id imagine i can create a forwarding contract for each user so i can detect payments to the contract and have it all in one place instead of spending my whole week manually transferring small amounts from each account. I suppose theres a script for that.Which approach would you reccomend and if the forwarding contract approach, can you explain whats wrong with this contract. Im getting alot of warnings

pragma solidity ^0.4.2;
/**
 * Contract that will forward any incoming Ether to its creator
 */
contract Forwarder {
  // Address to which any funds sent to this contract will be forwarded
  address public destinationAddress;

  /**
   * Create the contract, and set the destination address to that of the creator
   */
  function Forwarder() {
    destinationAddress = msg.sender;
  }

  /**
   * Default function; Gets called when Ether is deposited, and forwards it to the destination address
   */
  function() payable {
        if (!destinationAddress.send(msg.value))
            throw;
  }

  /**
   * It is possible that funds were sent to this address before the contract was deployed.
   * We can flush those funds to the destination address.
   */
  function flush() {
    if (!destinationAddress.send(this.balance))
          throw;
  }
}


texts:
I am reading the following article from a website:
bad randomness

In the context of Blockhash the author says:
For instance, a good protocol (formulating a random trial as a “bet”)
is the following:

  • accept a bet, with payment, register the block number of the bet
  transaction

  • in a later transaction, compute the blockhash of the
  earlier-registered block number, and use it to determine the success
  of the bet.

Somebody please guide me what is meant by registered block number.

Zulfi.


texts: How to create the ENS subdomain and assign it to an address?

texts:
The full code: https://plnkr.co/edit/WYDB9fOvmRoUvCVw

Testing on the mainnet because: ENS on Rinkeby - Network does not support ENS?

1⃣ setSubnodeOwner works

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

web3.eth.ens.('dearmoon.eth', 'hack', accounts[0], {from: accounts[0]}).then(function (receipt) {
    console.log(receipt);
});

2⃣ setResolver works

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

web3.eth.ens.setResolver('hack.dearmoon.eth', '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', {from: accounts[0]}).then(function (receipt) {
    console.log(receipt);
});

3⃣ setAddress fails

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

(Metamask told me it will fail but I send it anyway hoping for some helpful revert message)

web3.eth.ens.setAddress('hack.dearmoon.eth', '0x614962025820c57d6af5acff56b5879237daf559', { from: accounts[0] }).then(function (result) {
  console.log(result.events);
});

I'm using: https://web3js.readthedocs.io/en/v1.2.7/web3-eth-ens.html#setaddress

Do you know why setAddress fails? ♀

Existing research, good links:

https://github.com/ensdomains/subdomain-registrar - not good, the transfer is irrevocable, I need flexibility.
https://www.toptal.com/dapp/ethereum-name-service-dapp-tutorial - this is actually quite clever, including smart contract that does everything in a single transaction: https://github.com/radek1st/ens-subdomain-factory/blob/master/contracts/EnsSubdomainFactory.sol#L73-L79

registry.setSubnodeOwner(domainNamehash, subdomainLabelhash, address(this));
registry.setResolver(subdomainNamehash, resolver);
resolver.setAddr(subdomainNamehash, _target);
registry.setOwner(subdomainNamehash, _owner);

I'm thinking about using it but before doing complicated stuff I prefer to learn basics first.

Longer-term I would like to anyone register a subdomain but without me losing ownership.


texts: Can Ethereum be used as part of a decentralised forum like StackExchange?

texts: Can Ethereum be used as part of a decentralised forum?


texts:
i created a variable called startDate using now in a smart contract.

when reading it using Contract.startDate() it returns BigNumber { s: 1, e: 9, c: [ 1530272788 ] }

how do i convert this to an Interger (or anything else i can work with)? toNumber() and toString() wont work.

edit: toNumber() already worked on "bigger" bugnumbers (with e>10), just not with the bigNumber returned by startDate


texts: undefined contract address when trying to deploy with web3 and Metamask

texts:
I am trying to develop a simple wallet type contract but having troubles deploying it. I am trying to deploy it using the method described here. I am using truffle and web3 along with Metamask. Now, here's what I have for deploying the contract:

var contract = web3.eth.contract(abi);

instance = contract.new({
          from: web3.eth.accounts[0],
          data: <bytecode>,
          gas: 10000000
      }, function (e, contract){
          console.log(e, contract);
          if (typeof contract.address !== 'undefined') {
              console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
          }
      });

Transaction goes through fine but the contract address remains undefined for some reason. I want to be able to call contract functions. I have tried deploying it straight from Browser-Solidity with no luck.

Can anyone help me figure out what's going on? Also, is there any better way of doing this? Any suggestions are welcome!


texts: Connect Frontend to Deployed Contract on Ropsten Testnet

texts: I recently deployed a contract on the Ropsten testnet and am trying to connect my frontend to my deployed contract. I have created a contract instance with my ABI and contract address, however, my frontend is still not connecting properly. I am currently connecting to web3 via localhost 7545. Is this the problem? How can I resolve this? Help would be insanely appreciated!


texts: Should I connect to the blockchain from the client or server side?

texts:
I am trying to build a simple Dapp for buying and trading tokens.

Which of the following would be a better way to integrate with blockchain:

On the server side
On the client side

Which is more efficient? I don't think security will be a concern as blockchain data is already hashed.


texts:
I am trying to understand why RLP was chosen and developed as an in-house protocol.I stumbled up this link which provides some insights:

https://github.com/ethereum/wiki/wiki/Design-Rationale

Trying to understand the paragraph below, a detailed explanation is greatly appreciated.

"The alternative to RLP would have been using an existing algorithm such as protobuf or BSON; however, we prefer RLP because of (1) simplicity of implementation, and (2) guaranteed absolute byte-perfect consistency. Key/value maps in many languages don't have an explicit ordering, and floating point formats have many special cases, potentially leading to the same data leading to different encodings and thus different hashes."


texts:
I'm writing a library for Ethereum BIP44 address trees and comparing it against https://iancoleman.io/bip39/ using the same mnemonic phrase.

Given this mnemonic (just a test)

report dash combine correct until media shrimp wide about remain accuse sound solar lawsuit chest myth layer always style filter farm prison will brief

I correctly derived the seed

df9abf945edf79b2fff7b5bae337828daffac5ef49fc79d3cde032785ffe88c9f32a9ce32c48deb8b59c6efd85d599825377d233d5e6501d5acb87841f0af122

The BIP32 Root Key matches as well:

xprv9s21ZrQH143K49pE1HfQVEDXWn5e1poPa3qzNaREfAcosRdVb3Rw8zVefLthvpNf8kP66HpWLN4c9XdqtVc56yK1AauKBxagf6rY3bpne5e

This is for ETH, so I'm using the following path to get the Account Extended keys: m/44'/60'/0' (also matching)

# Account extended private key
xprv9ynU3F8fffBXZ462Y8HeMSaCjVrdQRFd2Le3jkf69kLRxvXbvhnrda7v5jFewACzMiYUUZFFc6QX9PcD3rTRkVcvjqbZvW1n1fAhk92YYHB

# Account extended public key
xpub6CmpSkfZW2jpmYAVe9peiaWwHXh7osyUPZZeY94hi5sQqirkUF77BNSPw2EiQ2Zzn5pARf1e5MAHDyM3xv8gzKcf82GSKxv8E8xoLX5hS7A

The BIP32 derivation path looks correct as well (m/44'/60'/0'/0)

BIP32 Extended private key
xprvA1wMCRgBn4WmoYqzVgXmsCQwXGcJ7FSeXEF2gVDaSYXPG1zePz7JuCVUcJzhU59ZRrwg1uF7SszEX3D38QwfQdxMHBYxHM2rGd2QXnQ96c6

BIP32 Extended public key
xpub6EvhbwD5cS5522vTbi4nELMg5JSnWiAVtTAdUsdBzt4N8pKnwXRZSzoxTZGD1FHURpXexK1BBRmRZrPTZPm15hBH2aWTRH55VUFtECtC7uX

Everything checks but the generation of the ethereum addresses.

M/44'/60'/0'/0/0

0x9545D807e40ff22F1EdC9Ede0d8bd383b53Bdf07

Question: Is this correct ?

The above address is generated from the BIP32 root key using the specified path following these steps.
The resulting extended public key (note the M) is Base58 decoded
The compressed public key is recovered, using EC curve calculation we recover the Y coordinate and append X and Y together to get the uncompressed public key

The standard steps to get 20 byte address (keccak sha3, keep just the tail 20 bytes and append "0x")

I double checked my Keccak hash function and it returns the correct hash for the "" value:

c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470


texts:
I'm attempting to import a transcribed geth UTC--... format keyfile into geth on ubuntu, using this guidance, and am getting the following error:

Fatal: Failed to load the private key: encoding/hex: invalid byte: U+007 B '{'

There are a few other similar questions but none ask why this error occurs.

Importing paper wallet using geth gives encoding error
Import private key into ethereum wallet
How to import an icebox encrypted wallet into Geth
Export Parity private key

I'm guessing the file must be in UTF-8 encoding. On using file -i on a terminal it returns:

UTC--etc_file_name text/plain; charset=us-ascii

I think us-ascii is a subset of UTF-8, so it should work....

Why is this error occuring?

What is the correct encoding for geth keystore files?


texts: Can I use the blockchain as a web server?

texts:
Is it possible to use the blockchain as "web server"?

Even if a web app stores all data per smart contracts on the blockchain I still need a central server to get the web app initially. Is there an approach to serve HTML & co. direct from the blockchain like a central web server does it or is this not possible?

I have the following use case: Let's say I deploy web components on my server. Everyone can use my web components now in there app. If I decide to shut down my server or my server is temporary not available, all apps which are dependent on my components are not working anymore. If I deploy my web components on the blockchain (if possible) this could never happen.


texts: Light, fast or full syncing for solo mining Ethereum?

texts: I would like to try my luck to solo-mine some ETH. Full syncing is out of range, regarding downloadtime and diskspace. So, that´s the question: Is it enoght to light syncing for solo-mining?


texts: How to use delegate call with or without arguments functions?

texts:
Below is my contract:

contract A{

    mapping (address => uint) public balances;

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

    function get(address lucky) public {
        require(msg.sender != lucky);

        if (!lucky.call.value(balances[msg.sender])()) {
            revert();
        }

        balances[msg.sender] = 0;
    }

    function() payable public {}
}

Now, I need to invoke the get function and the put function from another contract. Get function is not payable and need an address argument whereas the put function is the payable function and needs scope of msg.value only.

I tried the below code snippet but it all fails, can someone guide what I am doing wrong here?

import "browser/A.sol";

contract Attack {

    address bf = 0xdd1F635Dfb144068f91D430c76f4219088Af9E64;

    function attackBayFountain() public payable {
        // this should send msg.value to the put function
        require(bf.delegatecall(bytes4(keccak256("put()"))));

        // this should call get function of contract A with address of the Attack contract as argument
        require(bf.delegatecall(bytes4( keccak256 ("get(address)")), address(this)) );
    }

    // fallback function - where the magic happens
    function () payable public{
    }
}


texts: Contract Testing: Modifying State variable and using arguments

texts:
I tested the following contract on an online tool:

pragma solidity ^0.4.24;
contract Calculator{
   int private lastValue =0;
   function Add(int a, int b) public returns (int){
      lastValue = a+ b;
      return lastValue;
   }
   function Subtract(int a, int b) public returns (int) {
      lastValue = a-b;
      return lastValue;
    }
    function LastOperation()public constant returns (int) {
       return lastValue;
    }
 }

I got following messages:

  1)Contract fields that can be modified by any user must be inspected.
  2) Method arguments must be sanitized before they are used in
  computations.

Somebody please guide me how to modify the contract based upon the above messages?

Zulfi.


texts:
There's a lot of speak about PoS being more environmentally friendly and making transactions faster to be included in the blockchain but I haven't found any info on the fees. Will the minimum gas needed (currently 2100) or the average gas price go down?

edit: I'm aware of this question/answer but it is 1.5 years old when PoS was only a far future plan and so the answer is "we don't know yet" but with the casper testnet going alive recently there should be a better answer (or just a more sophisticated guess) IMO.


texts: MyEtherWallet JSON RPC Interface Ratelimiting?

texts:
Due to the recent mainnet.infura.io outages, I decided to switch some code which was using infura to the myetherwallet JSON RPC interface. During this time, the following error occasionally occurred.

Error: Invalid JSON RPC response: "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n\n
ERROR
\n
The request could not be satisfied.
\n
\nThe origin closed the connection.\n
\n
\n
\nGenerated by cloudfront (CloudFront)\nRequest ID: GQeM8ZIaLpwEBaAjAgi5g3i2D2cnKfkdvJn6vBguj-UmSoT7GSxG-g==\n
\n<ADDRESS>\n</ADDRESS>\n"
    at Object.InvalidResponse (/home/drone/projects/mew/asset-position-disposal/node_modules/web3/lib/web3/errors.js:38:16)
    at XMLHttpRequest.request.onreadystatechange (/home/drone/projects/mew/asset-position-disposal/node_modules/web3/lib/web3/httpprovider.js:115:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/home/drone/projects/mew/asset-position-disposal/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/home/drone/projects/mew/asset-position-disposal/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpResponseEnd (/home/drone/projects/mew/asset-position-disposal/node_modules/xhr2/lib/xhr2.js:509:12)
    at IncomingMessage.<anonymous> (/home/drone/projects/mew/asset-position-disposal/node_modules/xhr2/lib/xhr2.js:469:24)
    at emitNone (events.js:110:20)
    at IncomingMessage.emit (events.js:207:7)
    at endReadableNT (_stream_readable.js:1047:12)
    at _combinedTickCallback (internal/process/next_tick.js:102:11)

What is this? Does myetherwallet implement ratelimiting?


texts:
Is it possible to have a smart contract which uses computational libraries from python? If so, how? Is there a size restriction on this?

I wish to run an algorithm inside a contract.


texts: web3.min.js is missing in ./node_modules/web3/dist

texts:
I am following the below tutorial to create implement blockchain using web3.

https://medium.com/coinmonks/interacting-with-ethereum-smart-contracts-through-web3-js-e0efad17977

When I am using npm install ethereum/web3.js --save web3/dist is not getting created at all and is unable to find ./node_modules/web3/dist/web3.min.js.

On using npm install web3 --save web3/dist is getting created but web3.min.js is missing.

As per the tutorial and all other tutorials, need this in my script.

I need help!!!


texts: How to retrieve ERC20 from a hacked address monitored by a bot?

texts:
Check it out: https://discordapp.com/channels/554623348622098432/633092550407749652/714325610050355260

The address that was hacked: https://etherscan.io/address/0x1b3e1786c3f8524ca0f3175b0b37bcc1bee5a6d5

There are still some ERC20 left, probably the hacker did not account for all the tokens.

I was thinking that I can send 2 transactions in a single block:

Send small portion of ETH
Use that ETH to pay for the gas and send the ERC20 to my white hack address

Tried looking up how the transaction ordering works: What is the default ordering of transactions during mining, in e.g. geth?

Is the 1 + 2 plan possible?

I can surely generate raw TX with high gas prices and submit simultaneously, hopefully 1 will be higher up in the same block than 2?
Or maybe order of the transactions in the block does not matter?
Or maybe even if transaction 2 gets mined in the next block, it will be still faster than the attacker?


texts: Why does delete increase overall gas cost?

texts:
My understanding is there is a gas refund for delete and the idea is to encourage developers to remove garbage from contract states.

Consider this contract with a delete-enabled index of keys to mapped structs. The delete operations in deleteVoter() are not necessary for the function to work as required.

When the deletes are included, gas is about 34056 for a deleteVoter(). With the deletes commented out, the contract is as functional as before, but deleteVoter() only costs about 23926 gas. So, the deleteVoter() function is more gas-efficient without the delete garbage collection.

Q1: Why are the deletes adding to the cost?

Q2: Am I missing something about optimizing the two delete operations that seem to be adding to the gas cost?

Q3: Am I possibly missing the point of the gas refund? I expected the refund from the deletes to bubble up into a net savings so the cost of deleteVoter() would decrease. That is, incentivize garbage collection.

pragma solidity 0.4.11;

contract IterableMappingWithDelete {

  struct Voter {
    uint votesCast;                                         // application data
    uint voterListPointer;                                  // structurally important
  }

  mapping(address => Voter) public voterStructs;            // random access by key
  address[] public voterList;                               // sequential access by row and count

  function getVoterCount() public constant returns(uint voterCount) {return voterList.length;}

  function isVoter(address voterId) public constant returns(bool isIndeed) {
    if(voterList.length==0) return false;
    return voterList[voterStructs[voterId].voterListPointer]==voterId;
  }

  function insertVoter(address voterId) public returns(bool success) {
    if(isVoter(voterId)) throw;
    voterStructs[voterId].voterListPointer = voterList.push(voterId) - 1;
    return true;
  }

  function deleteVoter(address voterId) public returns(bool success) {
    if(!isVoter(voterId)) throw;
    uint rowToDelete = voterStructs[voterId].voterListPointer;
    uint voterListLastRow = voterList.length-1;
    address keyToMove = voterList[voterListLastRow];
    voterStructs[keyToMove].voterListPointer = rowToDelete;
    voterList[rowToDelete] = keyToMove;

    // The next line is optional garbage collection.
    // It increases the cost of this operation.

    delete voterStructs[voterId];

    voterList.length--;
    return true;
  }

}

This question is updated from the original post so the snippet works as intended. The gas figures are also updated.


texts: Is it possible to return an array of data from a smart contract?

texts:
I am busy writing my first smart contract dapp and have some questions.

My dapp has quite a bit of information I want to deliver to a client and to do this i have written a bunch of getters in the contract:

1. getSomeDetail
2. getSomeOtherDetail

There are probably 10 or so items of information that I require and 10 getters to get them.

Is it possible to have a single method that returns all the bits of information that I can then use in may dapp rather than calling each one?

In any other language I may do something like so:

function singleMethod() {
    $data = [
       'item1' => getItem1(),
       'item2' => getItem2(),
       'item3' => getItem3()
    ];
return $data;
}

Then in the app I can access each item as I need them. Obviously the advantage is a single call.

Maybe I do not need to worry about this since its not an API call that would suffer from latency issues...


texts: Can I trigger the execution of a js file from a smart contract?

texts:
I'm a noob at this, so excuse me if this is a ludicrous question..

I have a ReactJS app that interacts with a smart contract via web3.
At a certain point, some data gets stored to the contract,
by calling a function in the contract. Just after this data
is stored, I would like to be able to
call a js script, which uses Twilio to send an SMS. This script only seems to work locally when called with 'node send_sms.js'
in the terminal. The script works when called like this. But cannot be imported into the React Component file for some reason. I think it's because it cannot be run from the client.

I had been attempting for some time to call this script from within
the React component(inside an onSubmit function which is executed due to a Button press),
however, it seems that I cannot even import anything to do with this script into the Components file.

Is there a way to call it from solidity, or to trigger its execution with node?


texts:
I have created a new ERC20 contract using this generator  https://vittominacori.github.io/erc20-generator/

The status is "pending" , 21 hours at this time. Some explanation?

Previously, I tried it on Ropsten, with success.


texts: Set up hardforks parameters in parity JSON chain spec file for private network

texts: I want to set up a private network for tests using parity, which will function in the same way as the current mainnet, but with very low block mining complexity. Is Is it true that for this I need to manually set the values of the eip{number}Transition fields from this config file to zero? And is it true that I don't need to specify the parameters associated with DAO hard fork for my local testnet?


texts: Is there any API to create Addresss and wallet as well as make transfer for ETC (Ethereum Classic)?

texts:
There is balance checking, transaction list and transaction receipt getting APIs available for Ethereum Classic (ETC)?

Is ETC coin is only available on Ethereum Classic or its listed block explorer only?


texts: Truffle deploy smart contract from specific file

texts:
My contracts folder has the following files:
AdSpace.sol,Migration.sol,AdSpaceV2.sol, and EAdSpace.sol.
I have earlier deployed AdSpace.sol, and just added the other 2 files.
AdSpaceV2.sol contains
import "./IKetherHomepage.sol";

I wish to deploy AdSpaceV2.sol from command line using truffle, but can't figure out how to specify it? Does truffle accept arguments while deploying? If yes, how?
Thank you.


texts: What is preventing double spending Ether on a smart contract : how does a contract sends value/Ether to an other address?

texts:
When someone sends Ether, he/she use his private key matching address to sign the transaction. The private key not being part of the ledger, nobody can draw the fund of the account which sent money.

But how does this works for a smart contract since (as far I understand) a smart contract doesn’t have a private key ?

This not for asking how the CALL opcode works, but how internal transactions which sends Ether are handled in the ledger.


texts: Transaction underpriced at 5000000 gas but overpriced at 10000000

texts:
I've been developing a smart contract for a while on the Ropsten network using the Truffle framework, quite successfully. My truffle-config.js looks like this:
const path = require("path");
const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {
  contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    develop: {
      port: 8545,
      network_id: "*",
      host: "127.0.0.1"
    },
    ropsten: {
      provider: new HDWalletProvider(mnemonic, ropsten),
      network_id: 3,
      gas: 4000000
    },
    "live": {
      provider: new HDWalletProvider(mnemonic, mainnet),
      network_id: 1,
      gas: 5000000
    }
  },
  compilers: {
    solc: {
      version: "^0.6.0"
    }
  }
};

Where "mnemonic" and "ropsten" are strings connecting to my account and to my Infura link respectively.
I believe it is time to deploy my smart contract to the Mainnet. After looking for a little while for ways to do this within the Truffle framework, I came upon the Truffle documentation:
https://www.trufflesuite.com/tutorials/deploying-to-the-live-network#configuring-truffle
I concluded that using network_id: 1 is how I get truffle migrate --network live to deploy my smart contracts to the Mainnet.
After running the aforementioned command with gas specified at 5000000 in the truffle-config.js, I get the following error:
Error:  *** Deployment Failed ***

"Migrations" -- transaction underpriced.

However, turning that up to 10000000, I get the following error:
"Migrations" could not deploy due to insufficient funds
   * Account:  0xffA1c53b18d864A6340adA628BdFF6651fa4E097
   * Balance:  111432174000000000 wei
   * Message:  insufficient funds for gas * price + value
   * Try:
      + Using an adequately funded account
      + If you are using a local Geth node, verify that your node is synced.

What do you think is happening here? Is there some golden spot between 5000000 and 10000000 I should be looking for, and if so, how can I know beforehand what it is? Or is there something else I'm missing?


texts: Web3 Error: no synchronous methods without callback parameter

texts:
I try to load the Metamask Web3 object into my react/redux frontend. On page load i encounter the following error:

inpage.js:233 Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_mining without a callback parameter. See https://github.com/MetaMask/faq/blob/master/DEVELOPERS.md#dizzy-all-async---think-of-metamask-as-a-light-client for details.
at MetamaskInpageProvider.send (inpage.js:233)
at s.send (inpage.js:14300)
at r.mining (inpage.js:14300)
at derez (<anonymous>:2:6079)
at derez (<anonymous>:2:6072)
at derez (<anonymous>:2:6072)
at derez (<anonymous>:2:6072)
at derez (<anonymous>:2:6072)
at derez (<anonymous>:2:6072)
at derez (<anonymous>:2:6072)

Here is the relevant code:

import store from '../'
import Web3 from 'web3'

export const WEB3_INITIALIZED = 'WEB3_INITIALIZED'
function web3Initialized(results) {
    return {
        type: WEB3_INITIALIZED,
        payload: results
    }
}

let getWeb3 = new Promise(function(resolve, reject) {
    // Wait for loading completion to avoid race conditions with web3 injection timing.
    window.addEventListener('load', function(dispatch) {
        var results
        var web3 = window.web3
        console.log(web3)

        // Checking if Web3 has been injected by the browser (Mist/MetaMask)
        if (typeof web3 !== 'undefined') {
            // Use Mist/MetaMask's provider.
            web3 = new Web3(web3.currentProvider)

            results = {
                web3Instance: web3
            }

            console.log('Injected web3 detected.');

            resolve(store.dispatch(web3Initialized(results)))
        } else {

            // Fallback to localhost if no web3 injection. We've configured this to
            // use the development console's port by default.
            var provider = new Web3.providers.HttpProvider('http://127.0.0.1:9545')

            web3 = new Web3(provider)

            results = {
                web3Instance: web3
            }

            console.log('No web3 instance injected, using Local web3.');

            resolve(store.dispatch(web3Initialized(results)))
        }
    })
})

export default getWeb3

This is taken straight from truffles react-redux box (https://github.com/truffle-box/react-auth-box)

It does not tell me where the error occurs, where the callback is missing. I'm a bit confused as i thought truffle boxes contain best practice code. What am i missing here?


texts: Getting 403 Access Denied after several hours of execution

texts:
I have an application that executes fine for several hours but after a while I start seeing 403 exceptions from the RPC client, usually on internal TranasactionManager calls like "Estimate Gas".
Any suggestions on why this is happening or how I can output logs from the internal web3 client?
The Nethereum.Web3 instance and Nethereum.RPC.Accounts.IAccount instance are singletons.
I am using the BSC https://bsc-dataseed.binance.org endpoint.
Example stack trace:
Nethereum.JsonRpc.Client.RpcClientUnknownException: Error occurred when trying to send rpc requests(s)
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route)
   --- End of inner exception stack trace ---
   at Nethereum.JsonRpc.Client.RpcClient.SendAsync(RpcRequestMessage request, String route)
   at Nethereum.JsonRpc.Client.ClientBase.SendInnerRequestAsync[T](RpcRequestMessage reqMsg, String route)
   at Nethereum.JsonRpc.Client.ClientBase.SendInnerRequestAsync[T](RpcRequest request, String route)
   at Nethereum.JsonRpc.Client.ClientBase.SendRequestAsync[T](RpcRequest request, String route)
   at Nethereum.Contracts.TransactionHandlers.TransactionEstimatorHandler`1.EstimateGasAsync(String contractAddress, TFunctionMessage functionMessage)
   at Nethereum.Contracts.TransactionHandlers.TransactionSenderHandler`1.GetOrEstimateMaximumGasAsync(TFunctionMessage functionMessage, String contractAddress)
   at Nethereum.Contracts.TransactionHandlers.TransactionSenderHandler`1.SendTransactionAsync(String contractAddress, TFunctionMessage functionMessage)
   at Nethereum.Contracts.TransactionHandlers.TransactionReceiptPollHandler`1.SendTransactionAsync(String contractAddress, TFunctionMessage functionMessage, CancellationTokenSource cancellationTokenSource)


texts: How does dynamic array memory reallocating work?

texts:
Let's say I have a dynamic array of some length and I want to push a new element, but memory after last elem is already used.

What would happen in such case? Compiler would find a new 'chunk' of memory that can hold an array and copy it there or something else? And if yes, how this new address would be calculated?

Also, as I know, dynamic arrays in solidity works like mappings in some way, I mean each item of the array is laid out sequentially from address that is calculated with hash of array variable address:

keccak256(bytes32(variable_address))

And if memory was reallocated, how would solidity find this variable's new location? We don't store any pointers, just calculating hash.


texts: Can I detect if my solidity contract runs on testnet/ganache or mainnet?

texts:
Is it possible to detect from the smart contract in solidity if it runs on mainnet or testnet? Or if it runs on ganache?
Maybe by getting the network ID? But I'm not sure it's possible from the smart contract itself.


texts: What do the progress bars on the Alethzero "blockchain download" window mean?

texts:
I'm exploring Alethzero. What do the progress bars in the "blockchain download" window mean? I'm seeing this:

I'm assuming this relates to the progress in dowloading the blockchain but I can't work out what the different bars relate to.


texts: How to limit the ICO contract to 49% of the total supply?

texts:
I am using truffle and zeppelin.solidity to compile and test a contract for an ICO. So far, so good. But I have a big question:

My contract sends the total supply to the creator wallet, and then automatically sends the correct amount+first week bonus to the buyer. For test purposes, when it deploys, it creates 1000000001 tokens. In the future, these tokens will be used to reward suppliers that have complied with the AS/EN 9100 aerospatial standards set within a DApp that I am currently developping. How do I make sure that only 49% of the tokens can be sold during the ICO?

Here is the contract's source code, I use a Factory.sol contract to create it on the ropsten test net (it's address is 0xafE52AdaAD275FCd30d3bAeF947CF96017f3f277 and its name is KToken.sol):

pragma solidity ^0.4.16;

import 'zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol';
import 'zeppelin-solidity/contracts/token/ERC20/StandardToken.sol';

contract KToken is StandardToken {
    using SafeMath for uint256;

    string public name = "K";
    string public symbol = "₭‚";
    uint256 public decimals = 18;

    uint256 public totalSupply = 1000000001 * (uint256(10) ** decimals);
    uint256 public totalRaised; // total ether raised (in wei)

    uint256 public startTimestamp; // timestamp after which ICO will start
    uint256 public durationSeconds = 4 * 7 * 24 * 60 * 60; // 4 weeks

    uint256 public minCap; // the ICO ether goal (in wei)
    uint256 public maxCap; // the ICO ether max cap (in wei)

    /**
     * Address which will receive raised funds
     * and owns the total supply of tokens
     */
    address public fundsWallet;

    function KToken(
        address _fundsWallet,
        uint256 _startTimestamp,
        uint256 _minCap,
        uint256 _maxCap) {
        fundsWallet = _fundsWallet;
        startTimestamp = _startTimestamp;
        minCap = _minCap;
        maxCap = _maxCap;

        // initially assign all tokens to the fundsWallet
        balances[fundsWallet] = totalSupply;
        Transfer(0x0, fundsWallet, totalSupply);
    }

    function() isIcoOpen payable {
        totalRaised = totalRaised.add(msg.value);

        uint256 tokenAmount = calculateTokenAmount(msg.value);
        balances[fundsWallet] = balances[fundsWallet].sub(tokenAmount);
        balances[msg.sender] = balances[msg.sender].add(tokenAmount);
        Transfer(fundsWallet, msg.sender, tokenAmount);

        // immediately transfer ether to fundsWallet
        fundsWallet.transfer(msg.value);
    }

    function calculateTokenAmount(uint256 weiAmount) constant returns(uint256) {
        // standard rate: 1 ETH : 9000 ₭‚
        uint256 tokenAmount = weiAmount.mul(9000);
        if (now <= startTimestamp + 7 days) {
            // +50% bonus during first week
            return tokenAmount.mul(150).div(100);
        } else {
            return tokenAmount;
        }
    }

    function transfer(address _to, uint _value) isIcoFinished returns (bool) {
        return super.transfer(_to, _value);
    }

    function transferFrom(address _from, address _to, uint _value) isIcoFinished returns (bool) {
        return super.transferFrom(_from, _to, _value);
    }

    modifier isIcoOpen() {
        require(now >= startTimestamp);
        require(now <= (startTimestamp + durationSeconds) || totalRaised < minCap);
        require(totalRaised <= maxCap);
        _;
    }

    modifier isIcoFinished() {
        require(now >= startTimestamp);
        require(totalRaised >= maxCap || (now >= (startTimestamp + durationSeconds) && totalRaised >= minCap));
        _;
    }
}


texts:
I have four synced peer nodes running on two separate machines. Nodes 1-3 have been around since the beginning of the block chain and are all on one machine while Node 4 was just added around block 36000 and is on a separate machine.

Nodes 1 and 4 have open rpc ports and I am connecting to them through Metamask. When I run functions that use pastEvents, Node 4 responds noticeably faster than Node 1.

Why is this?
What could be causing Node 1 to return event data so slowly (much slower than Node 4) ?


texts: In case we have an interface written in a seperate .sol file how do we migrate it successfully?

texts:
HI consider i have 3 smart contracts A,B,C.
I have a separate file D.sol which is an interface used in all A,B and C.
What would the migration script look like for this project?


texts: What's reverted and not reverted during an Out of Gas exception?

texts:
A seemingly crucial question on EIP 158 was unanswered:

  Unless the empty accounts are deleted even in the case of an EVM
  exception, if that is the case would that not break the guarantee that
  EVM exceptions revert the state back as if the transaction was never
  made?

It seems this lead to the Nov 24 consensus security alert?

When a transaction encounters an Out of Gas (OOG) exception, some changes are reverted and some are not.  For example, contract storage changes are reverted, whereas the transaction itself is not reverted (it remains on the blockchain and the gas payment to the miner is made).  If the transaction deleting empty accounts runs OOG, the empty accounts should be brought back except for a "set of contexts involving out-of-gas calls to precompiled contracts".

What specifically are these contexts? Can this be explained?
What is the clear, complete list of conditions/changes that are reverted and not reverted during an Out of Gas exception?


texts: Elegant way to map web3.js error messages

texts:
when user's transaction fails before submitting to the blockchain, I want to know the failure reason, so I can give a better user experience.

for example if user rejects a transaction in Metamask, or if the transaction fails due to insufficient funds for gas. how can I detect that?

my current implementation is not great, and will break easily. is there more elegant way to do it?

return sendTransaction(txData).catch(err => {
    if (err.message.includes('User denied transaction') ||
        err.message.includes('Request has been rejected.') ||
        err.message.includes('transaction has been discarded') ||
        err.message.includes('Transaction not confirmed'))
        throw new Error('web3UserTxRejected');

    if (err.message.includes('nonce too low'))
        throw new Error('web3NonceTooLow');

    if (err.message.includes('nonce may not be larger than'))
        throw new Error('web3NonceTooHigh');

    if (err.message.includes('insufficient funds for gas'))
        throw new Error('web3InsufficientFundsForGas');

    if (err.message.includes('intrinsic gas too low'))
        throw new Error('web3GasTooLow');

    throw new Error(err);
});


texts: Can I add my own fields to JSON files in the keystore directory?

texts:
I need to add a few fields to JSON v3 wallet file, can I do it ? What is Ethereum's policy on this?

For example, to add account name I would do something like this:

{
    "address": "4c437d8f70dd161676010e8900016d23f5f5056a",
    "crypto": {
        "cipher": "aes-128-ctr",
        .... etc .....
     },
    "user_data": {
         "account_name":"All my life savings",
         ... etc ...
    }
}

so, basically , I would add a section to the JSON file called user_data where all the info about the account would go. In theory, doing this would be compatible with other wallets if the wallets are not strict about JSON format, so I guess it is doable. What do you think?


texts: How can I create a list of peers from my syncing geth node to manually paste into my non-syncing geth node using the admin.addPeer() command?

texts:
I have an Ethereum node that is not syncing to the Ethereum network. It is possible that there are some issues with the bootnodes -
refer to geth does not sync out of the box .

How can I easily create a list of peers from my syncing node so I can copy and paste a list of admin.addPeer(...) command into my non-syncing node?


texts: Parity 1.4.4: syncing stopped at some block (actually is very slow)

texts:
Not managed to find similar question or something useful with help of Google... I have two Ethereum nodes running based on Parity:

Here's the first one:

resurtm@resurtm-thinkpad:~$ screenfetch
                          ./+o+-       resurtm@resurtm-thinkpad
                  yyyyy- -yyyyyy+      OS: Ubuntu 16.04 xenial
               ://+//////-yyyyyyo      Kernel: x86_64 Linux 4.4.0-47-generic
           .++ .:/++++++/-.+sss/`      Uptime: 1d 1h 17m
         .:++o:  /++++++++/:--:/-      Packages: 1600
        o:+o+:++.`..```.-/oo+++++/     Shell: bash 4.3.46
       .:+o:+o/.          `+sssoo+/    CPU: Intel Core2 Duo CPU T7500 @ 2.201GHz
  .++/+:+oo+o:`             /sssooo.   RAM: 1572MiB / 7910MiB
 /+++//+:`oo+o               /::--:.
 \+/+o+++`o++o               ++////.
  .++.o+++oo+:`             /dddhhh.
       .+.o+oo:.          `oddhhhh+
        \+.++o+o``-````.:ohdhhhhh+
         `:o+++ `ohhhhhhhhyo++os:
           .o:`.syhhhhhhh/.oo++o`
               /osyyyyyyo++ooo+++/
                   ````` +oo+++o\:
                          `oo++.

resurtm@resurtm-thinkpad:~$ dpkg -l | grep parity
ii  parity                                      1.4.4                                         amd64        Ethereum network client by Ethcore

resurtm@resurtm-thinkpad:~$ apt show parity
Package: parity
Version: 1.4.4
Status: install ok installed
Priority: extra
Section: science
Source: parity
Maintainer: Ethcore <devops@ethcore.io>
Installed-Size: unknown
Homepage: https://ethcore.io
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.5
Vcs-Git: git://github.com/ethcore/parity.git
Vcs-Browser: https://github.com/ethcore/parity
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: Ethereum network client by Ethcore

Syncing stalled at this state:

http://i.imgur.com/92ThVXj.png

And here's my second node:

resurtm@resurtm-desktop:~$ screenfetch
         _,met$$$$$gg.           resurtm@resurtm-desktop
      ,g$$$$$$$$$$$$$$$P.        OS: Debian testing stretch
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 4.8.0-1-amd64
   ,$$P'              `$$$.      Uptime: 29m
  ',$$P       ,ggs.     `$$b:    Packages: 1704
  `d$$'     ,$P"'   .    $$$     Shell: bash 4.4.0
   $$P      d$'     ,    $$P     Resolution: 1920x1200
   $$:      $$.   -    ,d$$'     DE: XFCE
   $$\;      Y$b._   _,d$P'      WM: Xfwm4
   Y$$.    `.`"Y$$$$P"'          WM Theme: Default
   `$$b      "-.__               GTK Theme: Adwaita [GTK2]
    `Y$$                         Icon Theme: Tango
     `Y$$.                       Font: Sans 10
       `$$b.                     CPU: Intel Core i5 CPU 760 @ 2.801GHz
         `Y$$b.                  GPU: GeForce GT 640/PCIe/SSE2
            `"Y$b._              RAM: 3455MiB / 16041MiB
                `""""

resurtm@resurtm-desktop:~$ dpkg -l | grep parity
ii  parity                                 1.4.4                             amd64        Ethereum network client by Ethcore

resurtm@resurtm-desktop:~$ apt show parity
Package: parity
Version: 1.4.4
Status: install ok installed
Priority: extra
Section: science
Source: parity
Maintainer: Ethcore <devops@ethcore.io>
Installed-Size: unknown
Homepage: https://ethcore.io
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.5
Vcs-Git: git://github.com/ethcore/parity.git
Vcs-Browser: https://github.com/ethcore/parity
Download-Size: unknown
APT-Manual-Installed: yes
APT-Sources: /var/lib/dpkg/status
Description: Ethereum network client by Ethcore

So far so good on this node:

http://i.imgur.com/TjadT2x.png

The question is: what can I do to solve the stall issue at my first box? Parity is latest for the moment, cannot imagine what causes that.

I appreciate any help! ;-)

Thanks!


texts: Syntax: How do you require a string to be null (or anything but null)?

texts:
I want to make sure that when doSomething() is called, the string variable is always populated (that it can't be left blank):

    function doSomething (string hash) public {
        require(hash != null);
    }

Similarly, I want to make sure that when doSomethingElse() is called, the string is not already mapped to an address:

    mapping (string => address) public hashes;

    function doSomethingElse (string hash) public {
        require(hashes[hash] = null);
    }

I know null is not the correct syntax, but what is?


texts: Confusion over who should be the owner/administrator of a new instance of my smart contract?

texts:
I am working on a voting smart contract. I know I can set the owner for a smart contract. But I assumed that "role" was for the programmer of the smart contract so he can maintain control over important data structures (e.g. - preventing the improper deletion of certain users or user assets, etc.)

My current belief is that I would create and publish/migrate a new instance of my voting smart contract for each separate vote (e.g. - each new election, etc.), is that correct? If so, what is the normal best practice for assigning an administrator to the contract, someone that is not the smart contract programmer (myself) but the person who should be acting administrator for the current vote (i.e. - a particular instance of the smart contract that is managing one particular vote)? Should I make them the current owner of the smart contract instance when I create the new smart contract instance for the new vote?


texts: How msg.sender changes through relaying function calls?

texts:
I'm confused about how msg.sender changes through relaying function calls. I know that msg.sender sets to the caller(it should be me) address at first, but through the process, msg.sender can change to contract address. Like when one contract calls the function of the another contract, then the function of the another contract's msg.sender should be the first contract. Now, if like this,

contract example1 {
  function A() {
    print msg.sender; // just fake code to imagine it prints out the result
    example2.B();
  }
}

contract example2 {
  function B() {
    print msg.sender;
    C();
  }
  function C() { print msg.sender; }
}

If I call function A(), then it will print my address, and followed by the process, B() will print contract example1's address. Then is C() will print contract example1's address or contract example2's address?


texts: How to limit function access to certain frontend?

texts:
I've a function in my smartcontract, that pays out ETH to the sender. However it sgould be only callable from registered users on my website, regardless of their ETH-address.

I already tried to send a secret string as parameter, hash it and compare that to an array of hashes. But the problem is that an array of 1000 hashes is very expensive/impossible.
So I wonder if there's a better way to do that?
Would it maybe possible to generate unique secrets for each transaction, which all fit to ONE single "key" in the contract?

At the moment it's:

bytes32[] public hashedSubmitSecrets;

function requestMoney(string _submitSecret) {
   require (hashedSubmitSecrets[i] == keccak256(_submitSecret));
}

function addSubmitSecrets (bytes32[] _arrayOfHashedSecrets) onlyOwner {
      for (uint i = 0; i < _arrayOfHashedSecrets.length; i++) {
            hashedSubmitSecrets.push(_arrayOfHashedSecrets[i]);
        }
    }


texts:
I have an account in poloniex and i transferred 0.1 ETH to another account but it doesn't appear.
here are the images.


texts: Watched events not registering as expected

texts:
I have created a simple contract with one event. I use web3 via MetaMask to watch for these events, however I can see the transactions on Etherscan but the Javascript callback is not being fired for the new event.

Events that happened before page load I can get.

The contract is on Ropsten

pragma solidity ^0.4.18;

contract MyContract {
    address creator;
    event HasAccepted(address sender, bool isCreator);

    function MyContract ()
    public
    {
        creator = msg.sender;
    }

    function accept ()
    public
    {
        bool isCreator = msg.sender == creator;
        HasAccepted(msg.sender, isCreator);
    }
}

and associated web3 code below:

<html>
  <script>
    var contractAddr = "0x33743a345c0e20f556bf15d19ca12968c47ae4d8";
    var contractAbi = [{"constant":false,"inputs":[],"name":"accept","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"isCreator","type":"bool"}],"name":"HasAccepted","type":"event"}];

    function startApp() {
        var MyContract = web3.eth.contract(contractAbi);
        var contractInstance = MyContract.at(contractAddr);

        document.getElementById('acceptBtn').addEventListener('click', function(){
            contractInstance.accept({value: 0, gas: 210000}, console.log);
        });

        var event = contractInstance.HasAccepted(function(error, result){
            // Expect to log when click 'Run accept' button
            console.log("HasAccepted", error, result);
        });
    }

    window.addEventListener('load', function() {
      if (typeof web3 !== 'undefined') {
        window.web3 = new Web3(web3.currentProvider);
      }
      startApp();
    })
  </script>
  <body>
    <button type="button" id="acceptBtn">Run accept</button>
  </body>
</html>

I would expect that I would see output from the callback given to the 'HasAccepted' event.


texts: Halt chain to get balance of new wallet on Ropsten?

texts:
I am running through the voting dapp tutorial (https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-2-30b3d335aa1f) and am attempting to deploy to the Ropsten testnet. When I call

  web3.eth.getBalance('0xee865de6ebbbe517d079cf5effb274670284963e')

while running the chain on geth, I get this error

  Error: missing trie node 32004e17802c4fae5def997f9e5b641b4b8f25a4ca7c50d98e597cb7ece65e4a (path )
      at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
      at RequestManager.send (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/requestmanager.js:61:22)
      at Eth.send [as getBalance] (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/method.js:145:58)
      at evalmachine.:1:-52
      at ContextifyScript.Script.runInContext (vm.js:53:29)
      at Object.runInContext (vm.js:108:6)
      at TruffleInterpreter.interpret (/usr/local/lib/node_modules/truffle/lib/repl.js:136:17)
      at bound (domain.js:301:14)
      at REPLServer.runBound [as eval] (domain.js:314:12)
      at REPLServer.onLine (repl.js:433:10)

And if I halt geth and the chain, I get back the correct response.

  { [String: '0'] s: 1, e: 0, c: [ 0 ] }

Does anyone understand why this is, and perhaps answer if I need to have the chain up to date and running on my machine in order to interact with it?

Thanks so much!


texts: Is there a way to generate a mnemonic recovery phrase for an account on a private Ethereum chain?

texts: I have created a private Ethereum chain (via a genesis.json file, etc.). I would like to be able to use Truffle's HD Wallet Provider, and I need a mnemonic recovery phrase to do so. Is there a way to set this up for accounts on a private Ethereum chain?


texts: Solidity 0.5.x - make address array payable

texts:
I'm trying to write a contract that uses an address[] array which should contain payable addresses. But apparently creating a payable address array doesn't work in solidity 0.5.x.

All I'm trying to do is to run a loop that transfers funds to each address in the array like this:

address[] users;
// set users
...
for (uint i = 0; i < users.length; i++){
  users[i].transfer(<some_value>);
}

My super dumb solution would be to use a proxy mapping to get a payable address. It would look like this and does actually compile.

address[] users;
mapping(address => address payable) proxy;
// set users and proxy
...
for (uint i = 0; i < users.length; i++) {
   address payable u = proxy[users[i]];
   u.transfer(<some_value>);
}

Obviously this is pretty dumb. Is there a way to make an address array payable?


texts: Dropped transaction can be automatically broadcasted on network by specified condition?

texts:
I have a transaction with nonce #30, because of low gas price this tx is dropped while I checked on Etherscan (case #1 dropped transaction not dropped and replaced #2 ref). Before this transaction is dropped, I have also checked my 2 physical node geth, both of them response full detail of it by using eth_getTransactionByHash. But after dropped status for a period time I recheck again, eth_getTransactionByHash returned not found this transaction and also null receipt returned by eth_getTransactionReceipt.
Next 3 days, my friend does not notice this case and create new transaction with nonce #31, cause I have never met this stituation before, currently my program will increase each nonce after a transaction broadcasted on network. Normally, I should create a new transaction with nonce #30 cause previous tx #30 is dropped and this nonce is not filled. But when I create transaction with nonce #31, previous dropped #30 transaction is automatically rebroadcasted (not by anyone in my team) and status changed from dropped to pending then became success for a short time because of network fee reducetion.

I have tried to read ref carefully but not found dropped transaction can be automatically rebroadcasted, I have also searched but not found any related information conflict to this case. I hope someone who have faced this case can explain and confirm it, thanks so much.

Previous dropped transaction nonce #30:

Now it becomes success transaction none #30 same hash:
https://etherscan.io/tx/0x97e3e38fc5136f46205c29ffb6a297fb98728b39b43b5246fff8e20650076cb0

Transaction nonce #31:

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


texts: Sample code in ethers.js to send raw transaction and to sign transaction

texts: Is there any sample code in ethers.js to send raw transaction and to sign transactions?


texts: Signing A Raw transaction on contract function

texts:
I'm having some trouble signing a transaction on a contract function. First I build the transaction:

transaction = contract_instance.functions.buy().buildTransaction(
            {
                'nonce': w3.eth.getTransactionCount(w3.eth.accounts[1]) + 1,
                'from': w3.eth.accounts[1],
                'gas': 70000000,
                'gasPrice': 18000000000,
                'value': _value,
                'chainId': 10
            }
        )

Then I decrypt:

key = decrypt_account(address=w3.eth.accounts[1], passphrase='This')

then I sign:

signed = w3.eth.account.signTransaction(transaction, key)

then I send:

w3.eth.sendRawTransaction(signed.rawTransaction)

The problem comes when the function in the contract is called: buy()

function buy() isRunning validAddress payable public {
    uint256 amount = msg.value;
    amount = amount.div(buyPrice);
    amount = amount.mul(10**18);
    _transfer(this, msg.sender, amount);
    Buy(this, msg.sender, amount, buyPrice);
}

The tx_hash response I get is:

AttributeDict({'to': '0x6d3921d65b2127bF42035CF6E39B9c77d44443Eb', 'gasPrice': 21000000000, 'value': 1000000000000000000, 'hash': HexBytes('0xfc6ad0477afd00a5d9b44917db4e42e88437edee6902c0c963061d4453a51d89'), 's': HexBytes('0x7295aa1a2322d96e12ee05464b4502764873ea6167c87ac9641ee358335538cd'), 'from': '0xcE4f50A654c8cd561207725f8F0BF5801c2c9613', 'blockHash': HexBytes('0x0000000000000000000000000000000000000000000000000000000000000000'), 'r': HexBytes('0xf7040b0bf0cc13c6f469cc623603422031cdc7f1a1c2119f6e0844d12aafcd3c'), 'blockNumber': None, 'transactionIndex': 0, 'nonce': 3, 'gas': 6000000000, 'v': 56, 'input': '0xa6f2ae3a'})

As we can see the block hash looks empty and the blockNumber is None. Thats normally what I get when there was an error.

Now if I dont use the sign method and I just unlock the account:

I get a tx_hash response of:

AttributeDict({'hash': HexBytes('0xfef1bda5fc01e0ee937507cd79f911fc8c96b9819708ce114f353d8ea3ad2495'), 'input': '0xa6f2ae3a', 'gasPrice': 18000000000, 'from': '0xcE4f50A654c8cd561207725f8F0BF5801c2c9613', 'to': '0x6d3921d65b2127bF42035CF6E39B9c77d44443Eb', 'v': 27, 'gas': 700000, 'value': 1000000000000000000, 'nonce': 1, 'transactionIndex': 0, 'r': HexBytes('0x725fa7d26c3abf3e99c684bff8ec45133983635c1440d833ed66728aa67a037d'), 'blockNumber': 40, 's': HexBytes('0x720a5bcad1b8d71cf60031e838aedd32dc2b9b82d40cd52ab682a168ff50fdfa'), 'blockHash': HexBytes('0xa2292df37f6d7348c5cd6057f672a6b7235539f47b68ea0af7ed70f39dca71b9')})

So its without a doubt something with the signing and sending of the transaction.

Just so you can see how I call the transaction if I unlock:

contract_instance.functions.buy().transact({'from': user, 'gas': 700000, 'value': _value})

I'm really stuck on this one. Also, I'm running a test network chain if that matters.

{
"parentHash":  "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0xf2419003e9058198c71e42bb35f94b4452fadfa8",
"extraData": "0x686f727365",
"config": {
  "daoForkBlock": 0,
  "daoForSupport": true,
  "homesteadBlock": 0
},
"timestamp": "0x0",
"mixhash":  "0x0000000000000000000000000000000000000000000000000000000000000000",
"nonce": "0xdeadbeefdeadbeef",
"alloc": {
  "0x3d48e3a6a661e5dc56db193e49d484e79c927652": {
    "balance": "1000000000000000000000000000000"
  }
},
"gasLimit": "0x3b62df92707000",
"difficulty": "0x01"
}


texts: Using web3.py, I get a key error when connecting to a remote server with 3 nodes running (autoconnect works fine)

texts:
I have a web3.py project that is successfully performing basic tasks (read from blockchain, send tx, process data, etc.). It is connected to a remote server that is running an ETH node, a Rinkeby node, and an ETC node. The project works perfectly using the web3.py auto detection.

When I switch to Web3(Web3.HTTPProvider("http://127.0.0.1:8545")), I am having an issue only when I try to send a transaction. I can use this HTTPProvider and still read all the correct data, such as addresses, balances, nonce, etc. The only thing I error out on is when I run sendTranscation(). The error I am receiving is:

{'code': -32000, 'message': 'no key for given address or file'}

I assume this has something do with my key, but I cannot imagine what. The directory in my server is completely normal (~/.ethereum/keystore, ~/.ethereum/testnet/keystore, and ~/ethereum-classic/keystore). This doesn't totally make sense, though, because I can still read the nonce.

I am connecting to the server via SSH and the ~/.ssh/config file.

Do I need to point my connection to the correct keystore location? If so where in the stack do I do this?


texts: Going through the solidity style guide and wondered if there were any recommended libraries / plug ins that format solidity code like go fmt?


texts: If someone gets my geth keystore files, can they spend my ETH without knowing my password(s)?

texts: I always assumed so, since geth requires a new password for every account, but just want to be sure.


texts: How does contract of dapp figure out who buyer is?

texts:
How does contract of dapp(eg. market place) figure out who buyer is?

If buyer wants to purchase servive(or product) at certain dapp, he should transfer tokens to contract address of the dapp.

At this point, how does contract figure out buyer? does it check msg.sender? or address sent tokens? I am asking it because in case user purchase via approve+transferfrom, msg.sender is different from address sent tokens.

Plesase consider that i am not developer.


texts: Is a block number unique or does it change if the block becomes uncle? Does the transaction hash include a block hash as input?

texts:
Is a block number unique or do I need to save block hash to identify a block?
Does transaction hash include a block hash as input?


texts: Private ledgers on a Ethereum Blockchain Network

texts:
We are exploring one use case to connect a million customers with a bank. Since customers' transactions should be private to them, we want to understand whether we can have concept of private ledger on the customer nodes.

The transaction must be added only to the ledgers of the transacting nodes.

So for instance we have two customers Alice and Bob. Alice transacts(Debit) using the bank's system for $5 and Bob transacts (Debit) using bank's system for $10.

So the ledgers should look like.

Alice: Debit $5 (Transaction on Block)
Bob: Debit $10 (Transaction on Block)

Bank: Debit $5
      Debit $10 (Shows both transactions on the Bank's Node)


texts: Imported accounts in metamask are not visible using web3

texts:
I have a node in ropsten network and created 3 accounts say a,b,c  using geth. Connected metamask with ropsten network and created other account 'd' using metamask and imported accounts a,b and c by passing JSON file. But account 'd' was not shown with eth.accounts in geth console.

When I connected metmask with nodejs by :

var Web3 = require('web3');

window.addEventListener('load', function() {

window.web3 = new Web3(web3.currentProvider)

  var ETH_CLIENT = window.web3
  web3.eth.getAccounts(function(error, accounts) {
  if (error) {
  console.log(error);
  }

console.log('account0 ='+accounts[0]);

console.log('account1 = '+accounts[1]);
});
})

accounts[0] shows account address of 'd'.
accounts[1] is 'undefined'.

How to get imported accounts from metamask in nodejs?

And why account 'd' is not visible with command 'eth.accounts' in geth console? I have a running ropsten node at port 8545. But accounts 'a' ,'b' and'c' was not visible in metamask when I connected it. I had to import accounts..

Help will be appreciated :)


texts:
contract Bar{

    struct Foo{
        uint x;
    }
    mapping(uint => Foo[]) foo;

    function add(uint id, uint _x) public {
        foo[id].push(Foo(_x));
    }

    function get(uint id, uint index) public returns(uint){
        return foo[id][index].x;
    }
}

I'm trying to call all the index value. Like there will be return function which will return all the total index value.

And If suppose I wish to return the last 10 data of address ID + Index value. How would I call that.

Because I need to enter the index value, but if someone do not know the index value. Then it will be difficult.


texts: NOOB Error : Transaction mined but execution failed

texts:
i´m learning Solidity now, and i saw this code on web but when i try to use the method "Deposito" i receive a error. Someone knows what's that ? (PS.: I try to put the value but every time i chose another value different from 0 don't work).

I was using the remix to test code.

pragma solidity ^0.4.2;

CODE:

mapping (address => uint) private saldos;

function deposito() public returns (uint) {
    saldos[msg.sender] += msg.value;

    // Sem necessidade de "this." ou "self." para variáveis de estado
    // todos as variáveis são inciadas com seu valor default

    LogRealizacaoDeDeposito(msg.sender, msg.value); // dispara evento

    return saldos[msg.sender];
}


texts: How can I call selfdestruct when it is located in a constructor and not in the ABI of my contract?

texts:
I am reading some tutorials and while planning to deploy test contract on ropsten I have something like this:

pragma solidity 0.5.1;

contract destroy {
    constructor(address payable receiver) public payable {
        selfdestruct(receiver);
    }
}

contract Test {

     function() external payable { }

    function transfer(address _to, uint256 _amount) external {
       ///
    }

}

Getting "transfer" from the abi is quite easy. But what to do with "contract destroy"? Not only is this another contract but also everything is in the constructor? Is there a way to call this from web3 python/js or at least via myetherwallet? 10x!


texts: How to write smart contract to check deployed owner is intitiating the contract or not, everytime?

texts:
I want to write a smart contract where it would check it is owner of the deployed contract is trying to instantiate the contract or not. And by doing to i want to allow only the owner to call smart contract. How can i do so?

pragma solidity ^0.5.0;

contract Storage {
  string Hash;

  function set(string memory x) public {
    Hash = x;
  }

  function get() public view returns (string memory) {
    return Hash;
  }
}

This is my smart contract where i am using setter and getter method.


texts: Storing and Updating an array in a smart contract (for creating permissioned networks and updating members)

texts:
Can I define a smart contract including a dynamic array that I can update its content later?

precisely,I have some IoT(Internet of things) nodes sharing the received data from sensors with each others. I partitioned them to 2 permissioned networks: Network 1 includes: X,Y,Z nodes trusting each other. Network 2 includes: M,N,O nodes trusting each other.

Can I define a smart contract to each network containing the list of nodes (their PK) in order to create permissioned networks that enables nodes to accept the data of only its own peers in own network?

For instance, smart contract 1 includes the PK of X,Y,Z and enable them share data with each other. smart contract 2 includes the PK of M,N,O.

Due to some conditions, for changing these partitions, for example, moving node Z from network 1 to network 2.

Can I update arrays including the list of members in smart contracts 1 and 2.

That is, the list of new smart contract 1 is updated to X,Y,

and new smart contract 2 is M,N,O and plus new node Z can share data with network 2 members. Regards


texts: Is there a way to generate ethereum paper wallets?

texts: Is it possible to store ether on paper wallets or generate printable private keys offline somehow?


texts:
I am using debug_traceTransaction API from Geth node. (ropsten testnet)
It works well but sometimes the response gives me
{code=-32000, message=transaction c6f08309fa47a817b97a6eae3db04b3818fd7c12296b92098a0fa7c42de4ded4 not found}

even the transaction is in the block, but gives me right response when retry the request.
My request is like this.
{
    "jsonrpc" : "2.0",
    "id" : 0,
    "method" : "debug_traceTransaction",
    "params" : ["0xc6f08309fa47a817b97a6eae3db04b3818fd7c12296b92098a0fa7c42de4ded4", {"tracer": "callTracer"}]
}

Any ideas why it gives not found error..?


texts: Why does the transfer function need to have an amount parameter?

texts:
The following function must be implemented for a token to be ERC-20 compliant:

    // Transfer the balance from owner's account to another account
15     function transfer(address _to, uint256 _amount) returns (bool success) {
16         if (balances[msg.sender] >= _amount
17             && _amount > 0
18             && balances[_to] + _amount > balances[_to]) {
19             balances[msg.sender] -= _amount;
20             balances[_to] += _amount;
21             return true;
22         } else {
23             return false;
24         }
25     }

Notice that one of the parameters is the _amount.  That's the amount that the user specifies. However, isn't one of the internal properties of a transaction the msg.value parameter? That means that the _amount variable is redundant, and a code smell.


texts: Is it safe to delete .ethash folder and its contents from system?

texts:
As a first foray in to Ethereum I started downloading the Ethereum Wallet for OSX from https://www.ethereum.org/.  When I realised how long it was going to take to download the blockchain I killed the download and removed the application.  Looking around my Mac I see that I have a directory ~/.ethash, and that it has a file named full-R23-0000000000000000.  This file is about 1GB.

Am I right in thinking that this is the blockchain (or the part that I downloaded, at least)?  And can I safely delete it if I don't want to use Ethereum Wallet on this machine?