texts: Running ethereumjs/testrpc from a Docker container

texts:
I'm taking a stab at creating a set-up where I have a Docker container from which I run ethereumjs/testrpc (an Ethereum testing environment) and another Docker container running an Express app. I then wanted to be able to connect the two and, let's say, show account balances in my Express app.

My Dockerfile is

FROM node:boron

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# RUN npm install -g ethereumjs-testrpc --> tested adding this line
# did not work either

# Bundle app source
COPY . /usr/src/app

EXPOSE 3000

CMD [ "npm", "start" ]

and docker-compose looks as follows

version: "2.0"
services:
  web:
    build: .
    volumes:
      - .:/usr/src/app
    ports:
      - "3000:3000"
    links:
      - mongo
  mongo:
    image: mongo
    ports:
      - "27017:27017"
  ethereum:
    image: ethereumjs/testrpc:latest

The error output I get looks like

web_1       | module.js:471
web_1       |     throw err;
web_1       |     ^
web_1       |
web_1       | Error: Cannot find module 'ethereumjs-testrpc'
web_1       |     at Function.Module._resolveFilename (module.js:469:15)
web_1       |     at Function.Module._load (module.js:417:25)
web_1       |     at Module.require (module.js:497:17)
web_1       |     at require (internal/module.js:20:19)
web_1       |     at Object.<anonymous> (/usr/src/app/app.js:7:15)
web_1       |     at Module._compile (module.js:570:32)
web_1       |     at Object.Module._extensions..js (module.js:579:10)
web_1       |     at Module.load (module.js:487:32)
web_1       |     at tryModuleLoad (module.js:446:12)
web_1       |     at Function.Module._load (module.js:438:3)

Lastly, the beginning of my app.js is

var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var TestRPC = require("ethereumjs-testrpc"); // these two lines are throwing
web3.setProvider(TestRPC.provider()); // the errors

I'm not understanding how to fix this and have tried different things, none of which seem to work. Any pointers in the right direction would be much appreciated!


texts: What are the difference between _from, _spender and _to address in Ethereum in Solidity?

texts:
What are the difference between _from, _spender and _to address in these functions below?

function transferFrom(address _from, address _to, uint256 _value) public{/*...*/}
function approve(address _spender, uint256 _value) public{/*...*/}


texts: Blocks can't contain more than 81 transactions

texts:
I'm building a private blockchain with Parity clients. For performance testing, I'm submitting many identical transactions. One of the nodes has a GPU miner attached. There are 2 issues I cannot explain and hope to get some help from you:

A block never has more than 81 transactions, although gas limit allows for many more. Namely, every transaction consumes exactly 21000 gas, and every full block consumes 1701000 gas, although its gas limit is 8Mgas.
Every other block contains zero transactions.

UPDATE: Here are my Ethash parameters:

    "Ethash": {
      "params": {
        "minimumDifficulty": "0x10000",
        "difficultyBoundDivisor": "0x800",
        "durationLimit": "0xd",
        "blockReward": {
          "0x0": "0x1bc16d674ec80000"
        },
        "bombDefuseTransition": "0",
        "homesteadTransition": "0x0",
        "eip100bTransition": "0x0"
      }
    }


texts: Couldn't get any accounts!, Ethereum client is not configured correctly

texts:
I'm running testrpc on the default port 7545.

I run truffle console and test with: web3.eth.getAccounts().then( function (result) { return result[0] });

This works fine. According to docs the getAccounts() method only works if the account is connected properly with ganache, so it seems I should be all set.

when I enable MetaMask in crome and setup to required accounts, localhost web page is showing loading evin i had properly setup MetaMask as shown in image.

But when I dissabled the MetaMask, It is showing proper output with account at index 0 as shown below:

truffle version
Truffle v5.1.26 (core: 5.1.26)
Solidity - 0.4.25 (solc-js)
Node v12.13.0
Web3.js v1.2.1

Please help me getting out of this.


texts: Trie, Radix Trie, Patricia and Merkle Patricia Trie

texts:
Can you explain to me the main differences between these 4 tries?

Thank you


texts:
Hey guys so I have been running a few projects just for fun, not keeping tokens for myself, burning for trust etc but I would like to take a 1% fee so I can at least get something so in the below example if I change the tax fee from 4 to 5 but leave the max tax amount how it is, will this return the extra 1% to my dev wallet? if not, what is the easiest way in your opinion to implement it?
contract Example is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;

mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;

mapping (address => bool) private _isExcludedFromFee;

mapping (address => bool) private _isExcluded;
address[] private _excluded;

uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;

string private _name = "Example";
string private _symbol = "ExampleTicker";
uint8 private _decimals = 9;

uint256 public _taxFee = 5;
uint256 private _previousTaxFee = _taxFee;

uint256 public _liquidityFee = 5;
uint256 private _previousLiquidityFee = _liquidityFee;

IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;

bool inSwapAndLiquify;
bool public swapAndLiquifyEnabled = true;

uint256 public _maxTxAmount = 1000000000 * 10**6 * 10**9;
uint256 private numTokensSellToAddToLiquidity = 500000 * 10**6 * 10**9;

event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapAndLiquify(
    uint256 tokensSwapped,
    uint256 ethReceived,
    uint256 tokensIntoLiqudity


texts:
Is it possible to mine Ethereum on an Android device?

I know it may be inefficient, but still I want to see if I can develop and app that mines Ethereum on Android.
Thanks in advance.


texts: What are the most common attack patterns on a Smart Contract?

texts:
i'm new to Solidity.
After writing my first smart contract im fairly concerned about it's security, once deployed to the MainNet. What are the most important things i should check within my code? Also are there any resources where i can learn about attack patterns?


texts: How to make minting tokens not cost any ether for end-user?

texts:
I am extending openzeppeling ERC20 implementation contract. Currently, I have a constructor that does nothing but set the name and symbol, but I have a function that mints tokens:
  function mintTokensOnIntroCourseCompletion() external {
    _mint(msg.sender, 100);
  }

This mints tokens with no problem, but the problem is that it costs the user ether to call this function since _mint writes data to the blockchain. Obviously, I don't want the user to have to pay ether to get tokens. How can I make this happen? And since data is being written, who will pay the ether? Is there a way to make the contract do so?


texts: Why isn't the information in transaction receipt stored in the transaction itself?

texts:
The yellow paper says:

  Transaction Receipt. In order to encode information
  about a transaction concerning which it may be useful
  to form a zero-knowledge proof, or index and search, we
  encode a receipt of each transaction containing certain in-
  formation from its execution.

Why isn't this information stored in the transaction itself? that way one can save one more field in the block header. So what was the design philosophy behind that?


texts:
I want to use a deployed contract that has been deployed through Mist using byte code.

This is how I try to get the contract using a testnet:

import contract from 'truffle-contract';
import Web3 from 'web3';

if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}

const existingContract = new web3.eth.Contract([
    {
        "constant": true,
        "inputs": [],
        "name": "getNetworkAddress",
        "outputs": [
            {
                "name": "addr",
                "type": "address"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, ...
], "0x375b2cfB88c3732a14f2AbDD55c561E48c3ff960", { // contract address
    from: '0x749707e9327bc87fd6710de26334bd7003ca15b1', // coinbase
    gasPrice: '20000000000',
    gas: 5000000
});

existingContract.options.data = '0x6060604052...'; // byte code

const test = contract(existingContract);
test.setProvider(web3.currentProvider);
test.deployed().then((result) => {
    console.log({result});
    console.log(result.getNetworkAddress.call());
});

This gives the following error:

  Error: Contract has not been deployed to detected network (network/artifact mismatch)

What am I missing?


texts: Truffle. How to link deployed library by address during migration?

texts:
For now I use this code to link library during truffle migration:

deployer.deploy(SafeMathLibExt);
deployer.link(SafeMathLibExt, [CrowdsaleTokenExt]);
deployer.deploy(CrowdsaleTokenExt);

This code deploys library each time and I don't like it. I want to deploy library only once and then always use it. So I want something like that (pseudo code):

const library = deployer.getLibrary(libraryAddress);
deployer.link(library, [CrowdsaleTokenExt]);
deployer.deploy(CrowdsaleTokenExt);

is it possible to achieve in truffle?


texts:
I'm lost, does anyone understand this code?
        assembly {
            success := staticcall(sub(gas(), 2000), 7, input, 0x80, r, 0x60)
            // Use "invalid" to make gas estimation work
            switch success case 0 { invalid() }
        }


texts: EthTx adapter won't respond in Chainlink job, fails with "transaction reverted on-chain"

texts:
We're using the standard truffle box (https://github.com/smartcontractkit/box) to deploy Chainlink contract ($LINK definition, Oracle, sample end-user contract, etc) on a private Ethereum testnet.
Everything works, as in I can trigger jobs from smart contract calls on-chain, unless my job spec has ends with "EthTx" adapter. If I end my job with an "EthTx" adapter, the task will fail with the only error being "transaction reverted on-chain".
My Oracle ETH accounts are well-funded, so lack of gas for running the transactions isn't an issue. Also, all the other adapters work without failing...so it's not a problem with the HTTP endpoint being down, path being wrong, or casting the wrong types. What's going on?


texts: Truffle: Creating a single ABI file if contracts are in separate .sol files?

texts: I am building a project which is divided into separate .sol files, one per contract or interface. The tutorial shows a single file cryptozombies_abi.js which appears to me to be something like the json of all the separate of files found in the build folder after the compile concatenated but I am not sure. My question is, is there a way to create a single ABI from multiple sol files -- I have attempted with no success the --abi option of truffle compile which does not fail but also does not produce one large ABI -- it does produce the json still (which I am guessing are in fact ABIs for each sol file).


texts: How can I connect to geth by IPC on nodejs?

texts:
This this the command line i have used to get geth running.

geth ipc --ipcapi "admin,db,eth,debug,miner,net,shh,txpool,personal,web3" --ipcpath "/root/.ethereum_experiment/geth.ipc"

so from node js how to connect to this geth client,
before this i was doing rpc and connected using http providers but i want the connection over IPC not over RPC.


texts: Ether scan api, compute balance on the date

texts:
I need calcualete balance on the date to acconut, but web3 balance and etherscan.com api is missmath. How correct to calculate balance from the available data of api.

const web3 = new Web3("https://ropsten.infura.io/erKFM1jCovzvFHE1wBah");

BigNumber.config({ ERRORS: false });

const url = "http://ropsten.etherscan.io/api?";
const key = "apikey=HJ583R13XWNWUZVYB1H8J7XVGRDKEPJK9U";
const address = "0x5360486ef76c4c857675c8212f885f7757510d9f";

axios.get(`${url}module=account&action=txlist&address=${address}&startblock=0&endblock=99999999&sort=asc&${key}`)
.then(res => {
  const result = res.data.result;

  const input = [];
  const output = [];
  let balance = new BigNumber(0);

  result.forEach(item => {
    const value = new BigNumber(item.value);
    const gasUsed = +item.gasUsed;
    const gasPrice = +item.gasPrice;
    const cumGasUsed = +item.cumulativeGasUsed;

    if(item.isError === "0" && item.txreceipt_status !== "0") {
      if(item.to === address) {
        input.push({
          value: value,
          gasUsed: 0,
          time: moment.unix(item.timeStamp).format("DD-MM-YYYY").toString(),
        });

        balance = balance.plus(value);
      }
      if(item.from === address) {
        output.push({
          value: value,
          gasUsed: gasUsed,
          time: moment.unix(item.timeStamp).format("DD-MM-YYYY").toString(),
        });

        balance = balance.minus(value);
        balance = balance.minus(gasUsed * gasPrice)
      }
      if(item.from === item.to) {
        console.log("self", item.value);
      }
    }
  });
  console.log("api balance", web3.utils.fromWei(balance.toString(), "ether"));
  web3.eth.getBalance(address)
  .then(balance => console.log("web3 balance", web3.utils.fromWei(balance, "ether")));
})
.catch(console.log);


texts: How to upgrade contract so that solidity v0.5.0 can be used?

texts:
I tried to choose the v0.5.0 version of the solidity compiler recently, and found some errors when compiling the code. Can anyone tell me how to fix them? Thanks a lot!

transfer

convert

----------------------update-----------------------

Alright, I found the answer in the docs of solidity. See below:


texts: Is there any testnet faucet for ETC Ethereum Classic Coin?

texts: Not able to get testing ETC from available faucet https://etcfaucet.info/, is there any other faucet or way to get ETC for tesing?


texts: Not able to interact with Ganache-cli: "-bash: ganache-cli: command not found"

texts:
I've already installed ganache-cli with sudo npm install -g ganache-cli on my MacOS but I am not able to interact with it through my terminal.
I always get the error: -bash: ganache-cli: command not found.
Maybe it isn't installed on the right PATH?
Would be glad for help. The normal version of Ganache is working properly on my computer, but with that, I cannot fork the blockchain.


texts: Approve step in DAO refund - Error: exceeds block gas limit

texts:
I'm following the steps from this URL: https://theethereum.wiki/w/index.php/The_DAO_Refunds#How_Do_I_Withdraw_The_DAO_ETH_Refund_Using_Go_Ethereum.3F

"How Do I Withdraw The DAO ETH Refund Using Go Ethereum?"

Specifically this line right here is causing the error: var approve = theDAO.approve(theDAOWithdrawalAddress, theDAO.balanceOf(account), {from: account});

Is there a way to adjust the instructions in the above link to lower the block gas limit or..?


texts: P2P file sharing nodes using blockchain?

texts:
I want to make a p2p file sharing program where there are hosts (nodes) and renters. Files are stored on the hosts' PCs. I could just have a central server providing the lookup information as to which files are on which nodes, but I want it to be decentralized.

So, would it be possible to store that metadata in the Ethereum blockchain, maybe like a Decentralized Hash Table? I just need a way to be able to look up other nodes and upload and download to them (all P2P) without using a central server to handle the lookup and everything, I need it to be decentralized.

Or, if there's a different/better angle I could be tackling this problem, please let me know. Thanks :)


texts: How to use Web3.WebsocketProvider for continuously receiving the last block from own Node in Python

texts:
I use python 3.7 and own Node.
So i want to receiving every last block from own Node immediately after it was mined.
from web3 import Web3

WEB3_WS_URI = 'ws://node_url:8546'
w3 = Web3(Web3.WebsocketProvider(WEB3_WS_URI))

After that how i should use w3 for establish connection to receive every new block with transactions immediately after it was mined?
I can use:
def run():
    while True:
        last_block = w3.eth.block_number
        print(last_block)
        time.sleep(45)

but i'm sticking to my own time interval of 45 sec which is not very good because the real interval before to emerge new block can be more or lees. I need get new block only after new event was done - block was mined and ready for parce.


texts: Is it possible to fake contract owner address?

texts:
this link talks about contract visibility and accessibility in the blockchain.
Solidity functions - private visibility

So if I use the keyword "onlyOwner" only the owner can call the function?

Is it possibile to fake the sending address of the owner or the blockchain nature already prevents it?


texts:
How can I have my customers to pay the custom tokens to my dapp by using MetaMask?When I try on this, I couldn't see any options I could choose the custom ERC20 token but only the Ether.
Please advice.


texts:
I'm trying to use convert in Vyper but get the following error:
vyper.exceptions.TypeMismatch: Expecting one of ('num_literal', 'int128', 'int256', 'bytes32', 'Bytes', 'address', 'bool', 'decimal') for argument 1 of convert
def forLoop() -> (uint256):
    x: uint256 = 0
    for i in [1, 2, 3]:
        x += convert(i, uint256)
    return x


texts:
At some point in my contract I have a public, not Constant function that has more than 16 arguments (24 to be exact). I'm getting an error saying Stack too deep. Try removing local variables

I can't split the function into 2. This would result in 2 transactions, which would not work for what I want to do.

My idea was to pass in a dynamic-size byte array with all of the arguments, and then parse thru that array, extract each argument and do the proper type casting. However, I'm struggling with the implementation.

Is there a simpler way to do this? This seems like a problem that other people would run into.
I have thought of passing in a big struct, but I understand you can't call a function externally with internal types.


texts: Deliberate Slashing: Don't slashing and leaking incentivize DDOS attacks on smaller nodes? Won't this centralize POS more than POW, even?

texts:
In Ethereum's proposed proof-of-stake algorithm (POS):

A traditional node operator can't host a node themselves (e.g. on a home network), someone could just DDOS their node to bring them offline. This is only a problem in slashing (not POW) because it leads to a loss of funds (see later comment on this). So, a large percentage of nodes will likely be hosted on one of 3-5 cloud service providers. [These are the nodes needed for safe decentralization.]
Who would have the incentive to DDOS other nodes? Those with network resources, perhaps only those with the resources to have non-traditional DDOS protections on hardware outside these 3-5 cloud service providers. [These are multiple nodes controlled by one entity, like how Bitmain operates]

Are financial incentives everything? If yes, then this is a very real attack vector.

The owner of more resourceful nodes in #2 can just DDOS the ports of nodes hosted on one of these cloud service providers in #1. When network nodes drop offline for a time period, each node loses ~X% of their shares. It might be that the attacks are slow, such that only 0.5% of the network nodes are DDOSed offline per month.  One prolonged DDOS attack could be enough to wipe out a node operator's yearly POS profits, and stop each of these operators from wanting to go back online. Over time, the coins of #2 become more valuable, and as more operators in #1 decide not to stake, so do #2's returns in proof-of-stake. So, the conclusion is that there is really a tremendous incentive for those with resources (#2) to DDOS nodes that actually decentralize the network (#1). I call this attack vector deliberate slashing.

In proof-of-work, the financial cost of custom ASICs is actually quite high. On the contrary, a DDOS attack on a POS node (deliberate slash) is cheap. Any POS algo with slashing included is at risk.

The part about nodes being incentivized to run on a cloud service provider is also significant. It substantially increases the insider threat risk for something to go wrong versus running on your own hardware. Because the risk of a deliberate slash doesn't require access to the OS, there are probably nuanced ways to affect a large number of nodes in this manner that may not exactly be considered a "DDOS attack". More concretely, it requires paying for markups on bandwidth costs that may not be there if you could safely run a POS node from home, giving those in #2 even more power.

Is it possible to answer this question without "Whataboutism"? Let's not get tribal and compare this only to other coins / consensus algorithms. Please stick to the engineering problem outlined here. The POS component of consensus is actually more centralized than the POW component because deliberate slashing is a much cheaper attack vector than building an ASIC -- but theoretically, just being more decentralized than POW wouldn't be enough anyway. If Ethereum switched to a POS algorithm without slashing, all these concerns wouldn't be valid.

I am not an expert in cryptocurrency or network stuff. But based on what little I know about peer-to-peer networks, this has to be something that was considered by the Ethereum powers-that-be. I.e., Joe Lubin's Infura and Etherscan.io. Is there a mechanism to prevent deliberate slashing?

EDIT: These concerns were actually brought up 12 months ago as well: https://www.reddit.com/r/ethereum/comments/7nkwzn/what_is_the_punishment_for_a_validator_node_being/ds36kei

Also, see this post regarding how offline nodes (like those that have been DDOS'd) may generate Uncles leading to a slashing condition: Casper slashes nodes with poor network connection?
and also:

What are the impacts of the Ethereum pre-sale, pyramidal wealth distribution, and mysterious lack of concern within a decentralized financial system?

How much control does Consensys have over Ethereum, and how does this affect Ethereum's decentralization?


texts:
I am creating basic peer-to-peer ETH exchange on running geth full node, and can't find out how to make transactions inside node, from one account to another.

Is it even possible to transfer funds between account wallets (without fees) inside full node ? Maybe I should create one account with lots of wallet addresses and do virtual exchange ?

Any help appreciated.


texts: Determine current stage in smart contract

texts:
Suppose that i have stages with date range and discount as follow.

stage1 -> 2019-01-01 - 2019-02-02 -> 40% discount
stage2 -> 2019-03-03 - 2019-04-04 -> 30% discount
stage3 -> 2019-05-05 - 2019-06-06 -> 20% discount

How can i check that the token is mintable at current date.
Note:
- might have gap date during each stage
- no looping as it require high gas cost
- no manual set minting stage by owner
- logic must be implemented inside smart contract only (no external oracle to determine current stage)

I couldn't find a way that satisfy the 4 condition above.
But this seems to be a very common use case in ico.
Hope someone can enlighten me on this.

struct stage {
  uint256 startDate;
  uint256 endDate;
  uint8 discount;
}

mapping(bytes32 => stage) stageMap;

function getCurrentStage() private view returns (bytes32) {
   // what logic should be done here?
   // Note:
   // No storing the entire stages in array and loop through it to compare the date
}


texts: What's the difference between the two ways that contract B interacts with contract A?

texts:
The deployed contract A:
A.sol：
contract A {
    function testA() public returns(uint) {return 1;};
}

Here is the first way that contract B interacts with contract A:
B.sol:
import "./A.sol";

contract B {
    A a;
    function testB() public returns(uint) {
        a.testA();
    }
}

Here is the second way that contract B interacts with contract A:
IA.sol:
interface IA {
    function testA() external returns(uint) {};
}

B.sol:
import "./IA.sol";

contract B {
    IA a = IA(addressOfA);
    function testB() public returns(uint) {
        a.testA();
    }
}

Question:
What's the difference between the two ways? I know the second way is the way that how contract interacts with another deployed contract (know its address and ABI), but What does the first way mean? Why can the first way also work? What's the first way used for?


texts: I have several accounts in my Geth wallet. I need to locate the keystore file of a given account but there doesn't seem to be any connection between the keystore file names and the accounts. How do I get the keystore file of a given account?


texts:
Is there any reason why ethereum.enable() would not open the metamask console?
It was working briefly and now I cannot get any response from it.


texts: How can a DAO manage a domain, Twitter account, Github commit rights in a trustless manner?

texts:
With managing on-chain assets the Vault / Tresury controlled by DAO works.

With other digital assets, such as WWW domain, there is still a single human who uses GoDaddy.

Is there any technical feasibility for DAO to control the domain, ensuring that not a single human (rogue admin) can destroy the existing brand?

I was thinking about putting some bond system.

Whoever controls an important function that is not compatible with DAO, posts a 1000 DAI to keep them accountable.

(don't trust, verify)


texts: How to increase gas supply while making a transaction call?

texts: I am using a private chain for deploying contracts. I came to a problem that when I call one of my functions in contract, it runs out of gas and function could not get executed. Any suggestions on how to deal with this problem?


texts:
Is a reliable way to identify the caller with the following code?

bool isContract = msg.sender != tx.origin;


texts: Does a function call that does not change a contract's state cost gas

texts:
I have read multiple times that everything costs gas on ethereum. But when I write and use a function that does not change the state of a contract (i.e sum up two parameters and return the sum) that does not cost any gas.

So, where does the statement "everything costs gas on ethereum" mean now actually?


texts: Is it safe to make a contract call from a giant loop?

texts:
I have this function in solidity:
function payPlayers(address[] memory players, uint256[] memory values) public payable returns (bool[] memory result) {
        result = new bool[](players.length);
        for (uint i = 0; i < players.length; i++) {
            result[i] = false;
            (bool success, ) = players[i].call{value: values[i]}("");
            if (success) {
                result[i] = true;
            }
        }
        return result;
    }

I was reading about many calls made in giant loops that can cause block overflow and some transaction will fail. Is this correct?
What size of the players array can be safest for this loop so that all calls will work?
Thanks in advance.


texts: Why does this trivial function has "Gas requirement high: infinite"?

texts:
I wrote this trivial contract in Remix:

pragma solidity ^0.4.24;

contract HelloWorld {
    function greet() public pure returns (bytes32) {
        return bytes32('Hello World!');
    }
}

I got the warning: "Gas requirement of function HelloWorld.greet() high: infinite".

This is very strange since I do not have any strings or dynamic arrays. How can I get rid of this warning and have clean compilation?


texts: How can I properly set the gas / value for sending a transaction with web3.js?

texts:
My code is:

function sendEth(fromAddress, secret, toAddress, amount) {
  let params = {
    to: toAddress,
    from: fromAddress,
    value: web3.utils.toWei(amount + '', 'ether')
  };
  console.log(params);

  return Promise.all([web3.eth.estimateGas(params), web3.eth.getGasPrice()])
    .then((response) => {
      const estimatedGas = response[0];
      const gasPrice = response[1];
      params.gas = estimatedGas;
      params.gasPrice = web3.utils.toWei(1.1 * gasPrice + ''); // Use 10% more gas than recommended
      params.value = web3.utils.toWei(params.value - params.gas * params.gasPrice + '');

      return web3.eth.accounts.signTransaction(params, secret);
    })
    .then((signedTx) => {
      return web3.eth.sendSignedTransaction(signedTx.rawTransaction);
    });
}

But I get an error:

 Error: while converting number to string, invalid number value '-1.1549989999999999e+23', should be a number matching (^-?[0-9.]+).


texts:
Why does getProduct(..) always return an empty address 0x00 on browser-solidity?

pragma solidity ^0.4.7;

contract Products {
    struct Product {
        bytes32 name;
        uint votes;
        address company;
    }

    mapping (uint => Product) products;
    mapping (address => uint) companyProductsCounter;
    uint private counter;

    function Products () {
        counter = 0;
    }

    function registerProduct( bytes32 productName) {
        products[counter++] = Product({name: productName, votes: 0, company: msg.sender});
    }

    function getProduct(uint code) constant returns (bytes32 name, uint votes, address company) {
        products[code].name;
        products[code].votes;
        products[code].company;
    }
}


texts:
I am downloading the full blockchain for the main network in Homestead, does the --fast function in geth work?

  geth --fast

It has been a couple hours already and not even past 5%!


texts: How can i make function call from one contract deployed on the blockchain to another contract seperately deployed on the blockchain?

texts:
How can i make function call from one contract deployed on the blockchain to another contract seperately deployed on the blockchain to transfer ownership from the second (called) contract to a new address or contractaddress?

Hi!

So i deployed a tokencontract with the msg.sender address as the owner.

After i deployed the crowdsale contract (which needs ownership of the tokencontract to mint, burn and transact tokens) and i used the function transferOwnership() to transfer the token ownership to the crowdsale contract address.

This works, but then i need to change it back to another address, of course, it does not.

I need to have a function that directly calls the token contract address and gives as a parameter the new owner address.

How should i implement this?


texts: Does a transaction always require a smart contract to be executed?

texts:
I had a discussion with someone explaining that every time a transaction occurs (e.g. ICO token or ETH) on Ethereum it would pass via a smart contract or would require one.

I would like to know what are your best arguments to prove him wrong?


texts:
Currently I am using GETH, but it is getting like 4~5 days trying to sync without success!

May I know any other ETH client which can provides RPC connection and able to sync with the mainnet fast?!?


texts: Are there any code quality certifications or standards for smart contracts

texts:
In light of recent statistics on # of bugs in smart contracts and the DAO heists I like to know if there are any kind of smart contract quality certification framework , smart contract standards or even smart contract best practices in the context of Ethereum?

Thank you


texts: using account create in metamask with Nethereum

texts:
Can I use an account created in metamask using nethereum? I tried this:
var abi = @"";
var addressContract = "";
var myAddress = "xxxxx";
var password = "password";
var managedAccount = new ManagedAccount(myAddress, password);

var web3ManagedAccount = new Web3(managedAccount);
var contract = web3ManagedAccount.Eth.GetContract(abi, addressContract);

var method= contract.GetFunction("method");

SendTransactionAndWaitForReceiptAsync(from: myAddress, new HexBigInteger(3000), value: null, null, abcBytes, newAddress);

but return an error that say:The method personal_sendTransaction does not exist/is not available
Update
I had a big mistake, I needed to pass the private key and not the password, thanks for your help
var abi = @"";
var addressContract = "0xA0XXXXX";
var myPriveteKey= "myKey";
var managedAccount = new ManagedAccount(myPriveteKey);
...


texts: Why do I get "stack underflow" when executing sendTransaction?

texts:
I'm using geth to store data strings into Ropsten. All of them are 128 byte long strings (in fact they are all SHA512 hashes of data files).

I just call web3.eth.sendTransaction with the string I need to store in its "data" field, like this:

web3.eth.sendTransaction({from: source, to:source, value:0, data: '0x' + imgHash})

The transaction is created and uploaded to the blockchain. It works like a charm.

I'm also using "getTransaction" to read those strings from the blockchain, and it works perfectly, too.

Please note that I'm not using smart contracts at all.

The problem comes when I take a look at those transactions in ropsten.etherscan.io. The result of all of the transactions sent is "Error in Txn: Stack underflow", although as I mentioned, they're all correctly uploaded to the blockchain.

I'm not too worried, since everything works as I want it to, but I can't figure out why is this "stack underflow" error happening. It seems a bit weird to me that everytime I send a transaction it shows a "contract creation" in etherscan...

Can anyone please explain to me why is this happening and how to fix it?

Thanks in advance! :)


texts: Confirmations for a contract in Private Network

texts: I just established Ethereum Private Network and connected to mist.I also created an account using personal.newAccount("") which have zero ethers. I would like to deploy a contract.So to start I know that we really require Ethers and which can be achieved by preallocating the ether to the accounts in genesis file.So my account was preallocated with test ethers which are sufficient to deploy a contract to the network.Now I have 2 peers in the network, so if I deployed a contract to the network then those 2 peers should check or confirm them, but the other connected peers didn't do anything(like confirming the contract) but I got 190+ confirmations to the contract I deployed in private network.My question is who confirmed the contract?


texts: Truffle Contract Abstraction Contract.at() not returning logs when methods are called

texts:
In my test file I have this set up:

let acc = await Account.deployed()

Then when I call a method, I can get the logs in the receipt:

let deposit = await acc.deposit()
console.log(deposit.receipt.logs)

But when I do this:

let acc = await Account.at(sellerAcc)
let deposit = await acc.deposit()
console.log(deposit.receipt.logs)

There are no logs on the receipt and the console returns undefined!
Not sure how this is functioning but I know the difference is with Contract.deployed() and Contract.at(), so what's going on?

How do I get sellerAcc in  above:

let fac = await AccountFactory.deployed()
let seller = accounts[0]
let sellerAcc = await fac.getAccount(seller)

let acc = await Account.at(sellerAcc)

getAccount function from Factory contract

user_to_account: map(address, address)

@public
@constant
def getAccount(user: address) -> address:
    return self.user_to_account[user]


texts: How to I import my Ethereum wallet into MyEtherWallet

texts: I have an Ethereum Wallet on my Companys Laptop. Unfortunately I have to give it back. I also bought Tokens from the DAO with that account. How can I transfer / access my wallet on a different device. How can I access this account from Ethereum Wallet using MyEtherWallet? I'm not a great coder, so ... I'm afraid too loose my (Tokens)...


texts: Event firing before data is actually set

texts:
Let's say this is my smartcontract:

  event NewUser(
    address userAddress,
    uint amount
  );
  function addUser() public payable{
    require(msg.value <= maxValue && msg.value > 0);
    require(allowedValues[msg.value]);
    require(accountAmount() < 5);

    if (users[msg.sender] > 0) {
        userPullout(); //Remove senders data
    }

    userAddresses.push(msg.sender);
    partAmounts.push(msg.value);// This value doesn't get pushed before the event is finished
    users[msg.sender] = msg.value;

    emit NewUser(msg.sender, msg.value);//This is called to soon
}

This is my nodeJS file:

app.contract.events.NewUser({}, function(error, event){})
.on('data', function(event){
  io.emit('new user', event.returnValues);
}).on('change', function(event){
  io.emit('new user', event.returnValues);
})
.on('error', console.error);

If I log the partAmount array in web3 with a .call function, the old values before the event still get returned. This tells me that the event is fired too soon.

Is there anyway to call an event after the data is set?

EDIT: some more code.

const socket = openSocket('http://localhost:3000'); // subscribed to the socket server firing the events from node back-end
socket.on('new user', (event) => {
  console.log(event) // returns for example 7 which is CORRECT
  this.props.contract.methods.getCertainArray().call(this.props.contractObject, (err, res) => {
    console.log(res); // old data from before the event so if the previous array was [0, 6 , 6], this would still be returned NOTICE: no 7 in the array yet.
  });
})

NOTE:  If i put a set timeout around the call function like this:

setTimeout(() => {
    this.props.contract.methods.getCertainArray().call(this.props.contractObject, (err, res) => {
      console.log(res); // old data from before the event so if the previous array was [0, 6 , 6], this would still be returned NOTICE: no 7 in the array yet.
    });
}, 5000);

It does return the right array, but it is not the way I want the script to run.


texts:
I'm using web3 version '^0.20.6' in my node application and did following for connecting to web3 but still getting the error while calling the method getTransactionCount.

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider(INFURA_ADDRESS));

// Got error while calling the below function
web3.eth.getTransactionCount(address).then(txCount => { });

  Error : TypeError: web3.eth.getTransactionCount(...).then is not a
  function


texts: How to issue new ERC 721 tokens for each individuals with different name and symbol

texts:
I'm working with an app where different users can create their own ERC721 tokens by passing token, symbol total supply etc. Currently, the code is creating the token, but it has common name only.

pragma solidity ^0.5.0;

import "./token/ERC721/ERC721Full.sol";
import "./drafts/Counters.sol";

contract MyContract is ERC721Full {

    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721Full("MYToken", "MYT") public {
    }

    function mint(address player) public returns (uint256) {

        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        return newItemId;
    }
}

How to create tokens with different name and symbol for each user? and mint to their account?

Do I need to deploy a smart contract per user? if so, the complexity will be increased by time. And is there any best practice available.


texts: How do I execute a transaction with string parameters using JSON-RPC

texts:
My contract has a method with this signature:

register(byte32 documentHash, string owner, string url)

I read this documents (https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI#function-selector) and tried to execute a transaction using JSON-RPC.

I understand that the data parameter for the eth_sendTransaction method will begin with "0x9b74202e" :  first 4 bytes of Keccak encode from "register(byte32,string,string)".

I do not understand how to correctly encode the parameters.

Example:

documentHash = d46046d56d3807a12978ebccfbf0960790bb8d40f3888ac2d5d8416753cd5c54

owner = "johndoe@gmail.com"

url = "https://dl.dropboxusercontent.com/u/96015624/document.pdf"

For this example, how do I encode the data parameter?


texts:
I'm in need of some help!
I'm developing a project where I'm supposed to implement an ethereum payment system that will then be installed in a point of sale (POS) in a retail store.
The idea is not to use any gateway available in the market, so I need to understand what would be the best way to develop the whole system. I have already investigated and found that using smart contracts and the web3js library could be an option:

The merchant creates a smart contract with the value and inserts it into the blockchain.
The POS shows a QR Code with the data needed for the payment
The customer reads the QR Code through his wallet and executes the payment
The amount is entered into the contract
The merchant withdraws the contract value to your wallet

I would like to know if you find this option workable and if it could be successful. I am available for any new ideas!
Thank you!


texts: I want to reward users letting them claim tokens if they use my DApp. How do I prevent cheaters from using any other DApp?

texts:
I want to distribute tokens to users by verifying some data they provide to a DApp (for example, matching their camera photo with the database containing their faces). Since there will be thousands of users, given the high GAS costs, I cannot register each user within the smart-contract given the money constraints and the amount of data I need to store.
What is the best approach, if any, to prevent cheaters obtaining more tokens using some other DApp? I assume that somehow, the smart-contract needs to know which DApp the data is coming from... but I don't know how.
Furthermore, I would prefer if the solution involved just one smart-contract without asking me to change the state of a contract for each user. Also, I do not want the users to have to deposit ETH but only to pay the transfer fees obtaining their tokens.


texts: forward revert message from low level solidity call

texts:
I'm working on a proxy contract that will perform calls as follows:

bool success;
bytes memory returndata;
(success, returndata) = _to.call.value(_value)(_data);
require(success);

this works great, except that, if the call reverts with an error message, this function will simply reverts, hiding the reason string.

How can I retrieve the reason string (I assume in the returndata) and use if to revert properly


texts: Is there a way to be notified when ERC721 is deposited?

texts:
We are coding a contract that will work with ERC721 tokens, basically a Plasma Root Chain contract. We need this contract to do some work whenever it receives a new ERC721 token from a SafeTransferFrom.

Just like the function() external payable function is called only when ether is transferred to the contract, we would need the same functionality for ERC721, but we are not sure if it exists or is even possible to implement.

We know the function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) internal returns (bytes4) is called whenever a SafeTransferFrom is done correctly, however, what can be done to stop anyone from just calling that function without actually depositing an ERC721 token?


texts: ethers gone after restarting ethereum mint

texts: I was mining on test-net miner and was trying to send ether to coinbase for the first time just to test a transaction but the transaction never sent and is still showing pending transaction. After restarting ethereum mint all the ethers are gone, all of this happened while the nodes were not fully synced it was syncing for a couple of days and still not done yet. Are my ethers really gone, can I still retrieve them? if I check my balance on etherscan.io it says balance 0.. I am not sure if my address has changed or not I did not keep track.


texts: Token not found on Etherscan after Deploying Crowdsale

texts:
I am deploying contract that creates a token and a crowdsale, based on code slightly modified from zeppelin-solidity.

Problem: After deploying the contract to Rinkeby using Truffle and Infura, searching the Contract Address 0x9B4b8583048D77F7CDc5c665f138E6dbce1e37Ba on [Etherscan's ERC20 Token Search][2] gave the result that no token is found in that contract address!

What went wrong?

Output of truffle migrate --network rinkeby

Using network 'rinkeby'.

Running migration: 1_initial_migration.js
  Replacing Migrations...
  ... 0xb101fbf5cb0c6f2e0e937484c2db43cef906501d5544c0ce742fd6965a06594e
  Migrations: 0x9b4b8583048d77f7cdc5c665f138e6dbce1e37ba
Saving successful migration to network...
  ... 0x53dd9d5eb01e0dc636695a21ea8e95d58862a0c9e010c7fa8c840048fc21f7ad
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Replacing SampleCrowdsale...
  ... 0x31fef6189be9eb877b87751cd27c00f52e46c0fca3ce17722a4a586691a5c995
  SampleCrowdsale: 0x2c7bf1f6c01bd45e104de98e96266a2b1f07907f
Saving successful migration to network...
  ... 0xddfecd93e7d8aefa4c438a0e4a7d8e775e17ff6241177b0511413a5ccb665985
Saving artifacts...

SampleCrowdsale.sol

pragma solidity ^0.4.11;

import "zeppelin-solidity/contracts/crowdsale/CappedCrowdsale.sol";
import "zeppelin-solidity/contracts/crowdsale/RefundableCrowdsale.sol";
import "zeppelin-solidity/contracts/token/MintableToken.sol";

contract SampleCrowdsaleToken is MintableToken {

  string public constant name = "Sample Crowdsale Token";
  string public constant symbol = "SCT";
  uint8 public constant decimals = 18;

  uint256 public constant INITIAL_SUPPLY = 10000 * (10 ** uint256(decimals));

  /**
   * @dev Constructor that gives msg.sender all of existing tokens.
   */
  function SampleCrowdsaleToken() {
    totalSupply = INITIAL_SUPPLY;
    balances[msg.sender] = INITIAL_SUPPLY;
  }

}

contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale {

  function SampleCrowdsale(uint256 _startTime, uint256 _endTime, uint256 _rate, uint256 _goal, uint256 _cap, address _wallet)
    CappedCrowdsale(_cap)
    FinalizableCrowdsale()
    RefundableCrowdsale(_goal)
    Crowdsale(_startTime, _endTime, _rate, _wallet)
  {
    //As goal needs to be met for a successful crowdsale
    //the value needs to less or equal than a cap which is limit for accepted funds
    require(_goal <= _cap);
  }

  function createTokenContract() internal returns (MintableToken) {
    return new SampleCrowdsaleToken();
  }

}

2_deploy_contract.js

var SampleCrowdsale = artifacts.require("../contracts/SampleCrowdsale.sol");

module.exports = function(deployer) {
    var d = new Date()
    var startTime = d.getTime()
    var endTime = startTime + (86400 * 20) // 20 days
    const rate = new web3.BigNumber(1000)
    const goal = 10000
    const cap = 1000000
    const wallet = '0xcede48d8aC162d1b08ed9419010DE3c99F2cfDd6'
  deployer.deploy(SampleCrowdsale, startTime, endTime, rate, goal, cap, wallet);
};

This creates 2 contracts

Migrations: 0xc0e02bc10bc4fbdba607365afcab5f6c992759e0
SampleCrowdsale: 0x09451e7df77a32f4b35858385b96ddd0a4e2bff2

However using0x09451e7df77a32f4b35858385b96ddd0a4e2bff2 in Metamask Add Token feature does not add any Token. Etherscan's ETC20 Standard Token Explorer also does not find any valid Token at the contract address.


texts: Where is the security in http provider for a blockchain node IP address?

texts:
I have the code below. In testing this actually works but there is no security from what I have seen. The node is at an IP address and the node code just states the default account is coinbase.

So how should this security flaw be addressed? If when the account issue is solved then still anyone can access the network - it is a private network. I know ufw can be used to restict IPs but I understand it is not difficult to fake an IP address.

web3=require('web3');
var myweb3 = new web3(new web3.providers.HttpProvider('http://10.154.0.2:8505'))
;
  var contractaddress= "0x16a09128f41bffc590421f6d409930368267a3f4";
  var abi=
    [{"constant":true,"inputs":[],"name":"inventoryWeight","outputs":[{"name":""
,"type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},
{"constant":false,"inputs":[{"name":"hashInventory","type":"bytes32"}],"name":"a
ddInventoryHash","outputs":[],"payable":false,"stateMutability":"nonpayable","ty
pe":"function"},{"constant":false,"inputs":[{"name":"inventory","type":"string"}
,{"name":"hashInventory","type":"bytes32"}],"name":"addInventory","outputs":[],"
payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":tru
e,"inputs":[{"name":"","type":"bytes32"}],"name":"inventories","outputs":[{"name
":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function
"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"inventoryHas
hesStorage","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutab
ility":"view","type":"function"},{"constant":false,"inputs":[{"name":"weight","t
ype":"uint256"}],"name":"addWeight","outputs":[],"payable":false,"stateMutabilit
y":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAllIn
ventories","outputs":[{"name":"","type":"bytes32[]"}],"payable":false,"stateMuta
bility":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"
uint256"}],"name":"inventoryHashes","outputs":[{"name":"","type":"bytes32"}],"pa
yable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateM
utability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":
false,"name":"hashInventory","type":"bytes32"}],"name":"eventNewInventory","type
":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"hashInventory",
"type":"bytes32"}],"name":"eventNewStorageInventory","type":"event"}]
myweb3.eth.defaultAccount = myweb3.eth.coinbase;
let commodityContract = myweb3.eth.contract(abi).at(contractaddress);
    commodityContract.addWeight(77888555);


texts: Optimizing storage for an array of addresses

texts:
When possible, does Solidity optimize a storage array of address?

For example, does address[8] take up 5 storage slots (160 bytes), or 8 storage slots?

contract C {
  address[8] arr;
}

If 8 slots are used, is there a way to write the code so that Solidity will compile to only using 5 slots?  Different alternatives are welcome, with preference given to an easy way to access the addresses (such as arr[2] instead of twiddling with bytes, but such answers will still be helpful).


texts: Two Ethereum Node (connected to private net) on Single PC: Node data write error .Synchronisation failed

texts:
Is it possible to create 2 geth instance on single PC?
Both are connected the private blockchain?

When I connect a node to the private blockchain,it must sync with the blockchain by downloading all blocks upto latest one.Is this possible to do this on a 2nd node instance in same PC?

If not, what is the reason behind this?

I am getting the following error while I tried to run two instance.

First Node
geth --identity "TestNode1" --rpc --rpcport "8545" --rpccorsdomain "*" --datadir <data-path-1> --port "30303" --rpcapi db,eth,net,web3,personal,miner --networkid 987 console 2>> logfile_1

Second Node
geth --identity "TestNode2" --rpcport "8545" --rpcaddr "xxx.xxx.xx.xx" --ipcdisable --rpccorsdomain "*" --datadir <data-path-2> --port "30304" --rpcapi db,eth,net,web3,personal,miner --networkid 987 console 2>> logfile_2

Error:
INFO [10-26|09:30:33.099] Block synchronisation started
WARN [10-26|09:30:33.107] Node data write error err="state node 255a57…77b997 failed with all peers (1 tries, 1 peers)"
WARN [10-26|09:30:33.107] Synchronisation failed, retrying err="state node 255a57…77b997 failed with all peers (1 tries, 1 peers)"


texts: Transfer Ether from contract to user addresses

texts:
I have code to transfer Ether to an address, as follows:

addr.transfer(amount);

Unfortunately, when I execute this statement for two transfers, the money never arrives in the addr addresses. I do see the Etherscan output on Ropsten:

I have a suspicion the transfers (call_1_0 and call_1_1 below) are never fulfilled, because the GasLimit is set to 2300. Is this possible?

Is there a way to increase the GasLimit? I tried using:

  uint GAS_LIMIT = 4000000;
  addr.transfer.gas(GAS_LIMIT)(amount);

but then the solc compiler says:

  TypeError: Member "gas" not found or not visible after argument-dependent lookup in function (uint256)
        addr.transfer.gas(GAS_LIMIT)(amount);
        ^---------------^

This is the full code of the contract (beneficiaries are added during construction by a "manager" contract that instantiates it.

contract SimpleSmartAsset is Mortal {

  uint usagePrice;
  Beneficiary[] beneficiaries;
  uint totalWeight; // to calculate percentage the beneficiaries receive

  event AssetCreated(uint _usagePrice,
                     address[] addresses,
                     uint[] weights);

  function SimpleSmartAsset(uint _usagePrice,
                            address[] addresses,
                            uint[] weights) {
    owner = msg.sender;
    usagePrice = _usagePrice;

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

      uint weight = weights[i];

      addBeneficiary(addresses[i], weight);
      totalWeight += weight;
    }

    AssetCreated(_usagePrice, addresses, weights);
  }

  function getUsagePrice() constant returns (uint) {
    return usagePrice;
  }

  event BeneficiaryPaid(address addr, uint amount);

  function pay() payable onlyOwner {
    require(msg.value >= usagePrice);

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

      Beneficiary memory beneficiary = beneficiaries[i];

      uint weight = beneficiary.weight;
      address addr = beneficiary.addr;

      uint amount = (weight * usagePrice) / totalWeight;

      uint GAS_LIMIT = 4000000;
      addr.transfer.gas(GAS_LIMIT)(amount);
      BeneficiaryPaid(addr, amount);
    }
  }

  struct Beneficiary {
    address addr;
    uint weight;
  }

  function addBeneficiary(address addr, uint weight) onlyOwner {
    beneficiaries.push(Beneficiary({
        addr: addr,
        weight: weight
    }));
  }

}

How can I transfer money to the user addresses from the contract?


texts:
Several questions about guarantees of transactions:

Can valid transaction be not accepted in the beginning, so it will not make into pending pool?
Can it expire once it in the pending pool? (without any other actions from the same address)
Is there guarantee that transaction will be eventually executed(assuming there's no infinite amount of transactions with higher gas price)?


texts: Why after managing to deploy contract to POA Ethereum blockchain I can't interact with it?

texts:
We are using a private ETH proof of authority blockchain.

In order to deploy a contract I'm using 0 gas price and it deployed immediately.

Then, Tried to deploy many types of contracts with different functions. f.e:

pragma solidity 0.5.8;

contract graph{

    event CampaignCreated(uint256 relevantNumber, address owner, address moderator);
    event CampaignJoined(uint256 amount, address joinUser);
    event Number(uint256 general);

    function createCampaign(uint relevantNumber, address _moderator, address _owner) public{
        emit CampaignCreated(relevantNumber, _moderator, _owner);
    }

    function sendNumber(uint relevantNumber) public{
        emit Number(relevantNumber);
    }

    function joinCampaign(uint _amount, address _joinUser) public{
        emit CampaignJoined(_amount, _joinUser);
    }
}

but all of the tx are failing.
before each call, I'm again setting the gas price to 0.


texts: Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

texts:
let result = await instance.joinQuiz({
    from: accounts[1],
    value: web3.utils.toWei(10, "wei")
});


texts: List ERC721 tokens owned by a user on a web page

texts:
Let's say that I have an ERC721 (NFT) contract that represents a set of playing cards.

Is there sample code out there that shows listing all of the tokens of that ERC721 contract that a user owns on a web page so that the user could select one?


texts: how to broadcast ethereum signed transaction without web3.js or any other web3 library/client

texts: Is there any secure and reliable way of broadcasting signed Ethereum transaction without using Web3 library like with some service and some sort of HTTP API?


texts: What is the most correct way to test modifiers?

texts: As per the title, which testing method is most correct for modifiers? Something like testing via inheritance and creating a function specifically designed to test modifiers or testing via a framework like truffle (or even something else)? Just trying to get a better idea of Solidity best practices. Thanks!


texts: Difference between uncle block and forked blocks

texts: For example https://etherscan.io/uncles and https://etherscan.io/blocks_forked, what difference between them?


texts: Chainlink import causing Truffle console to crash

texts:
Related issue on GitHub: https://github.com/trufflesuite/truffle/issues/3329
If I compile my contracts with truffle compile and then open the truffle console with truffle develop then this happens:
truffle(develop)> version
Truffle v5.1.39 (core: 5.1.39)
Solidity - ^0.6.0 (solc-js)
Node v12.18.2
Web3.js v1.2.1
truffle(develop)> TypeError: Buffer.isBuffer is not a function
    at Function.writeFileSync [as sync] (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/write-file-atomic/index.js:213:1)
    at Configstore.set all [as all] (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/configstore/index.js:58:1)
    at new Configstore (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/configstore/index.js:25:1)
    at Function.getUserConfig (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:171:1)
    at Object.send (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/services/analytics/index.js:5:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:137:1)
    at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:155:1)
    at ReplManager.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/repl.js:129:1)
    at bound (domain.js:426:14)
    at REPLServer.runBound [as eval] (domain.js:439:12)
    at REPLServer.onLine (repl.js:760:10)
    at REPLServer.emit (events.js:315:20)
    at REPLServer.EventEmitter.emit (domain.js:482:12)
    at REPLServer.Interface._onLine (readline.js:329:10)
    at REPLServer.Interface._line (readline.js:658:8)
    at REPLServer.Interface._ttyWrite (readline.js:999:14)
    at REPLServer.self._ttyWrite (repl.js:851:9)
    at ReadStream.onkeypress (readline.js:205:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:482:12)
    at emitKeys (internal/readline/utils.js:335:14)
    at emitKeys.next (<anonymous>)

The reason seemed to be a naming conflict (but it's not. well... it is but... see below). But as a side-question: Openzeppelin and chainlink both include a SafeMath contract:
Compiling your contracts...
===========================
> ...
> Compiling @chainlink/contracts/src/v0.6/vendor/SafeMath.sol
> ...
> Compiling @openzeppelin/contracts/math/SafeMath.sol

> Duplicate contract names found for SafeMath.
> This can cause errors and unknown behavior. Please rename one of your contracts.

How can I use both chainlink and openzeppelin withouth running into this issue. Is this only possible with two completely separate contracts that only communicate through transactions? Or what do I not get here?
UPDATE
So... the actual problem seems to be just chainlink and/or truffle.
While the question remains, how to resolve those naming conflicts, I realized that the Buffer.isBuffer issue has nothing to do with it but with chainlink/truffle itself it seems.
If I import for example something from openzeppelin, like Ownable, everything works fine. But if I import chainlink and inherit from ChainlinkClient, the truffle console crashes with above exception once I first compiled the contract.
I recorded this, see here: https://youtu.be/InNPguD3h6g
It turns out the native node object, Buffer, is being overwritten when you have a contract with this name. In general contract names can conflict with native node objects.
Related issue on GitHub: https://github.com/trufflesuite/truffle/issues/3329
My project: https://github.com/mktcode/mergepay-contracts


texts: Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' By calling UniswapV2Router02 swapExactTokensForETH

texts:
I am trying to call UniswapV2Router02 swapExactTokensForETH function on my Solidity Contract.
I got Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'  on etherscan.
this is transaction url : https://kovan.etherscan.io/tx/0x5970c88d59cacdb33ac68ffe0785b9084309cbc5992d971293d24099af663ab7
than, I debug the transaction using  https://dashboard.tenderly.co/
I found that the real error occur at Dai.sol
Error msg is  "Dai/insufficient-balance"

Did some one know what's happen?
plz help me!


texts: invalid character 'personal_signAndSendTransaction' after top-level value

texts:
I am getting this error when I try to sign in to one of my accounts using Mist. If I try to unlock the account using the console I get this error:

  invalid character 'g' after top-level value


texts:
I am building a Smart Contract that can receive tokens and in exchange for the tokens received another token will be issued.

my problem is how can i make a function send automatically my tokens to the address of sender when the another erc20 token received

if you have code write it


texts: Hi there I came across "Truffle test". As a developer I feel like it's better to test code on remix for unit testing rather than wasting time on writing truffle test in javascript. What do you guys think??? Is there any greater benefit of Truffle test that I'm overlooking or it's just subjective?


texts: What happens when a Contract is added to the genesis block?

texts:
Recently I found out that you can add smart-contracts to the genesis block (genesis.json) of your local ethereum network.
Since normally, when you add a smart-contract via a transaction, you can call the constructor, which can initialize the contract. I also know that the constructor is optional, so I assume when adding the byte-code of a contract to an address in the genesis block, there is no way to call the constructor anymore. Is this correct? If so, is there a way to initialize some variables (e.g. owner address) besides hardcoding them?
Thanks :)


texts: passing address as a function parameter in web3

texts:
I've this contract that gets 'address' type variable as input parameter to function and sets it to a variable. This works fine in Remix. I'm trying to call this using web3js and am getting an Uncaught Error: invalid address error. Is there any work arounds / best design practices to get this done?

Contract:

mapping (address => bool) public lakeApprover;

function addForestApprover(address _forestApprover) public onlyOwner {
    forestApprover[_forestApprover] = true;
}

Web3js function

function addLakeApprover() {

    var MyContract = web3.eth.contract(abi);
    var myContractInstance = MyContract.at(contractAddress);

    var accountToAdd = document.getElementById('idAccount').value;
    var accountToSubmit = web3.personal.unlockAccount(web3.eth.accounts[0],'',300);

    var txHash = myContractInstance.addForestApprover(accountToAdd, {'from':accountToSubmit,'gas':47000},
        function (err, res) {
        if(!err) {
            console.log("Error: " + err + "\n Response: " + res);
            var txnReceipt = web3.eth.getTransactionReceipt(res);
            document.getElementById("idHashDetails").innerHTML = "
 Block Number: " + txnReceipt.blockNumber
                                                                + "
 Status: " + txnReceipt.status
                                                                //+ "
 Status-ascii: " + web3.toAscii(txnReceipt.status)
                                                                + "
 Transaction Hash: " + JSON.stringify(res);
                                                                ;
        }
    });
}

Hardcoded value and console print

    function addLakeApprover() {

        var MyContract = web3.eth.contract(abi);
        var myContractInstance = MyContract.at(contractAddress);

        var accountToAdd = "0x0B4a064e35f51aB6884E90B8F3953074a8C7F292";
        var accountToSubmitNOC = web3.personal.unlockAccount(web3.eth.accounts[0],'',300);

        console.log("accountToAdd value = "  + accountToAdd);
        var txHash = myContractInstance.addForestApprover ( accountToAdd,
        {'from':accountToSubmitNOC,'gas':47000} ,
            function (err, res) {
            if(!err) {
                console.log("Error: " + err + "\n Response: " + res);
                }
        });
    }

Response for hardcoded value code

accountToAdd 0x0B4a064e35f51aB6884E90B8F3953074a8C7F292
web3.js:3914 Uncaught Error: invalid address
    at inputAddressFormatter (web3.js:3914)
    at inputTransactionFormatter (web3.js:3740)
    at web3.js:5015
    at Array.map (<anonymous>)
    at Method.formatInput (web3.js:5014)
    at Method.toPayload (web3.js:5040)
    at Eth.send [as sendTransaction] (web3.js:5065)
    at SolidityFunction.sendTransaction (web3.js:4124)
    at SolidityFunction.execute (web3.js:4207)
    at addLakeApprover (Admin_screen.html:39)


texts: Deploy script not working and not throwing any errors

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

const provider = new HDWalletProvider(
   'Mneomonic',
   'rinkeby url'
);

const  web3 = new Web3(provider);

// const result = await new web3.eth.Contract(JSON.parse(interface))
//      .deploy({data: '0x' + bytecode, arguments: ['Hi there!']}) // add 0x bytecode
//      .send({from: accounts[0]}); // remove 'gas'

console.log('Starting deploy 1');
const deploy = async () => {
  console.log('Starting deploy 2');
    const accounts = await web3.eth.getAccounts();
    console.log('Attempting to deploy from account', accounts[0]);

    const result = await new web3.eth.Contract(JSON.parse(interface))
                    .deploy({ data: bytecode, arguments: ['Hi there!']})
                    .send({ gas: '1000000', from: accounts[0]}, function (error) {
                                        console.log('Error: ', JSON.stringify(error));
                                    });

    console.log('Contract deployed to', result.options.address);
};

deploy();
console.log('end')

I'm having a problem with this script

The script dosent get past the  const accounts = await web3.eth.getAccounts(); line

Its like it just returns out of the function

No console log messages are printed after this line

Does anyone know what the problem could be

It also doesn't throw any errors

Console output is
Starting deploy 1
Starting deploy 2
end

If tried surrounding it with a try cat


texts: Getting the error :- Web3ProviderEngine does not support synchronous requests

texts:
Below is my migration file,

var startTime = web3.eth.getBlock(web3.eth.blockNumber((err, res) => {})).timestamp + 30;
var endTime = startTime + 4 * 60 * 60;
var presaleLimit = startTime + 1 * 60 * 60;
var crowd1Limit = startTime + 1.45 * 60 * 60;
var crowd2Limit = startTime + 2.30 * 60 * 60;
var crowd3Limit = startTime + 3.15 * 60 * 60;
var disc1 = web3.toWei('1', 'ether');
var disc2 = web3.toWei('2', 'ether');
var rate = 3;
var wallet = '0x58B219a8Fd3897303D3C106031736df26Ad3A406';
module.exports = function(deployer) {
  deployer.deploy(SetherCrowdsale, startTime, endTime, rate, wallet, presaleLimit, crowd1Limit, crowd2Limit, crowd3Limit, disc1, disc2);
};

I am getting the below error while trying to run this on ropsten.

Running migration: 2_deploy_contracts.js

/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10
  this.stack = (new Error(message)).stack;
^
/usr/local/lib/node_modules/truffle/build/cli.bundled.js:219413
        throw error;
        ^

Error: Web3ProviderEngine does not support synchronous requests.
    at ProviderError.ExtendableError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-error/index.js:10:1)
    at new ProviderError (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/error.js:17:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:71:1
    at HDWalletProvider.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:109:1)
    at Object.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:209:1)
    at RequestManager.send (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:58:1)
    at Eth.get [as blockNumber] (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/property.js:107:1)
    at /home/fkp/Desktop/BCW/migrations/2_deploy_contracts.js:3:44
    at Script.runInContext (vm.js:74:29)
    at Script.runInNewContext (vm.js:80:15)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-require/require.js:97:1
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:532:3)


texts:
I know that only the first call to oraclize_query is free but i don't know how to send the small fee requested.
Can you give a code sample ?

Thanks!


texts: Contract function works on Remix but not works on web3js

texts:
I've a contract, more complex than the following but the concept is the same

pragma solidity ^0.4.23;

contract SimpleCatalog{
    bytes32[] internal x;

    constructor () public{
      x.push(0xa);
      x.push(0xb);
      x.push(0xc);
    }

    function getX() external view returns (bytes32[]){
      return x;
    }
}

When I execute the function in Remix, it returns all the values that I expect that are:

0: bytes32[]:
0x000000000000000000000000000000000000000000000000000000000000000a,
0x000000000000000000000000000000000000000000000000000000000000000b,
0x000000000000000000000000000000000000000000000000000000000000000c

But if I invoke it with Web3JS, that is:

const web3 = new Web3(window.web3.currentProvider);
console.log(web3.version) //0.19.0
const catalog =
  (web3.eth.contract(props.catalog.abi)).at(props.catalog.address);
catalog.getX(res => {console.log(res)})

the console prints null. I really don't see the point! Why the function works on Remix and not on Web3JS?


texts: Ethereum balance is 0 on local (geth) despite etherchain.org reporting it has ether

texts:
I bought some Ether over 4 hours ago:  https://etherchain.org/account/0x3d74c07013285b31049ecc7d9cb078cd1aa8ea96

When I run the following script on my local machine I get:

$ geth console
> function checkAllBalances() {
    var totalBal = 0;
    for (var acctNum in eth.accounts) {
        var acct = eth.accounts[acctNum];
        var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
        totalBal += parseFloat(acctBal);
        console.log("  eth.accounts[" + acctNum + "]: \t" + acct + " \tbalance: " + acctBal + " ether");
    }
    console.log("  Total balance: " + totalBal + " ether");
};
> checkAllBalances()
  eth.accounts[0]:    0x3d74c07013285b31049ecc7d9cb078cd1aa8ea96    balance: 0 ether

$ geth version
Geth
Version: 1.5.9-stable
Git Commit: a07539fb88db7231d18db918ed7a6a4e32f97450
Protocol Versions: [63 62]
Network Id: 1
Go Version: go1.8
OS: darwin
GOPATH=
GOROOT=/usr/local/Cellar/go/1.8/libexec


texts: Is it possible to use web3.js API methods to interact with Eris chains

texts: Is it possible to use the Web3.js API methods to interact with Eris blockchain? If yes, what should I pass in as the argument for setting the web3 provider?


texts: How to prefill fields on myetherwallet with given receiver address, amount, and gas limit?

texts:
Assuming I have a DApp that relies on people having some injected Web3 available such as MetaMask. If I detect that they do not have Web3, how can I forward them to myetherwallet offline transactions such that To Address, Value, and Gas Limit are prefilled?

What I mean is, it should look like this without users having to copy and paste the value, gas limit, and my address to send Ether from their account:


texts: What features are possible on Ethereum than can never be implemented with Rootstock

texts:
I understand that there are limitations to what type of code can run on the Bitcoin network and how much data can be stored in each transaction.

With a 2 way pegging like Rootstock many of the smart contracts allowed on Ethereum can be implemented at scale.

What features are unique to Ethereum and can never be implemented in Rootstock or a similar system?


texts: Would a pending transaction block all subsequent transactions?

texts:
I know that each ethereum transaction has a corresponding nonce, which is a positive increasing number. Say if tx1 with nonce 97 is still pending, would subsequent tx2 with nonce 98 also blocked until tx1 is processed? I haven't seen this behavior documented anywhere, but based on my personal trading experience, this seems the case - a previously blocked EtherDelta tx would block all subsequent txs, even subsequent txs are not originated from ED.

Can someone please explain a bit further? Thanks!


texts:
I have a question about how POS (ethereum casper) works. I am a little bit confused. So let's say User A decides to be a validator. So he has to have at least 1000Ether in his account to become a validator. When he does that, his 1000Eth becomes stake and is frozen. he can't use it anymore. Now, when new transactions happen in network, as we know it finally gets put into block and nodes make sure transactions are put into a new block as merkle trees. Now it's time to validate a block.

  What does that mean to validate a block, if transactions are already
  validated by nodes? why does a block need to be validated? how does a
  validator's node validate new block? I've also read about bets. What
  is bets? If a validator is malicious, he loses his stake or bet or
  what does he lose? That's the things i am really interested in. I'd
  appreciate it.


texts:
I am finding for the open source ethereum dapp example.

Could anyone recommend me any dapp that is fully operable by my own?

Thanks.


texts:
I am writing a function that requires a large fixed uint256 array as an input. The purpose of this function is to read one element of this large array and ignore all other elements.

    uint public test;

    function readArray(uint[10][10]["x"] _array) public {
        test = _array[1][1][1];
    }

To my (admittedly basic) knowledge, in this contract I am not doing anything explicitly gas expensive (such as altering or storing large amounts of this array). But as I increase "x" beyond around 10, everything crashes.

Is there anyway to input large amounts of data in to a contract without it crashing? (I am looking for an arbitrarily large value of x).

Thanks,
Andy


texts: How can I ensure a player matches another player's bet?

texts:
First, I want someone to send a bet (money) to the contract.
Then I want someone to match the original bet.

(There are many more safety checks in the contract. I just removed them to keep this as short as possible).
Let's say I have this:
pragma solidity >=0.5.10 <0.7.0;

contract test {

    constructor() public payable {
        require(msg.value > 0, "Must bet a positive amount");
    }

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

    function matchBet() external payable {
        require(msg.value == address(this).balance, "Must match original bet");
    }
}

I can deploy the contract.
I can view the pot (just to ensure everything is fine).
But then I try to send an equal amount with matchBet and it always says "Must match original bet".
Maybe I'm going crazy, but I swear this used to work.
I remember I implemented it after I asked this (from another account of mine): How can a Smart Contract pull an amount of Ether equal to its own balance from an External Account?
But now it's not working.
Why can't matchbet match the bet sent with the constructor?


texts:
I just opened a Coinbase account and purchased one ETH. Then I looked up the ETH wallet address (right on Coinbase), went to etherscan and searched for this address....Account was found, but doesn't show any balance or associated transaction. Please, advice.

P.S. Coinbase shows a balance of 1ETH


texts:
I am trying to get my hands on Oraclize, testing some sample queries with their Test query service. I can't get XML parser working with XPath. The documentation lacks an XML example.

Consider this simple feed.

The following query returns Dictionary.com Word of the Day, as expected:

xml(http://www.dictionary.com/wordoftheday/wotd.rss).rss.channel.title

The following semantically equivalent query that uses XPath returns nothing:

xml(http://www.dictionary.com/wordoftheday/wotd.rss).xpath(./rss/channel/title/text())

How can I query an RSS feed with Oraclize and filter the results according to come criteria (e.g., items with <user> field equal to Alice, etc)?


texts: convert padded topics address to valid address string

texts:
I am parsing some information from the topics array.

I receive 32bit padded addresses in some indexes. Is there a web3 utility function or useful helper method to get these back into normal sized addresses?

I'm not sure if I will remove the correct amount of 0's to get the same valid address Im looking for.

Please advise


texts: What options are suitable for Ethereum addresses with checksums?

texts:
Since Ethereum addresses don't have checksums, should ICAP addresses (which do have a checksum) be proliferated?

Or are there other options more suitable for the proliferation of checksummed Ethereum addresses?

For example, would this Ethereum Improvement Proposal (EIP) or some other be more suitable (for say an HD wallet)?

# code from EIP linked above
def checksum_encode(addr): # Takes a 20-byte binary address as input
    o = ''
    v = utils.big_endian_to_int(utils.sha3(addr))
    for i, c in enumerate(addr.encode('hex')):
        if c in '0123456789':
            o += c
        else:
            o += c.upper() if (v & (2**(255 - i))) else c.lower()
    return '0x'+o


texts: How to use web3js in vanilla javascript?

texts:
I used to use nodejs for working with web3js and it worked fine..But now I want to use vanilla javascript to connect with web3js.
I used CDN <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>, but didn't worked though..
$(document).ready(function () {
  if (window.ethereum) {
    window.web3 = new Web3(window.ethereum);
    try {
      // ask user for permission
      ethereum.enable();
      // user approved permission
    } catch (error) {
      // user rejected permission
      console.log("user rejected permission");
    }
  } else if (window.web3) {
    window.web3 = new Web3(window.web3.currentProvider);
    // no need to ask for permission
  } else {
    window.alert(
      "Non-Ethereum browser detected. You should consider trying MetaMask!"
    );
  }
});

Output: Non-Ethereum browser detected. You should consider trying
MetaMask!

PS: I have metamask installed


texts: How to add an address for which I have the corresponding private key into MEW?

texts:
I'm quite new to Ethereum, so, pls, forgive me if I say something wrong.

How can I see the balance of one already existing address, for which I have the corresponding private key, in MyEthereumWallet?

I would like to do so because it seems to me that MEW is very comfortable to use on the mobile.

So, to give you a little bit of background, here is what I did:

I created a wallet using Metamask using the usual 12 words.
Metamask provided me with an Ethereum address.
I bought some ETH through Coinbase, then transferred those ETH to the address defined at step 2, let's call it "my address".
All OK up to know, the correct ETH amount shows up in Metamask.
Then I installed MEW on my mobile because I would like to check the balance of "my address".
Sadly, I'm not able to add "my address" to MEW. It seems to me MEW is stuck with the single address it created during set up.

Any help is very appreciated. Thx in advance.

[EDIT]


texts: Original genesis.json file for ethereum mainnet, which should have 314 accounts allocation?

texts:
314 accounts are created at the start of ethereum frontier release and some funds were alloted to them.
https://www.etherchain.org/charts/totalAccounts

where can I get the genesis.json file used to create those 314 accounts on ethereum on 30 july 2015.

Thanks,
Shrey Baheti


texts: Which software is considered as an EVM Interpreter?

texts:
I am reading an article which talks about EVM interpreter but does not provide the name of interpreter. Is solc an EVM interpreter?

Zulfi.


texts: Who pays transaction fee ? Payer or Recipient of the ETH?

texts:
When we call address.transfer() or address.send() to transfer ETH, who has to pay transaction fee ? Payer or Recipient  of the ETH? And is there any option to choose payer of the fee or gas?

Updating :

Note 1 : According to this page:

   if Bob (payer) were to make an on-chain transaction for each tweet, 20% of Alice (recipient) ’s income would be eaten up by fees.

Meaning that it's recipient who has to pay transaction fee, isn't it?

Note 2 : According to this page:

  Instead of calling a function myself to initiate a payment, I’ll let the receiver of the payment do that—and therefore pay the transaction fee

Meaning that it's recipient who has to pay transaction fee. And is there any advantage if the recipient pays the transaction fee ?

What can we conclude ?


texts: Does delegatecall() use only the calling function?

texts:
Let me explain with the code:
contract A {
 function f() public {
  [...]
  g();
}

 function g() private {
  [...]
 }
}

contract B {
 A a;
 function delegateA() public {
  (bool success, ) = address(a).delegatecall(abi.encodeWithSignature("f()"));
 }
}

If B uses delegatecall() to call f() with its own storage, is a problem avoiding to write even the g() function on the B contract? I mean, I know that the structure of the storage of A must be the same as B, and the functions don't partecipate to it, so what about directly not writing the private functions which are used by A?


texts: Defining "listen," "listenaddr" and "discovery" ports from admin.nodeinfo?

texts:
f you type "admin.nodeInfo" at the javascript console, you will see:

 listenAddr: "[::]:<value>",
  name: "Geth/v1.6.1-stable-021c3c28/linux-amd64/go1.8.1",
  ports: {
    discovery: <value>,
    listener: <value>
  },

(along with a bunch of other stuff, of course.)

So we have these three ports: listenAddr, listener, discovery.  What does each one of them mean in this context.

I am not asking about the RPC port or the websockets port.  I am specifically asking about the thing that I just mentioned.


texts: Error openning the Ethereum wallet win64 0-8-8 on Windows 10

texts:
I'm getting this error when opening the Ethereum Wallet x64 version 0.8.8 on Windows 10:

And then I see this window:

I don't see any log file, but i see below Information in Windows Event log Security section:

A new process has been created.

Creator Subject:
    Security ID:        REDMOND\v-arkouk
    Account Name:       v-arkouk
    Account Domain:     REDMOND
    Logon ID:       0x2E1378

Target Subject:
    Security ID:        NULL SID
    Account Name:       -
    Account Domain:     -
    Logon ID:       0x0

Process Information:
    New Process ID:     0x1224
    New Process Name:   C:\Users\v-arkouk\AppData\Roaming\Ethereum Wallet\binaries\Geth\unpacked\geth.exe
    Token Elevation Type:   %%1938
    Mandatory Label:        Mandatory Label\Medium Mandatory Level
    Creator Process ID: 0x3a3c
    Creator Process Name:   C:\Users\v-arkouk\Downloads\Ethereum-Wallet-win64-0-8-8\win-unpacked\Ethereum Wallet.exe
    Process Command Line:   "C:\Users\v-arkouk\AppData\Roaming\Ethereum Wallet\binaries\Geth\unpacked\geth.exe" version

Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy.

Type 1 is a full token with no privileges removed or groups disabled.  A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account.

Type 2 is an elevated token with no privileges removed or groups disabled.  An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator.  An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group.

Type 3 is a limited token with administrative privileges removed and administrative groups disabled.  The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator.

Any ideas?


texts: Recovering Contract Address varies every time

texts:
I have a contract datafactorycontract  that calls another contract dataproducercontract. For that, in datafactorycontract I have a mapping that stores the address of the dataproducercontract being its name the key.I create the dataproducercontract on my own and then pass the address and the name to a function in the datafactorycontract. Code:

contract DataBankFactory
{

 address owner;
 mapping (string => address) dataProducerContracts;

    // Constructor
 function DataBankFactory()
 {
    owner = msg.sender;
 }

 function setProducer (string name, address add) returns (bool)
 {
    if(msg.sender == owner)
    {
        dataProducerContracts[name] = add;
        NewProducerContractAdded (name);
        return true;
    }
 }

 function getProducerAddress (string name) returns (address)
 {
    return dataProducerContracts[name];
 }
}

contract DataBankProducerContract
{
 string pname;
 uint balance;
 function DataBankProducerContract(string name, uint initbalance)
 {
    pname = name;
    balance = initbalance;
 }

}

Then, in javascript, I try to get the address of the contract stored:

var factoryAddress = HARDCODED_VALUE;
var hcproducerAddress = HARDCODED_VALUE;
var producerAddress;

factory= web3.eth.contract(ABIFACTORY).at(factoryAddress);

var producerAddress = factory.getProducerAddress(sender);
console.log('hardcoded producer address:' + hcproducerAddress);
console.log('obtained producer address:' + producerAddress);

being the result different:

hardcoded producer address:0x2a5e1E82bBf8CeEfacb72c3103Cb531942d36cC8
obtained producer address:0x03e29a82321f451f674edbd85178b4fe7013b43ca0376868903cecdd2649f48c

This last "address" varies every time

Does anybody know what I am doing wrong here? I've checked examples, and it looks things are done like this. I do not know what is it I am getting when I retrieve the address.


texts:
I am trying to send automatic payments in C# by linking a button to web3 code for a transfer.

Essentially I need to create a function/button that sends Ether or Tokens out of my wallet when it is clicked.

So for example I could just hit the button and the transaction sends to the address I hardcoded in at the amount of gwei I chose. I would like to do this in C#.

For for example in C#, it might look something like

public void sendMoney(){
transfer.initiate(AMOUNT_OF_ETH, MY_PRIVATE_KEY, DestinationWallet.eth, 1 gwei, GAS_LIMIT_HERE);
}

Now I'd have a function that I could call anytime to send the ETH or tokens to my destination wallet.

I understand the wallet could be totally drained if the button is spammed, and that's no problem.

Is there a way to set up these auto buttons so payments could be send without using metamask?

Thanks for any input


texts:
When I try to create my contract on remix using metamask (injected web3/Ropsten) I set gas limit to 4700000 in remix and press Create. When MetaMask opens it asks me to lower my gas fee under a certain amount. Once I lower it (if I don't I can't create it) the contract gets created BUT my variables inside the contract are not initialized. For example a var a = 10; is returning 0.

How can I overcome this problem?

pragma solidity ^0.4.20;
import "./oraclize.sol";

contract Casino is usingOraclize {
   address owner;
   uint public betAmount = 30 finney; //Equal to 0.01 Ether
   uint public totalBet; //Amount of Ether bet for current game
   uint public numberOfBets; //Total number of current bets
   //uint public maxAmountOfBets = 1 //Maximum amount of bets can be made for each game by each user
   uint public limitAmountOfBets = 3; //Maximum amount of bets for each game
   uint public numberWinner; //Number that won last game
   address[] public players; //Players
   mapping(uint => address[]) numberBetPlayers; //Who bet for which number
   mapping(address => uint) playerBetsNumber; //Number bet by each player

   modifier onEndGame() {
       if(numberOfBets >= limitAmountOfBets) _;
   }

   //constructor - set bet amount and max bets in each game
   function Casino(uint _betAmount, uint _limitAmountOfBets) {
       owner = msg.sender; //set creator of contract to owner

       if(_betAmount > 0) betAmount = _betAmount;
       if(_limitAmountOfBets > 0) limitAmountOfBets = _limitAmountOfBets;

       oraclize_setProof(proofType_Ledger); //arge
   }

   //check if player exists in current game
   function checkPlayerExists(address player) public returns(bool) {
       if(playerBetsNumber[player] > 0) return true;
       else return false;
   }

   //bet function
   function bet(uint numberToBet) payable {
       require(numberOfBets <= limitAmountOfBets); //check if limit has been reached
       require(!checkPlayerExists(msg.sender)); //check that player hasn't bet before
       require(numberToBet >=1 && numberToBet <= 10); //check that the bet is between 1 and 10
       require(msg.value == betAmount); //check that ether send by sender is equal to bet amount

       playerBetsNumber[msg.sender] = numberToBet;
       numberBetPlayers[numberToBet].push(msg.sender);

       numberOfBets += 1;
       totalBet += msg.value;

       if(numberOfBets >= limitAmountOfBets) generateNumberWinner();
   }

   //generate random numbers using oraclize_newRandomDSQuery function
   function generateNumberWinner() payable onEndGame {
       uint numberRandomBytes = 4;
       uint delay = 0;
       uint callbackGas = 200000;

       bytes32 queryId = oraclize_newRandomDSQuery(delay, numberRandomBytes, callbackGas);
   }

   function __calback(bytes32 _queryId, string _result, bytes _proof) oraclize_randomDS_proofVerify(_queryId, _result, _proof) onEndGame {
       assert(msg.sender == oraclize_cbAddress());

       numberWinner = (uint(sha3(_result))%10+1);
       distributePrizes();
   }

   function distributePrizes() onEndGame {
       uint winnerEtherAmount = totalBet / numberBetPlayers[numberWinner].length; //how much each winner will get

       for(uint i = 0; i < numberBetPlayers[numberWinner].length; i++) { //sent ether to addresses
           numberBetPlayers[numberWinner][i].transfer(winnerEtherAmount);
       }

       for(uint j = 1; j <= 10; j++) {
           numberBetPlayers[j].length = 0;
       }

       totalBet = 0;
       numberOfBets = 0;
   }
}


texts:
On many token sale site I see workflow when user suggested to send ETH to one time address and it is changed each time I refreshing page. I am trying to understand how it implemented?

Only way I see is to have main contract that acts as factory that can create children contracts per request that only has fallback function that forwards incoming ETH, msg.sender and msg.value to the main one. But this approach looks insecure - each subcontract creation takes gas and I potentially can exhaust main contract only by refreshing site's page and asking each time for new pay-in address.

Could you explain how it works?


texts: How to encode dynamic types when calling a contract function?

texts:
I am trying to figure out how to calculate the offset in bytes to the start of their data area, measured from the start of the value encoding as described here in the Solidity docs for dynamic parameter types.

Here is my function that I would like to call on my deployed contract:

function myFunction(
        address _address,
        bytes _name,
        bytes32[] _choices,
        uint256 _blockNumber)
        public
    {
    }

How do I calculate the offset for bytes _name and bytes32[] _choices?

I normally use ethabi to encode my parameters, but I don't think it's able to output what I need here?

Any help is appreciated!


texts: web3.js and require.js - unexpected identifiyer issue

texts:
I'm testing the web3 api, but it seems to be an error when I try require('web3').

Require.js indicates that there is an error inside web3.js, but I have the latest release of web3. Maybe I have a wrong use of it. Can you help me ?

You can find bellow my code and the error:


texts: How do sites like Opensea get all their data so fast? Because getting the data from the blockchain and fetching the tokenURi's takes a lot of time. So I thought they might store all the assets, events, users in a database, but wouldn't that be a huge amount of data?


texts:
I am trying to connect to Kovan testnet from a Node.js server. I have tried to connect in order to retrieve past events.
Steps tried so far:- The connection was done via Infura. Tried these steps over multiple versions

Version 0.20.3(Version in Github):

var MyContract = web3.eth.contract(JSON);

contractAddress=<contractAddress>;
var contractInstance = MyContract.at(contractAddress);
var events = contractInstance.allEvents({fromBlock: 5000000, toBlock: 'latest'});

events.get(function(error, logs){
    console.log(logs);
});

Despite having events no output are produced. If Infura is the issue is there any other way I can get events from Kovan Testnet?

I tried web3-1.0.0.beta19 to connect to Infura via websockets but realised there are no websockets for Kovan.


texts: Is there a way to reverse engineer and know the ABI of a contract just by knowing its contract address?

texts:
Let me be clear on this, here i want reverse functionality. I have the contract address generated and i am able to access it in the mined block. However i want to know what is the data in ABI json once again. Please let me know if its possible. Else minimum requirement for getting JSON file(without using contract code).

Thanks in advance for your help.


texts: Can a transaction be pending indefinitely?

texts:
Is an eth transaction guaranteed to be processed at some time? In other words:
Can a transaction be pending indefinitely or will it eventually be canceled, forgotten, or confirmed (by the network?!?)?


texts: What is Ethereum mainnet - Byzantium fork status

texts: I don't understand the loops with different Hash but same block number @ http://status.ethereum.org/. Are they Uncles?


texts: Getting wrong nonce when trying to send transaction

texts:
Im using opencv in ganache in this app to send an ethereum transaction
In my app im getting the transaction that i send like that
nonce = web3.eth.getTransactionCount(account_1)

tx = {
'nonce': nonce,
'to': account_2,
'value': web3.toWei(1, 'ether'),
'gas': 21000,
'gasPrice': web3.toWei('500', 'gwei')
}
print(nonce)

and i send the transaction with this part
if len(smiles) > 0 :
            cv2.putText(frame, 'you are smiling', (x, y+h+40), fontScale=3, fontFace=cv2.FONT_HERSHEY_PLAIN, color=(255, 255, 255))
            signed_tx = web3.eth.account.signTransaction(tx, private_key)
            tx_hash = web3.eth.sendRawTransaction(signed_tx.rawTransaction)
        else:
            cv2.putText(frame, 'Smile to send tx', (x, y+h+40), fontScale=3, fontFace=cv2.FONT_HERSHEY_PLAIN, color=(255, 255, 255))

When i run the code i get this error message:
ValueError: {'message': "the tx doesn't have the correct nonce. account has nonce of: 13 tx has nonce of: 14", 'code': -32000, 'data': {'stack': 'Error: \n    at validateNonce (/tmp/.mount_ganachnBhuGM/resources/app.asar/node_modules/ganache-core/lib/statemanager.js:964

I have tried to change the nonce like that:
tx = {
'nonce': nonce + 1,  #and also nonce -1,
'to': account_2,
'value': web3.toWei(1, 'ether'),
'gas': 21000,
'gasPrice': web3.toWei('500', 'gwei')
}
which didnt change anything on the error


texts:
I am a new learner in solidity.
My simple contract cannot compile in remix and I do not know how to fix the error in line 18 (the declaration of uploadStudent). The error is 'Data location can be specified for array, struct, or mapping types, but 'memory' was given.'
May I have your help?
pragma solidity ^0.6.0;

contract simple {
  mapping(uint => studentFile) public studentfiles;

  uint studentCount;

  struct studentFile {
    uint studentId;
    string studentName;
    uint age;
  }

  constructor() public {
      studentCount=0;
  }

  function uploadStudent(string memory _studentName, uint memory _age) public {

    // Increment student id
    studentCount ++;

    // Add File to the contract
    studentfiles(studentCount) = studentFile(studentCount, _studentName, _age);
  }
}