texts:
Using web3js v1.2.1

const contract = new web3.eth.Contract(abi, '0x29...');
const amount = 1 * 10 ** 18;
const data = contract.methods.transfer(recipient, amount).encodeABI();

I get error :

invalid number value (arg="value", coderType="uint256", val

 reason: 'invalid number value',
  code: 'INVALID_ARGUMENT',
  arg: 'value',
  coderType: 'uint256',
  value: 1000000000000000000 }

This should work:

const amount = web3.utils.toHex(1e18)


texts: web3 1.0.0-beta example for etherscan websocket?

texts:
Does anyone have a working JS example for wss://socket.etherscan.io/wshandler?

Or any alternative websocket providers, besides Infura?

The reason I'm looking for Infura alternatives is it fails for me in two ways that are pretty much blockers:

1) it doesn't implement ping/pong and therefore I get random disconnects. I haven't found a bulletproof workaround, though I tried
a) subscribing for new blocks
b) calling contract immutable methods periodically

2) there seems to be a problem with larger chunks of data when e.g. calling getPastEvents to fetch blocks with a big number of transactions consistently result in disconnect with Error: CONNECTION ERROR: Couldn't connect to node on IPC. I don't know if this is Infura's fault or e.g. websocket or else - but I thought maybe I start by testing a different provider. Any other debugging suggestions would be appreciated.


texts: Performing a smart escrow with ERC20 tokens

texts:
After developing a token Smart Contract that is compliant with the ERC20 standard https://github.com/ethereum/EIPs/issues/20 (is that the same as token API https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs ? ) and a escrow Smart Contract too, I want to use the escrow contract to manage tokens instead of Ether. I guess that is possible by implementing calls to the token contract inside the escrow contract, right?

So, I have two questions:

1.- Can I develop a universal escrow contract that accepts any kind of tokens, not just my own, using the token contract hardcoded address?

2.- If gas is out while executing the escrow and token contract has been called from escrow contract, would token transfers be rollback?

Thx for any hint about these topics.

References:
    Can I use my own coin in 3rd party contracts?
    How can I know if a token that I created is used in a smart contract?
    How can ERC20 token implementations be verified?


texts: creating multi signature wallet for my custom token

texts:
I have created a custom token named VCF token as

pragma solidity ^0.4.18;
import './IERC20Basic.sol';
import './SafeMath.sol';

contract VfcToken  is IERC20Basic{

    using SafeMath for uint256;

    uint256 public _totalSupply ;
    string public constant symbol = "VFC";
    string public constant name = "Vfc Token";
    uint8 public constant decimals = 1;

    mapping(address => uint256) balances;

    function VfcToken() public{
        _totalSupply = 10;
        balances[msg.sender] = _totalSupply;
    }

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

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

    function transfer(address _to, uint256 _value) external returns (bool){
        require(_to != address(0)
                && _value > uint256(0)
                && _value <= balances[msg.sender]);

        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        Transfer(msg.sender, _to, _value);
        return true;

    }
}

I want these tokens to be spent only by the authentication of not one but two addresses as in multi-signature wallet, how can I implement that feature within my contract?


texts: IPFS gateway not getting my files , Keeps on loading without any errors

texts:
After making all the client side scripts inside a folder which are needed for my website (in dist folder)

checked with ipfs swarm peers : shows many results

then adding the files with ipfs add -r dist/

proceeded with ipfs name publish < root hash ie hash of dist  >

when in browser gateway.ipfs.io/ipfs/<new_given_hash>

the browser keeps loading and no errors in ipfs daemon running terminal


texts:
Is there any solid justification that every blockchain is a distributed ledger, but not every distributed ledger is a blockchain?.

What are the main differences between blockchains & distributed ledger technology from a technical perspective?

Why did some researchers say that distributed ledger is different than blockchain,  on other side said that blockchain is same as from a technical perspective?

Note:  Common keywords for distributed ledger are (shared ledger, or Distributed Ledger Technology, DLT)

I wish if someone could provide a solid justification for it, especially, from the technical perspective not as the definition of the above term.


texts: Has anyone set up a prediction market on the ETH/USD price conditioned on a hardfork/softfork/nofork?

texts:
I know Vitalik has talked about using prediction markets as a way for community members to decide on forks.

There are basically 3 proposals that I've seen.

Hardfork to return all funds to the DAO
Softfork to freeze the stolen funds (but not return them)
Do not fork at all and let the thief keep their winnings

There are strong feelings for and against these proposals but I think the vast majority of people are arguing their side because they want Ethereum to continue to thrive.

If there were a prediction market that definitively showed that one of these proposals was better for the ETH/USD trading price, I would certainly switch to supporting that stance. Is this type of thing being done?


texts: Funding contract with LINK tokens revert error

texts:
When I try creating a Chainlink contract from "master contract" and fund it with LINK, I keep getting the error:
"VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information."
What am I doing wrong? Here's my REMIX code: https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&evmVersion=null&gist=79cf8c59f1fbf6e6a0327920c9a9c49a


texts:
I have Mist 0.9.0 and Geth 1.6.7 running on Windows 8.1 x64.

Why am I get this error message when I open Mist?

What I did:

geth --datadir=$HOME/.rinkeby init C:\projects\rinkeby\rinkeby.json
geth --datadir=$HOME/.rinkeby

In another prompt window

geth --rinkeby attach

And double click on Mist.exe


texts: Multiple inheritance and order of chaining of multiple base constructors

texts:
I am trying to understand the order of invocation of base class constructors in the presence of multiple inheritance. As far as I can tell, the order appears under-specified in the  Solidity documentation below:

http://solidity.readthedocs.io/en/develop/contracts.html#arguments-for-base-constructors
http://solidity.readthedocs.io/en/develop/contracts.html#multiple-inheritance-and-linearization

I have also gone through related questions in Stackexchange, but they do not address the issue with chaining multiple base constructors.

My understanding from Remix is that order of invocation of base constructors depends on the order of inheritance of the derived contract, and does not depend on the order in the constructor.  For example, in both the cases below, the constructor for B is invoked before C.

contract B {
    function B() public {emit PrintB();}
    event PrintB();
}

contract C {
    function C() public {emit PrintC();}
    event PrintC();
}

contract D is B, C {
    function D() C() B() {}
}

contract E is B, C {
    function E() B() C() {}
}

Can someone confirm if my understanding is correct?

If indeed my understanding is correct, is it documented in the Solidity specification, or is it just a feature of the current implementation and may change in the future.

Thanks for your help!


texts: Can the same keypair be used for holding ETH and different ERC20 tokens?

texts:
I have an ETH keypair.

Can I hold ERC20 tokens with this ETH keypair also?
Can I hold several ERC20 tokens with one key pair?


texts: With the recent release of the FOMO3D exploit in its smart contract, how does the exploit work?


texts: How to get the bytecode of a transaction using the solidity-browser?

texts: I want to get the bytecode to put in the "MyEtherWallet/Send-Ether" when I want to make some transaction, sending some ether to some contract, to call some function in the contract. I need to use the "Solidity-Browser" to this end.


texts:
I was trying to create an account via geth. My question is about using the non-interactive password input.

With the following variables :

GETH_ROOT_PATH="${HOME}/Chain_Test"
GETH_DATA_DIR="${GETH_ROOT_PATH}/chaindata"
BR2="}"
PASSWORD="${GETH_ROOT_PATH}/passwordfile.txt" => in this file, I have something like :

l1: {ADDR1}password1

l2: {ADDR2}password2

.....

So I have tried this :

geth account new --datadir ${GETH_DATA_DIR} --password awk -F"$BR2" '[ print $2 ]' ${PASSWORD}

So what I wanted is to go to the password file and take the output following the "}" and to make it as the password of the account.

But it didn't work.
Could you help please ?


texts: Contracts not running in Web3 after upgrading to solidity 0.5

texts:
I have a cotract that used to work with web3 and solidity 0.4.21 now I'haven't been able to get a god answer from web3 although my tests work perfectly. this is my contract:

pragma solidity >=0.4.21 <0.6.0;

import "./MyContract.sol";

contract ContractsManager {

    address public owner;
    MyContract[] public contracts;

    constructor() public{
        owner = msg.sender;
    }

    function getContracts() public view returns (MyContract[] memory) {
        return contratos;
    }
}

This is my js:

if (typeof web3 !== 'undefined') {
    this.web3Provider = web3.currentProvider;
}
else {
    this.web3Provider = new Web3.providers.HttpProvider('http://localhost:8545');
}
web3 = new Web3(this.web3Provider);

var ContractsManagerArtifact = await $.getJSON('ContractsManager.json');
var MyContractArtifact = await $.getJSON('MyContract.json');

this.solContracts.ContractsManager = TruffleContract(ContractsManagerArtifact);
this.solContracts.MyContract = TruffleContract(MyContractArtifact);

this.solContracts.ContractsManager.setProvider(this.web3Provider);
this.solContracts.MyContract.setProvider(this.web3Provider);

this.manager = await this.solContracts.ContractsManager.deployed();
var addresses = await this.manager.getContracts();

for (let i = 0; i < addresses.length; i++) {
    var address = addresses[i];
    var contratoSol = await this.solContracts.MyContract.at(address);
}

When I test my getContracts() function using truffle test, it returns an empty array [] but in my javascript the getContracts() function its returning undefined.

I tried changing my web3.js version with the same result, am I missing something for solidity 5.0 to work well with web3.js?

Thanks


texts: Return values of function which just set a value

texts:
If I have a function that just sets a value like this:

  function setBytes(
    bytes32 _value
  ) public {
    testBytes = _value;
  }

Should this kind of functions return a value or should the function remain without a return if the function is called from another contract? In some code examples, I have seen that this kind of functions returns true. Like this:

  function setBytes(
    bytes32 _value
  ) public returns(bool success) {
    testBytes = _value;
    return true;
  }

What is the best practice in such cases and what is the purpose of returning true?


texts:
I am trying to transfer tokens from myEtherWallet and Codebase in C#.
I found a code sample https://github.com/maxpaynestory/Nethereum.ERC20.Token.Transfer.Sample/blob/master/EthereumClient.cs
and have this code:

var transactionMessage = new TransferFunction()
        {
            FromAddress = accountFrom,
            To = accountTo,
            AmountToSend = tokens
        };
var transferHandler = web.Eth.GetContractTransactionHandler<TransferFunction>();
Task<string> transactionHashTask = transferHandler.SendRequestAsync(transactionMessage, contractAddress);
return await transactionHashTask;

For the contract address I am using the contract address of the token(https://etherscan.io/address/0xb92c39977f18c25121a76748a6cc25c29584a12c).

I keep getting an error "gas required exceeds allowance or always failing transaction"
I changed the token amount to be a lot less then the account balance and I have enough ETH in the account to cover gas.


texts:
I withdrew KBC from my HitBTC account to my countries local crypto app LUNO which only supports ETH.
This transaction was sucssesfull however I can not retrieve it from my Luno account. They say it cannot be recieved.
Is there anyway to reverse it or get this crypto back


texts: Deploying contract with constructor arguments via Geth RPC

texts:
How can I deploy a compiled contract with constructor arguments using geth rpc?

I have tested my call deployed the compiled contract bytecode just fine, I just don't understand how I can pass constructor arguments via an rpc call in the form:

{'jsonrpc': '2.0', 'method': 'eth_sendTransaction', 'params': [{'from': account, 'contract': contract}], 'id': 1}

Thanks


texts: Is this function prone to underflow hacking?

texts:
So I want to write as simple as possible withdrawal function in a token contract which also doesn't use Safemath for one very simple reason: I admit I don't understand well enough data types in EVM so I'll rather stick to basic logical statements to prevent hacking, so how safe is this:

function withdrawTokens(uint _amount) external returns (uint _available) {

        _available = _amount < balances[msg.sender] ? _amount :     balances[msg.sender];
        msg.sender.transfer(_available);
        balances[msg.sender] -= _available;
        emit eventWithd(msg.sender, _available);

    }

My major concern is this line:

    balances[msg.sender] -= _available;

This will obviously underflow if the balance of the msg.sender is say 5 and they send 6 as argument (5-6 = -1 but in uint it's huge positive number...), so I am betting on the fact that at least one of these 2 lines will revert thus never reaching the dangerous line above:

 _available = _amount < balances[msg.sender] ? _amount balances[msg.sender];
        msg.sender.transfer(_available);

Any thoughts? Thanx a lot!


texts:
I'm trying to call Smart Contract with next method signature

calculateHash(string)

and Code like:

function calculateHash( string testStr ) constant returns ( bytes32 ){
    return sha3( testStr );
  }

I have next Sha3:
0xa8cbcecd37e0c4ac16c3135987b900352c43486006715fbca927444ab937b3af
so first 4 bytes looks like 0xa8cbcecd
Parameter for example is "Hello, Words!"
According to ABI documentation I should encocde it like

bytes, of length k (which is assumed to be of type uint256):

enc(X) = enc(k) pad_right(X), i.e. the number of bytes is encoded as a uint256 followed by the actual value of X as a byte sequence, followed by the minimum number of zero-bytes such that len(enc(X)) is a multiple of 32.

string:

enc(X) = enc(enc_utf8(X)), i.e. X is utf-8 encoded and this value is interpreted as of bytes type and encoded further. Note that the length used in this subsequent encoding is the number of bytes of the utf-8 encoded string, not its number of characters.

so in my case it is

enc(enc_utf8("Hello, World!)) = end(Ox48656c6c6f2c20576f726c6421) =
000000000000000000000000000000000000000000000000000000000000000d
48656c6c6f2c20576f726c642100000000000000000000000000000000000000

so full POST looks like

{"method":"eth_call","params":[{"from":"0x0027440CB2A41a3CF38Da9f89B0380311D146330","to":"0x3aDbCF5E934B0D78F0012C173032E2e2f3586F63","data":"0xa8cbcecd000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20576f726c642100000000000000000000000000000000000000"}],"id":2,"jsonrpc":"2.0"}

But I have next return {
    "jsonrpc": "2.0",
    "result": "0x",
    "id": 2
}

Where is my mistake?
Thank you
Alex


texts: Parity: Is deleting ~/.ethash folder also deletes chain data?

texts:
I am not doing any mining and I want to clean unnessary files due to my limited memory space. I realized that ~/.ethash folder contains around 3.5 GiB. I am not sure should we keep it for the chain-data syncing process.

~/.ethash$ ls
full-R23-0000000000000000  full-R23-5a46dd85298b0bef  full-R23-7e7d8bef9d86983a  light

/.ethash$ du -h
45M ./light
3.6G    .

[Q] When I remove ~/.ethash folder does it also removes Parity's chain-data?

Thank you for your valuable time and help.


texts: Transactions from myetherwallet.com not going through

texts:
I created yesterday a wallet at https://www.myetherwallet.com, however I tried to send some small amounts into three different wallets but none is going through.

If you look at etherscan.io the ether seems still to be at my wallet:

https://etherscan.io/address/0xac541c3c698a729ebf6c42419860cdddabd622a6

However the amounts to be sent are staying pending and the time when it was sent is changing always to a few seconds. Sometimes they are not showing at all and I need to refresh the page to see them again.

Are these approx. 2 Eth now lost? It's been almost a day since I sent my first amount.

What about the rest in my wallet, how can I prevent losing my Ether there?

Thank you in advance!


texts: I ran geth --rpc. I got to block ~15,000,000 but then it suddenly went back to ~4,000,000. Now it's super slow. Maybe 1 minute per block. Why is it suddenly so slow? I never got a finished message. Did I finish and new blocks are just being created?


texts: How does Uniswap calculate price impact without fee on the swap page?

texts:
Context: We are creating a smart contract which integrates Uniswap DEX for swapping Tokens to ETH. We need to make sure one swap does not impact the token price more than 3%.
We are in need to write a function which takes in input the price_impact: uint, reserve0: uint and reserve1: uint and outputs the maximum amount of tokens which when swapped for ETH on uniswap will have the given price impact on the token price.
So, can someone please help in understanding how is the price impact calculated on the uniswap swap page, and also in writing a function which ouputs maximum number of tokens to be swapped for ETH which would have the given price impact?

Exchange: https://uniswap.org
Docs: https://uniswap.org/docs/v2
Pricing Docs: https://uniswap.org/docs/v2/javascript-SDK/pricing
Glossary: https://uniswap.org/docs/v2/protocol-overview/glossary/#docs-header


texts:
Hello World !

I'm trying to find a way to shuffle an array of addresses in Solidity !

Looking at Underscore / Lodash source code _.shuffle() points out a few things.

_.shuffle([1, 2, 3, 4]);
  * // => [4, 1, 3, 2]

Something like:

address[] public players;
// Players addresses     -> 0x00001, 0x00001, 0x00002
// _.shuffle(players[]); -> 0x00002, 0x00001, 0x00001
// _.shuffle(players[]); -> 0x00001, 0x00002, 0x00001

EDIT with Example:

address[] public players;

function enter() public payable {
    require( msg.value >= .01 ether && msg.value % .01 ether == 0 );

    uint ticketCount = msg.value / .01 ether;
    for(uint i = 0; i < ticketCount; i++){
        players.push(msg.sender);
    }
}

function getPlayers() public view returns (address[]) {
    return players;
}

// Take this scenario, each ticket is worth 0.01 ether.
// Two players decide to play. One buys 3 tickets and the other 2 tickets.
// We push the first player address 3 times and 2 times into our players array.
// Player 1 address is duplicated 3 times, players 2 address is duplicated twice.
// In our players array there are a total of 5 addresses stored.

When we call the getPlayers() function after the players have deposited their ether we get:

0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C,
0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C,
0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C,
0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB,
0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB,

I'm pretty sure this is a bad way to do it and might require extra gas to be spent. At the end of the game our players array of will reset but i'm sure that keeping logs about how much a player has deposited might be a better way to approach this matter. I still hope to find a better way than just moving most of the random logic on the of-chain and loose trust and security ...

Hope someone already has a better way !


texts: How do DAO's investors or founders make profit?

texts:
I am hearing a lot about DAOs and their up as well as downsides. But I still didn't understand " How can a investor investing his ether in a DAO make profit?". Say for examples I funded a DAO by giving 20ether. Where do I get profit from?
I am new to ethereum so try to explain in plain english. Thank You!


texts:
I'm trying to write a code that reads variable, adds 1, sends update call, waits until the transaction is done and then reads the variable again.
Console shows that the transaction is complete, but if I read the variable it gives me the previous result.
What is wrong here?
edit
It SOMETIMES displays variable correctly. So there is most likely an async problem somewhere.
Solidity:
pragma solidity ^0.4.22;

contract Test
{
    uint public v;

    function updateV(uint value)
        external
    {
        v = value;
    }
}

JS code:
let rrr = await promisify(cb => contract.v(cb));
rrr = rrr.toNumber();
console.log("received value: " + rrr);
rrr++;
console.log("should return: " + rrr);
let hash = await promisify(cb => contract.updateV(rrr, cb));
await waitForReceipt(hash);
rrr = await promisify(cb => contract.v(cb));
console.log("returns: " + rrr.toNumber());

JS function:
async function waitForReceipt(hash) {
    await new Promise((resolve, reject) => {
        let timer = window.setInterval(function () {
            web3.eth.getTransactionReceipt(hash, function (err, receipt) {
                console.log("check");
                if (err) {
                    clearInterval(timer);
                    reject(err);
                    console.log("nope");
                }

                if (receipt !== null) {
                    clearInterval(timer);
                    resolve(receipt);
                    console.log("ok");
                }
            });
        }, 1000);
    })
}

Console result:
received value: 20
(index):1093 should return: 21
9(index):1068 check
(index):1078 ok
(index):1097 returns: 20


texts:
Apparently they are running a full node which we can attach our geth.

  We are running 4 public Geth nodes in AWS EC2 and you can attach or
  RPC to them.

  IP address: 52.208.46.161

  Main net, it is a full node and started with:

geth --port 30302 --rpc --rpcport 8546 --rpcaddr 0.0.0.0 --rpccorsdomain "*" --rpcapi "eth,web3,net" --lightserv 25 --lightpeers 50 RPC port: 8546

but when I do

geth attach http://52.208.46.161:8546

I get

Fatal: Failed to start the JavaScript console: api modules: Post http://52.208.46.161:8546: dial tcp 52.208.46.161:8546: getsockopt: connection refused

I hardly think that post is out of date as it's only a week old. How can I check the status of such a node?

http://help.b9lab.com/eth-developer-course-technical-help/our-public-geth-nodes


texts: How many "shares" I got, submitted, or checked by this claymore display?

texts:
ETH - Total Speed: 175.728 Mh/s, Total Shares: 2117, Rejected: 0, Time: 14:13
ETH: GPU0 29.088 Mh/s, GPU1 29.468 Mh/s, GPU2 29.079 Mh/s, GPU3 29.058 Mh/s, GPU4 29.970 Mh/s, GPU5 29.066 Mh/s
 SC - Total Speed: 3514.556 Mh/s, Total Shares: 17548, Rejected: 83
 SC: GPU0 581.755 Mh/s, GPU1 589.354 Mh/s, GPU2 581.571 Mh/s, GPU3 581.169 Mh/s, GPU4 599.390 Mh/s, GPU5 581.317 Mh/s
 SC: 05/02/17-09:24:44 - SHARE FOUND - (GPU 3)
 SC: Share accepted (281 ms)!
 SC: 05/02/17-09:24:49 - SHARE FOUND - (GPU 4)
 SC: Share accepted (656 ms)!
 SC: 05/02/17-09:24:50 - SHARE FOUND - (GPU 3)
 SC: 05/02/17-09:24:50 - SHARE FOUND - (GPU 5)
 SC: Share accepted (453 ms)!
 SC: Share accepted (1250 ms)!
GPU0 t=67C fan=71%
ETH: 05/02/17-09:24:53 - SHARE FOUND - (GPU 2)
ETH: Share accepted (437 ms)!
 SC: 05/02/17-09:24:55 - SHARE FOUND - (GPU 2)
 SC: 05/02/17-09:24:55 - SHARE FOUND - (GPU 3)
 SC: 05/02/17-09:24:55 - SHARE FOUND - (GPU 4)
 SC: Share accepted (156 ms)!
 SC: 05/02/17-09:24:56 - SHARE FOUND - (GPU 1)

Sometimes I got "SHARE FOUND"

Sometimes I got Total Speed: 3514.556 Mh/s, Total Shares: 17548, Rejected: 83

What is going on?

How many shares I actually get?

Do I get a share every time I got SHARE FOUND

or do I get 17548 share once every 10 seconds or so?

The way I understand how stratum proxy works is most hash are not transmitted.

So my GPU in ETH, for example, have 29 mh/s. And most of those 29 mh every second is not even transferred to mother board at all. A few at higher difficulty is then transferred to stratum pool.

What percentage is transferred to motherboard and what percentage is transferred to stratum proxy?

And how does that effect what claymore dual miner display?


texts: My smart contract has a dynamic array inside a struct, however, while there are no errors, it is not running properly. Can you have a dynamic array in a struct in solidity? If not, should I use a mapping?


texts: Compiler version incompatibility nightmare

texts:
I'm new to Solidity and Truffle.  I'm trying to compile my Solidity code within Truffle to create an ERC-20 token. I have @truffle/hdwallet-provider and @openzeppelin/contracts as my dependencies. Now, I only have two Solidity files, both of which have pragma solidity ^0.6.0;.  I have been uninstalling and reinstalling to different versions and changing the compiler version in truffle-config.js to whichever the error message is telling me to change as well as changing the pragma solidity versions in the two files I have.  I also had to change the individual files in node modules to fit the right version.

Finally, I think the change in the version from ^0.6.2 to ^0.6.0 broke a file called Address.sol in the utility folder of contracts in Node Modules:

    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{ value: amount }(""); // here
        require(success, "Address: unable to send value, recipient may have reverted");
    }

The error message shows:

  ParserError: Expected ';' but got '{'

indicating the point right after call.

First, how do I fix this? And second, is this version incompatibility issue what I should expect every time there's been updates in either Truffle, Solidity, or any of my dependencies?


texts: Is smart escrow with ERC20 tokens fit for below scenario?

texts: I am planning for ICO, which provides services. User need to invest some x amount of money to buy token.After buying token their will be a grace period for 10 days to generate revenue and expect returns on month basis for next 10 years. Which  model of ICO is fit for this ?


texts: Create fastest possible localhost Ethereum test net

texts:
Is there an Ethereum test blockchain (similar to Ganache) which prioritises calculating transactions and creating a local blockchain 'db' as quickly as possible?

Requirements:
 - Calculate transactions (i.e. smart contract logic) as fast as possible (c++ or rust environments for speed maybe?)
 - Write to local db (i.e. create the 'blockchain') quickly;
 - Retain ability to make RPC calls/tx's/queries to this local Ethereum 'blockchain' quickly;
 - Strip away all PoW & difficulty calculations (no consensus mechanisms - the localhost is the only source of truth);
 - Strip away all p2p communication;

^^^ all with the aim of having a super super fast test environment (albeit with some features removed).

Ganache is fairly quick, but has computational overhead to simulate some aspects of a blockchain that I don't need. I want to prioritise getting smart contract calculations completed and added to the db as quickly as possible. E.g. push a transaction to do very computationally heavy smart contract calculations as fast as possible, and then be able to query this 'blockchain' as fast as possible. Nothing more.

Thanks :)


texts: how to export that web3.admin api in external java Script code web3.admin api doesn't work in external JavaScript code

texts:
I'm trying to interact with a private blockchain from JavaScript code. For that I've provided an RPC address to each node and extended multiple apis using -rpcapi. Now if I'm using geth attach http://127.0.0.1:8546 I'm able to use admin apis in new console, but when I use a web3 object with same address, it doesn't recognize admin api.

var Web3 = require('web3');
let express = require('express');
const bodyParser = require('body-parser');

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:8101"));
}

console.log('web3 miner',web3.miner);//here it gives undefined

and the command i used to run private blockchain is

geth --port 30303 --networkid 58343 --datadir ./datadir --rpc --rpcport 8101 --rpcapi "eth,net,web3,personal,miner" console


texts: Can't retrieve Event logs with MetaMask Web3

texts:
I have no problem retrieving events with this code:

contract.MyEvent({}, { fromBlock: 0 }).get((err, data) => console.log(data))

But when I use the exact same code in a browser that is using MetaMask, the callback never runs.

Is MetaMask doing something that stops the event from coming back? I can call functions just fine, but I can't retrieve events.


texts: Is there any solution to have anonymous coinbase transaction in ethereum or other Cryptocurrency? Something like using coinjoin for coinbase transactions or something else.


texts: Can we create multiple private blockchains in a single computer?

texts: I have already created a private blockchain in my system. Now can I create another private blockchain in the same system? I have tried to create one more by changing the chain id in genesis block and network id but still when I open the ethereum wallet I could see the contracts created by me in my first blockchain in black and white. Can anyone tell me why??


texts:
I was trying to compile a .sol file using solcjs --standardjson inputConfig.json command, the compilation had thrown error. But when I try with Solidity compiler, the compilation was success.
Can you please instruct me how to compile with solcjs --standardjson command?
My inputConfig.json content is:
{"language": "Solidity",
"sources":
{
   "testEth.sol":
{
"urls":[
    "E:\Solidity\testEth\testEth\testEth.sol"
     ]
  }
},
"settings":
{
   "optimizer": {
      "enabled": true
},
    "evmVersion": "byzantium",
    "outputSelection": {
     "*": {
       "*": [
           "abi", "evm.bytecode"
          ]
       }
     }
  }
}

Following texts are the error message had thrown:
**fs.js:193
let mode = stats[1];
^
TypeError: Cannot read property '1' of undefined
at isFileType (fs.js:193:19)
at Object.readFileSync (fs.js:380:16)
at Object. (C:\Users\john\AppData\Roaming\npm\node_modules\solc\solcjs:60:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47**


texts: Why higher gpu clock resulted in lower hash rate?

texts:
I have a couple of question, if you'd be so kind to answer:

I've been searching the internet for the relation between GPU core clock & memory clock and the hash rate that it can do. All information saying that higher memory clock means higher rate, but my laptop (MSI with GTX1060) seem to gain higher hash on higher core clock.

My MSI Afterburner is unable to change the "core voltage", "power limit", "temp . limit" (the options is greyed out and unclickable) so the only way I can undervolt GPU (reduce wattage) is with the curve (ctrl+f) but even reach the same clock before GPU undervolt, it result in lower hash, 20% less.


texts: What number of confirmations is considered secure in Ethereum?

texts:
In Bitcoin, 6 confirmations are considered secure (very low probability of transaction/block reversal).

What is the current number in Ethereum?


texts:
I am writing a document about the applicability of multi-agents to solve various business problems and I have seen bitcoin is described as multi-agent: Godsiff, Philip. "Bitcoin: bubble or blockchain." Agent and Multi-Agent Systems: Technologies and Applications. Springer International Publishing, 2015. 191-203. They say

This paper sets out a brief, deliberately non-technical, overview of
 Bitcoin, a new, but becoming more mainstream, crypto currency,
 generated and managed by a distributed multi–agent system.

I want to examine the role of parallelism and scalabity issues. I understand a smart contract is stored as byte code on the blockchain and then distributed to all nodes. When someone runs the smart contract, how does it run? If say 1000 dapps all run that smart contract at the same time, how does that run? Does the blockchain node execute that code 1000 times all in memory? If the number say is 50000 executions at the same time, what happens then? Do they all queue and wait to run?

I would appreciate an overview how the contract runs and if we can apply parallelism to allow scalability to large scale dapps.


texts: Unable to verify deployed contract! Error! Unable to generate Contract ByteCode and ABI

texts:
I already searched and many of the people got this issue, I tried that but unable to fix this issue.
I have deployed a contract and Contract Address is here.
I am getting this error
Error! Unable to generate Contract ByteCode and ABI

Contract Verify Option selected.

Warnings in remix

I would like to ask why this error comes up? Is this due to warnings or due something else? How can I fix it?


texts:
I am the beginner in Ethereum stuff need guidance please help
I am running a private ethereum network and using mist wallet
here is my contract code

pragma solidity ^0.4.0;

contract MyFirstContract {
    uint256 counter =0;

    function increase() public {
        counter++;
    }

    function  decrease() public{
        counter--;
    }

    function getCounter() public constant  returns (uint256) {
        return counter;
    }
}

the counter value was not changing when I press  execute increment or decrement function counter value was not changing after many tries i got these error message
I am getting the error message "Error from sendSignedTransaction: Error: Returned error: replacement transaction underpriced"after some researching I found out this answer
error: replacement transaction underpriced
I have one pending transaction

web3.eth.pendingTransactions();

[{
    blockHash: null,
    blockNumber: null,
    from: "0x4f7f384236f79a5e3322e33cc7bb2ccd5143a87c",
    gas: 188189,
    gasPrice: 18000000000,
    hash: "0x193d30297d98ad9da5958e6295d61bf333050cec901601ccdbf83e9c0b1cb082",
    input: "0x60806040526000805534801561001457600080fd5b5060ea806100236000396000f30060806040526004361060525763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313bdfacd81146057578063d732d95514607b578063e8927fbc14608f575b600080fd5b348015606257600080fd5b50606960a1565b60408051918252519081900360200190f35b348015608657600080fd5b50608d60a7565b005b348015609a57600080fd5b50608d60b3565b60005490565b60008054600019019055565b6000805460010190555600a165627a7a7230582094d5704152e41ee1cb7ab5b820a49845ec5652e2c9c442a8d55da756f6d5cda60029",
    nonce: 10,
    r: "0x34fa67311a0a29d31139a425c2ab120033d4ab34a6d1a860d6c806f95412f7af",
    s: "0x7d831f773e541f73a2371be911ec29b36d803db414ab4712007c4b00d4f10be9",
    to: null,
    transactionIndex: 0,
    v: "0x1b",
    value: 0
}]

so I increased the nounce
        web3.eth.getTransactionCount("0x4f7f384236f79a5e3322e33cc7bb2ccd5143a87c")+1;
    11

after then I again try to exceute the transaction but again getting these messages


texts: What (if anything) in Bitcoin is better than Ether in the application area of a payment system?

texts:
I know of course that there is much more about Ethereum being a smart contract platform. I only refer to the characteristics of a cryptocurrency. If Ether is used for plain payment purposes similar to Bitcoin, it should be faster with no block size limitations. Let alone the speed (8-17s) is much better for payment purposes. I wonder if there is anything that's still better in Bitcoin, besides maybe the market capitalization that gives is robustness as a payment platform.

Why would Bitcoin remain a payment choice in the long run if it can't have the speed of most recent technologies? Is there any technological advantage Bitcoin still holds over Ether?


texts: Solidity function overloading and selectors -- member not unique

texts:
I have the following contract:

pragma solidity ^0.4.17;

contract test{

mapping(bytes4 => bool) internal supportedInterfaces;
uint public a;

function test() public{
          supportedInterfaces[this.transferFrom.selector] = true;
  }

  function supportsInterface(bytes4 interfaceID) external view returns (bool) {
        return supportedInterfaces[interfaceID];
  }

  function transferFrom(address _from, address _to, uint256 _tokenId) public{
     a = 1;
  }

  function transferFrom(address _from, address _to, uint256 _tokenId, bytes data) public{
    a = 2;
  }

}

But I get the error:

  Member 'transferFrom' is not unique after argument dependent lookup.

So how do I refer to the selector (or two different ones) in the test function?

Edit:  https://github.com/ethereum/solidity/issues/1256   --does this issue mean that it's not resolved?


texts: Getting this ---- Error: Stack too deep, try removing local variables

texts:
Hi Ethereum Developer's,

Need your precious time..

I know this question is asked and solutions is given for the same

I have a smart contract---------

pragma solidity ^0.4.18;

contract myContract {

  struct UserInfo {
    uint uId;
    uint producerId;
    uint clientId;
    uint transId;
    uint weight;
    bytes32 addr;
    bytes32 suburb;
    bytes32 city;
    bytes32 country;
    bytes32 postcode;
    bytes32 lat;
    bytes32 lng;
    bytes32 titleType;
    bytes32 status;
    address advAddress;
  }

  //Key-Value Pair between uId and UserInfo
  mapping (uint => UserInfo) userIdInfo;

  //Function to store UserInfo on to the blockchain
  function landregister (uint uId, uint producerId, uint clientId, uint transId, uint weight, bytes32 addr, bytes32 suburb, bytes32 city, bytes32 country, bytes32 postcode, bytes32 lat, bytes32 lng, bytes32 titleType, bytes32 status) public returns(bool)
  {
    var userinfo = userIdInfo[uId];

    userinfo.landId         = landId;
    userinfo.producerId     = producerId;
    userinfo.clientId       = clientId;
    userinfo.titleType      = titleType;
    userinfo.landSize       = landSize;
    userinfo.addr           = addr;
    userinfo.suburb         = suburb;
    userinfo.city           = city;
    userinfo.country        = country;
    userinfo.postcode       = postcode;
    userinfo.lat            = lat;
    userinfo.lng            = lng;
    userinfo.transId        = transId;
    userinfo.status         = status;
    userinfo.advAddress     = msg.sender;
    return true;
  }

  //Function to retrieve UserInfo from the blockchain
  function getUserById(uint index) public constant returns(uint, uint)
  {
    return (userIdInfo[index].uId, userIdInfo[index].producerId);
  }
}

When i am trying to deploy it, it give me Error: Stack too deep, try removing local variables.

I have read many articles but not able to find solution ....

Please if anyone can help me with example for the same

Thanks in Advanced ......


texts: How to check if an address is an active contract in Vyper?

texts:
Often for security reasons I want to limit certain address parameters to non-contract addresses for certain functions in my contracts, ie. there are no code stored on the addresses passed in as function parameters or as msg.sender, so to make sure the addresses are not some attack contracts that may try to exploit some re-entrancy vulnerabilities or conditionally congest the Ethereum network, etc. etc.

With solidity it seems the current de-facto standard way is to use inline assembly that checks if there are code stored on the address. Since Vyper has no inline assembly, is it possible for a Vyper contract to check if certain address parameters and/or the transaction sender are contracts or not?


texts: Get error when I want to withdraw ethers from my contract

texts:
I have a contract in which, I want to withdraw my ethers using a function.
It works fine in remix, but in web3 It does not work and throws VM Exception while processing transaction: invalid opcode","code":-32000
note that, I have enough ether in my contract
my contract(sol v.8) code is :
pragma solidity ^0.8.0;

contract TestEther {

address payable wallet;

fallback() external {}

constructor(address _wallet) {

  wallet = payable(_wallet);
}

function sendEther() public payable {

}

function withdraw(uint _amount) public {

    require(_amount <= address(this).balance, "not enough");
    payable(wallet).transfer(_amount);
 }
}

web 3 code using react (removed the extra codes here):
sendEther = (amount) => {
this.state.ether.methods.sendEther().send({ from: accounts[0], value:
amount }).on('transactionHash', (hash) => {
 })
}

withdraw = (amount) => {
this.state.ether.methods.withdraw(amount).send({from:
accounts[0]}).on('transactionHash', (hash) => {
 })
}

The Send ether method works fine, but the withdraw doesn't work with Web3 (works fine in Remix)
I use the same way in web3 to withdraw erc20 tokens like this, and it works fine. But it cant withdraw ether.


texts: Browser will not connect to running Geth: NS_ERROR_UNKNOWN_PROTOCOL

texts:
My Geth tutorial Greeter contract runs fine from the command line. I tried to make a front end that just outputs the string from Greeter, but the browser console returns the error, 'NS_ERROR_UNKNOWN_PROTOCOL.'

I tried the suggestions from here:

How to connect a web site to a geth node?

using --rpccorsdomain and --rpcaddr flags referencing localhost and port 8080 which my bootstrap frontend references, but same error.

Other ideas? Any working examples of backend blockchain contracts to front end UI's?

Thanks.

UPDATE to clarify, here are my configuration/execution steps:

Installed web3.js into project using Bower. Verified it is referenced in project index.html.
Ran CLI GETH Client with:
geth –rpc –rpcaddr localhost --rpcport 8545 --rpccorsdomain “http://127.0.0.1:8080”
observed it is syncing properly - running “net” in attached console shows 11 peers.
Run an http-server from project folder:
http-server –p 8080
My project’s app.js file sets up HttpProvider following docs guidance:

// Dependencies
var Web3 = require('web3');
// Initialize connection
var web3 = new 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://127.0.0.1:8545'));
}

HTML page function call includes:
console.log("HttpProvider: " + web3.currentProvider)

The app.js function log output:   “HttpProvider:  undefined”

Clearly, I’m misconfigured, but how?


texts: Is it possible to have multiple coin types in one contract?

texts:
I'm still pretty new to ethereum but I have a decent understanding of how it works and I've written a couple different contracts.

What I am trying to figure out is if it is possible to have n different coin types in a single contract.

So for example if I took the example coin code from the go-ethereum github

contract token {
    mapping (address => uint) public coinBalanceOf;
    event CoinTransfer(address sender, address receiver, uint amount);

    /* Initializes contract with initial supply tokens to the creator of the contract */
   function token(uint supply) {
     coinBalanceOf[msg.sender] = supply;
   }

   /* Very simple trade function */
   function sendCoin(address receiver, uint amount) returns(bool sufficient) {
     if (coinBalanceOf[msg.sender] < amount) return false;
     coinBalanceOf[msg.sender] -= amount;
     coinBalanceOf[receiver] += amount;
     CoinTransfer(msg.sender, receiver, amount);
     return true;
   }
}

and instead of just having the one coin type I wanted to have three different coin types, coin1, coin2, and coin3, what would be the best way to implement this in my contract?

My initial thought was to have an array of all of the different coin types and then each element in the array would contain another array that contains the address and balance information but I'm not exactly sure how I would write that.


texts:
When launching Parity UI with --unlock and --password

I get this error

No valid password to unlock account 0x00e4ΓÇªfb21. Make sure valid password is present in files passed using --password or in the configuration file.

Ive created the password file with one line and password only.  I've also tried creating a config file and placing it in the correct directory.  I'm using parity version 2.1.3-20181015 on windows 10.


texts:
When I look at some Dapps on github there are many separate contracts that interact with each other (eg, Augur). Thus, though each contract is simple, they refer to so many others that it is quite complicated.

Is there a link to an examination of this? That is, highlighting a good Dapp with minimal or efficient use of multiple contracts, and comparing it to one that is an abomination of complexity?


texts:
I test some function as follows,,,

function fooMain() public pure returns(uint8) {
    uint8 tempData;
    uint8 i;
    for(i=0 ; i<10 ; i++){
        tempData = subFooMain(tempData);
    }

    return tempData;

}

function subFooMain(uint8 _in) public pure returns(uint8){
    uint8 i;
    uint8 result;
    result = 0;
    for(i=0 ; i<200 ; i++){
        result = result + _in;
    }
    return result;
}

And my test code(truffle) is like this

gasEstimated = await instant.fooMain.estimateGas();
console.log("estimated gas(fooMain) : " + gasEstimated);
let inData = 1;
gasEstimated = await instant.subFooMain.estimateGas(inData);
console.log("estimated gas(subFooMain) : " + gasEstimated);

And this is the result

My question is the estimated gas to run fooMain is smaller than I expected? Because the subFooMain consume 37114 gas, and it runs 10 times in fooMain, so I think it should be much more than 175345.


texts: How to optimally use map of maps in solidity?

texts:
I have the code:
struct A {
        mapping(uint256 => uint256) b;
}
mapping(uint256 => A) public a;

and I want to have the following code as gas efficient as possible:
a[key_a].b[key_b] = a[key_a].b[key_b] | mask;

is it the most optimize way or there are might be some gas optimizations?
as I understood, solidity would take an address of the map a, calc the address of mapping by index key_a, take field b, calc the address of mapping item by key b - which costs more than just simple access the uint256 variable storage, am I right?
Does it do twice (before and after =) or cache it somehow for optimization?
Maybe something like that:
A storage a_key_a = a[key_a];
a_key_a.b[key_b] = a_key_a.b[key_b] | mask

or any approaches would make it cheaper?


texts: web3 - Uncaught TypeError: Cannot read property 'methods' of undefined

texts:
I am made a coin flip dapp and am using ganache to deploy it. A player has to selects a number between 0 and 1. I read this error means "the contract is undefined" but I do not know how to solve this error. My github repo
My main.js code is
var web3 = new Web3(Web3.givenProvider);
var contractInstance;
var contractAddress = "0x2Ae24960e9f6331e68Ef6c19b7FA15094adFdA98";
var number;
var guess;

$(document).ready(function() {
    window.ethereum.enable().then(function(accounts) {
      contractInstance = new web3.eth.Contract(abi, contractAddress, {from: accounts[0]});
      console.log(contractInstance);
    });
    $("#bet_0").click(bet(0));
    $("#bet_1").click(bet(1));
});

function bet(number) {
  contractInstance.methods.flipCoin(number).send({value: web3.utils.toWei("1", "ether")})
  .on("transactionHash", function(hash) {
    console.log(hash);
  })
  .on("confirmation", function(confirmationNr) {
    console.log(confirmationNr);
  })
  .on("receipt", function(receipt) {
    console.log(receipt);
  })
  .then(function() {
    fetchAndDisplay(guess);
  })
  .catch(function(error) {
    console.log(error);

  })

}

async function fetchAndDisplay(guess) {
  await contractInstance.methods.outcome.call().call().then(function(res) {
    if(guess=res){
      console.log("Result is " + res + " you won!");
      $("#outcome_display").text("You Won!");
    }
    else {
      console.log("Result is " + res + " you lost!");
      $("#outcome_display").text("You Lost!");
    }

  })

}


texts: How to ensure the Mist GUI client is running on the new, hard-forked blockchain?

texts: I installed a while ago geth 1.4.17 from the git repo (together with cpp-ethereum, the genoil CUDA miner, and the Mist GUI wallet). However, now I can't figure for the life of me how to upgrade geth to 1.5.x (in preparation for the impending hard-fork), so I just downloaded the latest version of Mist (0.8.7), and it's syncing to the blockchain just fine. How can I ensure that it will be running on the new, hard-forked chain, though?


texts: allowance - why not directly transfering?

texts:
I have a couple of questions relating ERC20...

why is allowance needed ? It would be the same as if instead of approving my 10 tokens to some address to spend, I could directly transfer 10 tokens to that same address. Hence, no allowance necessary and the same result.

I am looking at the following contract... https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol .  I don't seem to figure out why transferFrom is written like this. That way, anyone can call the function and pass other 2 addresses, which means that If I call it, I can make a transfer from userA's to userB, even though I am userC and I shouldn't have the permission to do so.

Where can I find the actual ERC20 compliant contract with all the functions(including mint) and with the correct implementation and not the one i linked above ?


texts: Block explorer running on private network

texts: Is there any application out there that allows me to explore the Ethereum blockchain in a private network? (something similar to what blockchain.info does to bitcoin or etherchain does to ethereum public network)


texts: Store a mapping of addresses linked to arrays of structs

texts:
How would I have the following data structure be saved in an Ethereum contract using solidity?

{
  address1 => [struct1, struct2, struct3, struct4, struct5],
  address2 => [struct1, struct2, struct3, struct4, struct5],
  address3 => [struct1, struct2, struct3, struct4, struct5],
  ...
}

The goal is for me to be able to easily access the array of structs associated to each user/address.


texts:
This question is regarding the bytecode-optimizer of the solidity-compiler, not the yul-optimizer:

Is there any way to separately optimize bytecode?
Normally the solidity-compiler optimizes the deployment-bytecode while compiling solidity-code as one of the last steps.

When I have unoptimized (deployment-)bytecode, how would you optimize the existing bytecode? Re-compiling the solidity-code is unfortunately not an option.

Is there another solution apart from rewriting the compiler?

I would be really happy for any hint :)


texts: why would I need to use `memory` in front-of parameter?

texts:
Let's say I have the following contract.
contract D {

    function again(uint256[] memory bla) public returns(uint) {
        return bla[0];
    }
}
contract A {

    function test(D f, uint256[] memory haha) public returns(uint) {

        return f.again(haha);

    }

}

So, we deploy D, then Deploy A ,and call contract D , from contract A via test function.
The code seems to be working the same if in the again function, we change it from memory to calldata.
I have seen some places that some still put memory.  It seems to me that using memory causes more gas due to copy operations. Any idea why I wouldn't use calldata and use memory ?


texts: Balance returns zero but shows ether with web3.eth.getBalance on testrpc

texts:
Issue:
Using an account on testrpc I get 0 as my balance from within a program but I get the correct amount when I query balance at web3 command prompt:

//here I'm calling a function (shown below) from command line

  contractInstance.queryBalance("0xf24qf4b3ae667a23f296f48eb92fa619310c95fd")
  { [String: '0'] s: 1, e: 0, c: [ 0 ] }

  //here's I'm listing my accounts, just showing the first one to save space

  web3.eth.accounts
  [ '0xf24qf4b3ae667a23f296f48eb92fa619310c95fd',
   ...

//here I am querying the balance directly at the command prompt

  web3.eth.getBalance('0xf24qf4b3ae667a23f296f48eb92fa619310c95fd')
  { [String: '99999999999984495002'] s: 1, e: 19, c: [ 999999, 99999984495002 ] }

Here is the function call I'm making in my program:

function queryBalance(address addr) public constant returns (uint balance) {
    return balances[addr];
    }

What else I've tried
contractInstance.queryBalance("0xf24qf4b3ae667a23f296f48eb92fa619310c95fd", {from: web3.eth.accounts[0], gas: 4500000})
{ [String: '0'] s: 1, e: 0, c: [ 0 ] }
and

Environment:
web3.js environment on Mac with testrpc running

Thanks


texts: How does MetaMask's TRANSACTION DATA work? How to interact with smart contracts by only using MetaMask?

texts:
I have this source code

pragma solidity ^0.4.21;

// Relevant part of the CaptureTheEther contract.
contract CaptureTheEther {
    mapping (address => bytes32) public nicknameOf;

    function setNickname(bytes32 nickname) public {
        nicknameOf[msg.sender] = nickname;
    }
}

// Challenge contract. You don't need to do anything with this; it just verifies
// that you set a nickname for yourself.
contract NicknameChallenge {
    CaptureTheEther cte = CaptureTheEther(msg.sender);
    address player;

    // Your address gets passed in as a constructor parameter.
    function NicknameChallenge(address _player) public {
        player = _player;
    }

    // Check that the first character is not null.
    function isComplete() public view returns (bool) {
        return cte.nicknameOf(player)[0] != 0;
    }
}

So is it possible to call setNickname(bytes32 nickname) with MetaMask using the Transaction Data field?

Further, if I have set the nickname - how can I call receive my nickname from mapping (address => bytes32) public nicknameOf; with MetaMask using the Transaction Data field?


texts: What is the syntax for having both 'is' and 'using' in a contract declaration?

texts:
I have a contract which inherits from some other contract and uses some library.

I tried the following ways for declaring it, none of which works:

contract B is A  using Lib
contract B is A, using Lib
contract B is A; using Lib
contract B using Lib  is A
contract B using Lib, is A
contract B using Lib; is A

UPDATE:

I found this answer here:

contract B is A {
    using Lib for *;
    ...
}

But it doesn't quite achieve what I was hoping to, since I still need to prepend Lib. on every call to a function of Lib.

Thank you!


texts:
Working with a simple contract to get the hang of this. I can't seem to get the correct value back from my contract function. It always outputs 0.

Truffle version: 4.1.15

Contract:

pragma solidity 0.4.24;

contract HelloWorld {
    uint public balance;

    constructor() public {
        balance = 1000;
    }

    function deposit(uint _value) constant public returns (uint _newValue) {
        balance += _value;
        return balance;
    }

    function get() constant public returns (uint) {
        return balance;
    }
}

Truffle commands:

const hw = HelloWorld.at("0x90BB90BA04612eb9B30A2640BC7516168A684cE7");
undefined
hw.deposit(500).then(function(balance){n = balance.toNumber(10); console.log(n);})
0
undefined
hw.get().then(function(balance){n = balance.toNumber(10); console.log(n);})
0
undefined

Both deposit() and get() seem to return 0 no matter what. This should at least return the initial value of balance (1000), right?


texts: Using web3.py to send a 0 price gas erc20 transaction

texts:
Sorry about the formatting, I’m on mobile

I'm trying to push an ERC20 Token transaction with 0 gas price using web3.py. Although when I set the gas price to 0, I receive the following error:

{'code': -32000, 'message': 'transaction underpriced'}

I know 0 gas price transactions are possible because I’ve seen plenty of them.

Code:

nonce = web3.eth.getTransactionCount(account)

txn = contract.functions.transfer(to_address, amount).buildTransaction(
  {
    'chainId': 1,
    'gas': 1000000,
    'gasPrice': web3.toWei("0", "gwei"),
    'nonce': nonce,
  }
)
signed_txn = web3.eth.account.signTransaction(txn, private_key=account_priv_key)

tx_hash = web3.eth.sendRawTransaction(signed_txn.rawTransaction)

And I need the transaction to be a 0 gas price.
Any help would be great thanks.


texts: Truffle doesn't see the smart contract deployed on ganache

texts:
etherjs (5.0) is used to deployed a smart contract Hello.sol. Here is the js code (truffle 5.1.52/ganache CLI 6.12.1):
  import { ContractFactory, ethers } from "ethers";

  let privateKey = "0xf43608a210da70d40115ad23526e50f2a502c018aeffd56477fcbe44119b53cc"; //<<==private key from ganache-cli
  let wallet = new ethers.Wallet(privateKey);  //address of the wallet
  console.log("wallet : ", wallet);
  //deploy
  const factory = new ContractFactory(abi, bytecode, signer); //<<==abi, bytecode, signer defined before
  const contract = await factory.deploy(wallet.address);
  console.log("contract deployed : ", contract);
  console.log("contract address : ", contract.address);
  // The transaction that the signer sent to deploy
  contract.deployTransaction;
  // Wait until the transaction is mined
  contract.deployTransaction.wait();

The execution of code above generates the output on ganache-cli -b 3:
  Transaction: 0xbbd7dfd7272cee291a2d1e62ac51e32dd99c98dacb44d04f1ae4bd50487f35b7
  Contract created: 0x03734542501c30e1ea22d6ddcb876e84eaa99381
  Gas usage: 92522
  Block Number: 2594
  Block Time: Thu Nov 12 2020 14:37:36 GMT-0800 (Pacific Standard Time)

The contract is deployed at the address of 0x03734542501c30e1ea22d6ddcb876e84eaa99381.
truffle is started with truffle development. command networks generates the following output:
truffle(development)> networks

Network: develop (id: 5777)
  No contracts deployed.

Why truffle doesn't find the contract deployed above?


texts: Why am I getting a Parse Error in my smart contract after the constructor?

texts:
I'm writing a token sale smart contract & my original error was my function had the same name as the contract and I changed it to a constructor because the contract cant have the same name as the function. I know get this error

browser/ballot_test.sol:11:17: ParserError: Expected '(' but got identifier
constructor ChampToken(ChampTokenSale _tokenContract, uint256 _tokenPrice) public {
^--------^

Here is my code -

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


texts: How do you generate an address identicon using javascript?

texts: Given an address, how do you generate its identicon using javascript?


texts: Strange error when trying to npm start react file

texts:
I get that error while npm start

PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader> npm start

> react-box@0.1.0 start C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader
> node scripts/start.js

internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module 'dotenv'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader\scripts\
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-box@0.1.0 start: `node scripts/start.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-box@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output ab
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Concierge\AppData\Roaming\npm-cache\_logs\2018-11-17T04_27_59_461Z-debug
PS C:\Users\Concierge\downloads\prod\pdf2\ipfs_image_uploader>

and when i run command npm install: I get that error:`> scrypt@6.0.3 preinstall /Users/user/Documents/pdfuploader/node_modules/scrypt

  node node-scrypt-preinstall.js

  scrypt@6.0.3 install /Users/user/Documents/pdfuploader/node_modules/scrypt
  node-gyp rebuild

gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder. (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/user/Documents/pdfuploader/node_modules/scrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2018-11-18T05_45_00_864Z-debug.log`


texts: Inability to verify contract with ABIEncoderV2 on Etherscan

texts:
Yesterday I deployed a contract to Ropsten (https://ropsten.etherscan.io/address/0x1fe59c223fa4e9781237f0f49a15ca598069cc30) that relies on V2 of the ABI encoder. Thus it includes statement

pragma experimental ABIEncoderV2;

I tried to run Etherscan's code verification (https://ropsten.etherscan.io/verifyContract2) with a flattened version of my Solidity code, matching compiler version, optimization flag, optimizer runs etc. The code verification result, however, is negative.

Back in June when I also deployed contracts with the same pragma I got message from Etherscan helpdesk that they don't support ABIEncoderV2. This despite the fact that compilation at Remix only issues a warning and Etherscan claims to support contracts that compile at Remix.

So I am looking for alternatives. Can anyone lend support to the hypothesis that it is lack of support for ABIEncoderV2 that is still causing code verification problems? Also are there other alternatives for public code verification of smart contracts?

Cheers,

Jens Ivar


texts: UPDATE: (I need to run testrpc before running the code) Problem with signing a message with "web3.eth.personal.sign" or "web3.eth.sign"

texts:
I use exactly the example of web3js (here) to sign a text.

So, I generated a .js file asfollows :

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

web3.eth.personal.sign("Hello world", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!")
.then(console.log);

However, I receive the following error message, when I run this file with Terminal (Ubuntu) as follows : node filename.js

Error message: https://ibb.co/j6HEUy

Even when I use web3.eth.sign instead of web3.eth.personal.sign, I receive the same error message :

  Error: Invalid JSON RPC response: ""

UPDATE: I need to run testrpc before running the code. However, now I receive another error message as follows:

  Error: Returned error: Error: cannot sign data; no private key


texts: Does Go Ethereum have User service hooks like Pyethapp?

texts: Pyethapp provides a simple hook to allow developers to plug-in user services that can intercept blocks and even create mini oracles in Python.  Does Go Ethereum have something similar?


texts:
I am working Remix Browser for the following simple Contract.   I had a couple of questions.  I could not find the right answers.

During Contract Creation:   It gives the following error.  What is this error.  How can I get rid of it?

  undefined errored:  cannot read property 'op' of undefined

I have an event defined.  Where can I see the output of the event on Remix browser?

    pragma solidity ^0.4.15;
    contract MyContract {

        bytes32  public custName;
        bytes32  public custLoc;
        address public docAddress = this;

        function MyContract () {

            custName = "0xDEFAULT";
            custLoc  = "0xDEFAULT";

        }

        event LogNewCust (address _address, bytes32 _custName, bytes32 _custLoc);

        function AssignAttributes (bytes32 _custName, bytes32 _custLoc)
            returns (bool isSuccess) {

            custName    = _custName;
            custLoc     = _custLoc;

            LogNewCust(docAddress,custName,custLoc);

            return true;

        }

    }


texts: strange revert on proxy pattern delegate call

texts:
I've worked with upgradeable contracts before using zeppelin's upgradeable contract pattern.
However, I found out that if I try to fetch the implementation contract address through a contract call, I get an unexpected revert.
pragma solidity >=0.6.0;

contract Proxy {
    address registry = 0xc5c97AAd92a962396229cbC8392e62585B04DfB3; // assume this is registry address

    function implementation() public view returns(address) {
        return Registry(registry).getImplementationAddress();
    }

    fallback() external payable {
        address implementationAddress = implementation();
        assembly {
            let ptr := mload(0x40)
            calldatacopy(ptr, returndatasize(), calldatasize())
            let result := delegatecall(gas(), implementationAddress, ptr, calldatasize(), returndatasize(), returndatasize())
            returndatacopy(ptr, 0, returndatasize())

            switch result
            case 0 {revert(ptr, returndatasize())}
            default {return(ptr, returndatasize())}
        }
    }
}

contract Registry {
    address public implementationAddress = 0x8750c1719E32294260e596c80a04818533e2C643; // assume this is impl address

    function getImplementationAddress() public view returns(address) {
        return implementationAddress;
    }
}

contract Foo { // assume this is implementation contract
    uint256 public a;
    uint256 public b;
    function setA(uint256 val) external {
        a = val;
    }
    function setB(uint256 val) external {
        b = val;
    }
    function getA() external view returns(uint256) {
        return a;
    }
    function getB() external view returns(uint256) {
       return b;
    }
}

all transactions would revert on any call to the proxy in the context of Foo. However if I make the line address registry = 0xc5c97AAd92a962396229cbC8392e62585B04DfB3  constant, it would no longer revert. Does anyone have any insight into what's causing the revert?
reproduced on Solc version 0.6.13, 0.7.4.


texts: Set minimum purchase condition ideas needed :)

texts:
I am quite the beginner and trying to get my head around things using Remix practice building contracts.

I want to set a minimum total purchase required(amount Tokens)
I am using
 " https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/crowdsale/Crowdsale.sol"
as my starting point.

now i want to require set minimum to get a bonus like

// from BokkyPooBah MyToken example:

if (now <= BonusAdded) {
            tokens = msg.value * 4500;
        } else {
            tokens = msg.value * 3000;
        }

Appreciate any advice


texts: Contract not properly deployed with Remix

texts:
Can someone help me deploy a token contract with Remix?
I try to deploy this contract using remix and this is the result.
The contract deployed does not appear to be my token contract.
How can I deploy my token contract with Remix?


texts: Calling contract method results in metamask error using ganache

texts:
I have a simple Vue form, that calls a method in an Ethereum contract.
If I don't provide a callback to my method, Metamask complains:

  Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_sendTransaction without a callback parameter.

So I added this. (even though I already have a callback in my sendTransaction)

Then I get the error:

  Uncaught TypeError: Cannot read property 'sendTransaction' of undefined

In my console.log I can clearly see the method on dash.crowdsaleContractInstance, and the sendTransaction property as well.

I'm using Ganache CLI v6.7.0 (ganache-core: 2.8.0)
and metamask web3 api version: 0.20.7

Im calling my method on the instance of the contract not the contract object

I tried this as well as found in the documentation:
myContract.methods.myMethod(123).send...
but the methods property is not available, so I guess I'm on another version of web3?

I've done a fair share of web3 smart contract programming by now, but I still find it very hard to debug, to be honest. Anybody who can help to find what is going wrong here?

dash is an object where I instantiate a lot of async functionality

Thanks.

vmBuyform = new Vue({
el: '#buyForm',
data: {
  to: dash.crowdsaleaddress,
  from: accounts[0],
  amount: 0.25
},
methods: {
  buy: function (event) {

    var sender = this.from;
    var receiver = this.to;
    var amountVal = this.amount;

    var amount = web3.toWei(amountVal, 'ether');
    console.log(dash.crowdsaleContractInstance);
    console.log(abis.crowdsaleContractInstance);
    console.log('Version: ', web3.version);

    // does not work with metamask enabled, works without metamask
    dash.crowdsaleContractInstance.depositFunds({from:sender, to:receiver, value: amount, gas: 2000000},
      function(error, result){}).sendTransaction({from:sender, to:receiver, value: amount, gas: 2000000},function(error, result){

      if(!error){
          console.log(result);

      }
      else{
          console.error(error);
      }

    });
  }
}
})


texts: UnimplementedFeatureError: Variable inaccessible, too deep inside stack (17)

texts:
I'm getting this error, with no indication of which line of code or variable is responsible. I know it goes away when I comment out

pragma experimental ABIEncoderV2;

…but I need ABIEncoderV2 as I have functions that return structs. The title above is the entire error message. Does anyone have any idea how I might go about looking for the variable responsible?


texts: Is there a way to know the REAL msg.sender?

texts: I want to know the real msg.sender of the transaction. Which this means is, if I use truffle console I can change the msg.sender by using {from: another address}. So let's say my address is A, and another user's address is B. And B created an sale auction for he's item1. But by using truffle console, I can cancel this auction by, cancelAuction(item1_id, {from: B}) despite the REAL msg.sender is me(the address A). How can I check the real msg.sender(A) from the function's require()?


texts: What exactly happened with the parity bug in Nov-2017 to lose $300+ M?

texts:
From my understanding, all I know is that ether got locked up in parity and there's no way to get it out. I'm not familar with parity, as I just use myetherwallet to store ether.

Isn't parity just a node software like bitcoin core? Or is it a wallet?
If its a smart contract that lives in the blockchain, isn't it immutable where it cannot be deleted?
How did this bug get overlooked during a code audit? Assuming it was a simple bug that a newbie coder found and screwed up.
What are some solutions to resolve this similar problem down the line?


texts:
I am trying to install Ganache GUI on my ubuntu 18.04. I downloaded the Ganache-2.0.1.AppImage from the site. On the site it says that the package installs automatically when double clicked. But it is giving error of not finding any application to open the file.

I have installed the Ganache cli by this command
"npm install -g ganache-cli"

Is it not possible to install the GUI for Ganache on linux? If yes please tell me how?


texts: Where are my ethers: Etherli wallet withdrawal by using Parity

texts:
Last week I tried to withdraw 2.09 ethers from my Etherli wallet to my poloniex account (1). As set out in other questions Etherli suggested performing this transaction (2) however no balance (0.00) was transferred at all. Three days later I tried to execute the same transaction again (3).

As nothing happened I imported my Etherli wallet into Parity where I actually saw a "pending transaction". Parity (v.1.6.8, windows) gave me the option to sign (in tab "signer") this transaction by another account (created in Parity by myself). After signing it (4), it asked me another two times to do the same (5,6). As inexperienced as I am I signed the other two as well after which the pending transaction were gone.

However, as my ethers have gone they never arrived where they had to. At etherscan.io I can trace all the (internal?) transactions however I don't know where my ethers have been (or have they been lost?) and (in case they have not been lost) what to do to get them at the right place.

Below are the Txhash's of the 6 transaction moments as described above. Can someone help me out:

1) What went wrong (what to do differently next time);
2) Where are the 2.09 ethers?
3) Is there something I can do to get my ethers at the right place?

0xe7e94a6416ed2889e0990e6a653453c21d7737d02da9f49a8328adb3499eeb30
0x4d09ee7c9234c3096e2c2412b48f0893765d95611c4b067fbfcae3d967307895
0x1f905fc37646551c15b3469faa9d225785f55c5daf89f30b266c96fe268a3fdc
0x0932c23c9729314c3f6b5acea5b4a32f9d6cad7c1c27380daca638b753978758
0x6043fb80ce94bd106617b6804ce4c64a872b4a7b083fcd7ff16488748f8c6104
0x139a875fbc5f9be98c08c8b379d1f23b154c83233fc6149127b03c48560f59d1

Many thanks.

Patrick


texts: Does my wallet software need to be running to get Ether payments?

texts:
I was wondering what happens if someone made a payment to me whilst my wallet software (for example Mist) was not running on my computer?

Will the payment be lost or will it show once I start the software?


texts: Ethereum's version of -walletnotify to monitor a bunch of addresses?

texts:
I'm trying to build an ethereum explorer and want to be able to monitor a bunch of addresses. I was thinking of just having a script on a 5 minute cron to check for any activity on these addresses.

But I realized that Bitcoin had a -walletnotify flag that lets the wallet software run a script you declare in the config file whenever it detects activity in one of the addresses.

Is there a -walletnotify equivalent flag in ethereum?


texts:
I am trying to test an enum value from a test. This is simplified version of the contract:

pragma solidity >=0.5.0 <0.7.0;

contract Foo {

  enum State {
    StateA,
    StateB
  }

  State internal state;

  function getState()
    public view
    returns (State)
  {
    return state;
  }
}

Now running the test just like this:

contract("Foo", async accounts => {
  it("requires a project to create", async () => {
    let instance = await Foo.new()
    console.log(await instance.getState())
  })
})

I am getting output like this

BN { negative: 0, words: [ 1, <1 empty item> ], length: 1, red: null }

I've read that enums are still not supported from the ABI but shouldn't this then just return the index? What is BN? negative? red?


texts: Sent ETC from Jaxx to Coinbase ETH wallet accidently

texts:
I accidently sent ETC to an ETH wallet.
Sent ETH from Jaxx to a Coinbase ETH wallet.
ETC not appearing now on coinbase because I sent it to an ETH address.

Please can you help me with this?

I am willing to reward you for your efforts

Narendra


texts: How can a dapp user verify that the data being rendered on a page originates from a contract call?

texts:
@Eth here references how "...a dapp can effectively have two back-ends..."

In other words how can a user trust they are receiving trustless data?


texts: What happened in the Ropsten hardfork from Byzantium to Constantinople?

texts:
What were the consensus issues during the Constantinople hardfork in the Ropsten testnet?

One noted consensus issue is:

  geth and parity have been in noticeable disagreement regarding block
  4230605. The discrepancy is gas-used in this transaction - parity charged 791587, geth charged 1078987.

Why did they disagree? Were there other consensus issues?


texts: Web3 and MetaMask, receiving event from blockchain

texts:
Hey guys I'm terribly stuck with getting events to frontend. I'm using MetaMask. what am I missing?

Solidity event:

event enrolled(address payoutAddress, address sender, uint dateOfTransaction);

And Web3:

MyContract = web3.eth.contract(abi);
    myContractInstance = MyContract.at(contractAddress);
    var depositEventAll = myContractInstance.enrolled({dateOfTransaction: userAddr}, {fromBlock: 4400000, toBlock: 'latest'});
    depositEventAll.watch(function (err, result) {
        if (err) {
            console.log(err);
            return;
        }
        console.log(result);
    });

Thanks!


texts: Can a contract read the address of past miners?

texts: I am trying (in solidity) to write a contract that needs some statistics on the past few miners. E.g., who mined the last 100 blocks. I know that for the current block I get the address as explained here. I can also get the last 256 blockhashes, but is it at all possible to get the address of the miners of the last blocks?


texts: Add new sealers in aura network without hard-fork?

texts:
I've set up a private PoA (aura) network using parity-deploy and was wondering how it's possible to add/remove authorised nodes without doing a hard-fork of the network.

I've heard about people storing them in a smart contract, however I have not found any documentation on how to do this. Any pointer in the right direction would be greatly appreciated!

Thanks!


texts: How to choose contract address and wallet address

texts:
When you start an ICO, to receive a fund from people for your ICO, how do you choose the contract address and your wallet address to receive ETH collected for your ICO?
Thank you.
And excuse me for my bad English, i speak French, and i translate with Google


texts: What do last few opcodes of a smart contract do?

texts:
I built a sample smart contract, then I looked at the opcodes, and always found similar opcodes at the end - for all samples I tried - like below.

a1  log1
65 62 7a 7a 72 30 58  push6 627a7a723058
20  sha3
8b  dup12

Nowhere in the contract refers (JUMP) to these instructions, so I am wondering why they are here, and what they do.

Any ideas? Thanks

Update: below is the source code of my sample.

pragma solidity ^0.4.23;

contract sample {
    uint public a = 2;

    function exp(uint256 input) public {
        a = a ** input;
    }
}


texts: Can't invoke SC function: Error: gas required exceeds allowance or always failing transaction

texts:
I've deployed my smart contract to Rinkeby test net.
The "addProject" function works fine.

But when I try the "addProjectFile" function I got error.

  "Error: gas required exceeds allowance or always failing transaction"

The code:

pragma solidity ^0.4.18;

contract MyProjectManger {
  address public owner;
  mapping (uint => MyProject) public myProjects;

  uint projectIndex;
  mapping (uint => uint) public projectFileIndexes;

  struct File {
    string url;
    string fileHash;
  }

  struct MyProject {
    bytes32 id;
    string name;
    mapping (uint => File) projectFiles;
  }

  function MyProjectManger() public {
    owner = msg.sender;
  }

  modifier onlyOwner {
    require(msg.sender == owner);
    _;
  }

  function addProject(bytes32 id, string name) public onlyOwner returns(uint projectId) {
    projectId = projectIndex;
    myProjects[projectIndex] = MyProject(id, name);
    projectIndex++;
  }

  function addProjectFile(string url, string fileHash, uint projectKey) public onlyOwner returns(uint fileId) {
    uint projectFileIndex = projectFileIndexes[projectKey];
    MyProject storage project = myProjects[projectIndex];
    require(project.id[0] != 0);

    fileId = projectFileIndex;
    project.projectFiles[projectFileIndex] = File(url, fileHash);
    projectFileIndex++;
  }

  function remove() onlyOwner public {
      selfdestruct(msg.sender);
  }

  // to receive ether
  function() payable public { }

}

I did get "Gas requirement of functions" warnings for those two addXXX functions. But I don't understand, I don't have loops in those two functions, why gas requirement should be an issue?


texts: Remix: Trouble naming a function parameter?

texts:
pragma solidity ^0.4.0;
contract SignatureStatus
{
    string documentIDhash;
    struct Signature {
        string documentID; //ID of the document
        string studyID; // ID of the study the document is associated with
        string timeStamp; // Timestamp of the signature
        bool consented; //  boolean of the consent status
    }

//sets the consent status of the contract
function consentBuild(documentIDhash,studyIDhash,timeStamphash,consentedhash) public returns (Signature)
{
string documentID = documentIDhash;
string studyID = studyIDhash;
string timeStamp = timeStamphash;
bool consented = consentedhash;

 }
    //checks the status of the contract
    function Status() returns (bool status)
    {
    //bool consented = true;
    if (consented == true) {status = true;} else {status = false;}
    }

This is my current contract, I'm trying to create a public function that receives a tx call from web3 js and stores the parameters in a struc. I'm getting this error however whenever I try to name my parameters in the function. I've tried defining the parameters beforehand and that isn't working either. What exactly am I not seeing/missing to simply set my function parameter names?

browser/Untitled.sol:15:27: TypeError: Name has to refer to a struct, enum or contract.
function consentBuild(documentIDhash,studyIDhash,timeStamphash,consentedhash) public returns (Signature)
                      ^------------^


texts: Can a payment be made automatically from a smart contract?

texts:
If I have two people who want to make a payment at a certain time, eg 1pm tomorrow for 1 ETH, can a smart contract perform that task without the payer stating their private key at the time of the transaction? This is akin to a direct debit on a bank account.

I imagine their key would be needed but that cannot be stored in the contract. Is there a workaround for this? Can the hash of the private key be stored?

I understand Escrow would work, but I want to just have the payer pay the payee without be present at the time of the txn.


texts: Contracts with custom fee and limited numbers of transactions

texts:
Is there a valid way to set custom re-sell fee for "custom currency", e.g. https://blog.ethereum.org/2015/12/03/how-to-build-your-own-cryptocurrency/ and limit this re-sells somehow?
For example:
0. custom currency can contain $ value, and its can be different (like different kinds of same contract)

first transaction A => B (0% custom fee, just ethereum network fee)
B => C (10% custom fee in ETH + ethereum network fee)
C => X -- transaction not allowed.
Also it is possible to to save custom fee in dollar (int) values in second step?( how i will proceed this fee its my headache)

Apologies for so many random questions, any hints are appreciated.

Cheers!


texts: Sending transaction from different addresses in truffle test case

texts:
I am having an admin in my contract who can do certain things. Here is the contract

function changeAdmin(address admin_) public {
    if (msg.sender != admin) revert();
    potentialAdmin = admin_;
}

function becomeAdmin() public {
     if(potentialAdmin==msg.sender) admin = msg.sender;
}

address public admin;

constructor() public{
      admin = msg.sender;
}

I am trying to test this using truffle framework. For this I need to pass an admin name from the contract creator and then call becomeAdmin from the address passed in first step. I am not able to clear this. Here is my test case

const te = artifacts.require("MyContract");

contract("Contract test cases", function() {

  it("should be able to change admin", async function() {

    var token = await te.deployed();

    var accounts = await web3.eth.getAccounts();

    var newAdmin = accounts[1];
    await token.changeAdmin.call(newAdmin, {from : accounts[0]});
    await token.becomeAdmin.call({from: newAdmin});

    var adminChanged = await token.admin.call();
    assert.equal(adminChanged, accounts[1], 'Admin set is wrong');

  });

});

Is the way of calling contract by passing different from addresses correct ?


texts: Identify whether the recepient of transaction is an external account or a smart contract

texts:
I know that an Ethereum transaction addressed to '0x000..000' is creating a new contract. Now, given a transaction address to non-zero address, I want to identify whether it is a transaction to an externally owned account(non-contract address) or to a smart contract.

One approach I figured out is to look at the debug trace of the transaction and distinguish between them.

My question is:

  Is there an alternative way of identifying whether the recipient of a transaction is an externally owned account or a smart contract?

Any solution using geth console or web3 API would be appreciated. Thanks


texts: Allocating unsold tokens at the end of a crowdsale to a specific address

texts:
I am using Open Zeppelin Token and Crowdsale contracts.

What should I do such that at the end of a crowdsale, the unsold token amount gets allocated to a specific address that I own?

Currently, the Crowdsale contract creates the Token contract, which assigns a portion of its balances to Crowdsale. But my understanding is that a contract has no private key, so how would I go about recovering the unsold tokens after the crowdsale ends?

Please advise.


texts: Uncaught TypeError: e is not a function from getAccounts() + web3 1.0.0-beta.37 + truffle + React Dapp

texts:
I am creating my first Dapp by using web3 1.0.0-beta.37 and trufflfe

While getting the accounts in app.js by using ganache-CLI and Metamask, I am getting  following error.

Uncaught TypeError: e is not a function in the console

Following is my code of App.js

import React, { Component } from 'react';
import './App.css';
import FormSubmitContract from './contracts/FormSubmit.json';
import getWeb3 from './utils/getWeb3.js';

class App extends Component {
  state = {
  web3:null,
  address:null,
};

 componentDidMount = async () =>{
 try{
    const web3 = await getWeb3();
    console.log(web3);
    const accounts = await web3.eth.getAccounts();
    console.log(accounts);
    const networkId = await web3.eth.net.getId();
    const deployedNetwork = FormSubmitContract.networks[networkId];
    const  instance = new web3.eth.contract(FormSubmitContract.abi,
    deployedNetwork, deployedNetwork.address);
 }catch(error){
  console.log(error);
 }
}

I am able to print the web3 in console log

Proxy {_requestManager: s, currentProvider: MetamaskInpageProvider, eth: r, db: e.exports, shh: a, …}

But got undefined in

const accounts = await web3.eth.getAccounts();
console.log(accounts); ==> undefined

I think there has been change in web3 1+ versions for getting the accounts.

Help me.
Thanks in advance


texts: web3.accounts.create() is not a function

texts:
I want to create a new account via code (Node.js), so I ran the following code, which was copy-pasted from the docs:

web3.eth.accounts.create();

How ever accounts' value is an empty array, and therefore I'm getting this error:

  web3.eth.accounts.create is not a function

which makes sense because Array doesn't have a method named create.

How do I create a new account?


texts: How can I retrieve transaction history of an address with my own ether node?

texts:
Etherscan shows transaction history of my address. How can I get the history without using Etherscan? I have my own ether node, geth server. Do I have to install anything tools?

https://ropsten.etherscan.io/address/0x5DBB9793537515398A1176d365b636A5321D9e39

Update 1

Seems using Block explorer is a good way.

e.g. etherchain-light
https://github.com/gobitfly/etherchain-light


texts: Quorum Smart Contract Avoid State Changes External Calls (Oraclize) - Deterministic

texts:
One of the Solidity best practices relating to external calls is to avoid state changes after an external call.

However, does this principle still apply if one is using a private blockchain such as Quorum?

For example, in a hypothetical situation, to decide if a trade should proceed (i.e., update a state variable in the smart contract), an external call to a service which returns credit spread VaR needs to be made first. Based on the result of the external call, the trade will either proceed or be halted.

Understand that the original intent of this external call principle is to ensure determinism. However, based on the returned external call result (i.e., an arbitrary number), the smart contract will use a if-else range to decide if the trade should proceed or not -- making this process deterministic again.

Thus, should a smart contract in a private/permissioned blockchain such as Quorum be allowed to make state changes after external calls?

SOURCES:
https://docs.oraclize.it/#background


texts: Is there a DAO to vote on Ethereum Foundation development decisions / direction?

texts:
I'd like to know if the Ethereum Foundation itself has been decentralized yet.

Is there a DAO with which is used to make decentralized decisions? Is it open to public viewing? Closed?


texts: How to divide a nominator against a denominator of a larger amount?

texts:
I am trying to get the value of (75 % 100) * 638

when the transaction is called the return value is 0 ?

is there any way to divide smaller numbers against larger ones, the purpose of the function is to return a percentage of the tokenAmount (638)

the code is below

pragma solidity ^0.4.21;

contract math {

  uint tokenAmount;

  function doo(uint _nominator) public returns (uint) {
      tokenAmount = 638;
      uint stPrize = (_nominator / 100) * tokenAmount;
      return stPrize;
  }
}

thanks in advance !


texts:
I am using MetaMask chrome extension, for my Dapp. I have a function which needs to transfer some amount to another account. This amount is of the order 200 to 800 wei. How do I set msg.value() attribute in MetaMask popup window?

This feature can be seen on remix, but I could not find it on MetaMask?


texts: Does Blockapps allow contract deployment to the Ethereum blockchain?

texts: I've been exploring Blockapps' Strato & bloc APIs and deploying sample contracts to their private blockchain, but I was wondering how I can use this to deploy a contract to the actual Ethereum blockchain. Any links to documentation on this (beyond the Blockapps API documentation) or examples would be very welcome.


texts: Specific to Cryptokitties -- Trying to learn how SaleClockAuction works

texts:
I'm trying to understand, how the actual process of putting something up for auction works and also how does web3 interact with this auction.

Here are my findings till now:

I think that SaleClockAuction.sol has to be deployed with _nftAddress and cut.
What is nftAddress? Is it an address of another contract (ERC721 contract, maybe?) or the users current account address?
Ok, once deployed, the address of SaleClockAuction.sol has to be copied and this address in turn has to be called from KittyCore.sol in order to un pause the contract.
Now, how is the process of  calling functions that puts up something for auction or bids on an auction work?  I see that the KittyCore exposes createAuction but not bid. Do users directly interact with the external functions of the deployed SaleClockAuction contract?

Where I am stuck with

Either calling createAuction from KittyCore.sol or createAuction and bid from SaleClockAuction.sol is throwing an error for me.


texts: How can I automize process of deploying my contract?

texts:
I am using following appoach How to deploy Ethereum Smart Contract through Brownie to the Private Network.
I want to automate this process in order to capture the transaction hash and deployed contract's address, and its abi.
Afterwards save them under a json file for my future use, instead of copy and paste them by hand.
[Q] How can I accomplish it?


texts: Best practices on handling both ether (Ξ) and tokens

texts: I'm writing a contract which should handle both ether (Ξ) and ERC20 tokens. I know that many dApps use WETH and I understand what it does, but I'm not sure if it's used because it's the most efficient in terms of avoiding writing code logic twice, gas costs etc - or some other reason?


texts: web3.eth.sendSignedTransaction -> insufficient funds for gas * price + value

texts:
I am signing this raw transaction and I can't seem to find the correct gas parameters to make the transaction valid. The from address/private key has over 3 ETH as seen here:
https://rinkeby.etherscan.io/address/0x22dd8860db83a962e8d2ec734eae62fab63e73ae

    var Web3 = require("web3")
    var web3 = new Web3("https://rinkeby.infura.io/TOKEN")
    var privateKey =
      "PRIVATE_KEY"

    var account = web3.eth.accounts.wallet.add(privateKey)

    var tx = {
      chainId: 4,
      from: "22dd8860db83a962e8d2ec734eae62fab63e73ae",
      gas: "12880",
      gasPrice: web3.utils.toWei("0.0000000001", "ether"),
      nonce: "0x0",
      to: "0x8a09e76a5255E3d07854647f4DBef7323F98323d",
      value: web3.utils.toWei(".000001", "ether")
    }

    var signed = account.signTransaction(tx)

    web3.eth.sendSignedTransaction(signed.rawTransaction).then(console.log)

I also tried converting to Hex and I receive the same error:

var tx = {
  chainId: 4,
  from: "22dd8860db83a962e8d2ec734eae62fab63e73ae",
  gas: web3.utils.toHex("21000"),
  gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')),
  nonce: "0x0",
  to: "0x8a09e76a5255E3d07854647f4DBef7323F98323d",
  value: web3.utils.toHex(web3.utils.toWei(".000001", "ether"))
}


texts: What is the difference between networkid 3 and testnet?

texts:
I have geth 1.5.4 installed on my ubuntu box. Here is the geth command line documentation for networkid:

  --networkid value                   Network identifier (integer, 0=Olympic (disused), 1=Frontier, 2=Morden (disused), 3=Ropsten) (default: 1)

So, to connect to the Ropsten network, I started geth with --networkid 3.

  geth --fast --networkid 3 console

However, it did not connect to the Ropsten network at all. My node started syncing but not sure what network it connected to. When I don't specify networkid but just pass --testnet:

  geth --fast --testnet console

it connects to Ropsten network correctly and starts syncing.

What is the difference between specifying --testnet vs --networkid 3?


texts: Sent ETH to my Wallet, but it did not show up

texts:
Note: This question was initially asked for Mist, but is in general also true for all other wallets like Ethereum Wallet, Etherwall, Parity, Harmony, etc.

I sent ETH from MyEtherWallet to my Mist Wallet, but balance did not show the sent amount. Later, I also imported MyEtherWallet account into Mist.

The transaction detail showing the amount that was sent to my Mist wallet below: https://etherscan.io/address/0x5C8a1cbEF21403B2D708796ea2F050F517393b91

Attached is a screenshot showing the 0 balance in my Mist wallet. I presume the blockchain is fully synced as I can see my Accounts Overview.

Any idea how I can use the amount that was sent to my Mist Wallet.


texts: How to create accounts and also retrieving the ether balance with web3j in a java file?

texts: I do not see anything in creating accounts and retrieving ether balance in web3j's documentation, I wonder if it is possible.


texts: Subscription sample using websockets or IPC?

texts:
So I was using the web3 API from the NodeJS 'web3' module very happily and it works very well (it uses HTTP transport AFAIU). But now I want to receive events from the server (without polling), and for that it seems I need to use the subscription API.

However, the documentation I just linked states subscriptions require a full duplex connection. Geth offers such connections in the form of websockets (enable with --ws) and ipc (enabled by default). Fair enough.

But, for the life of me, I cannot find any sample out there of how to connect via IPC/WebSockets. If the documentation included a simple hello world sample of a subscription, it would be rad.


texts: How can I get source code of deployed contracts

texts:
I'm doing a hobby project of blockchain exploration project. One thing I'd like to do is to see what contracts are deployed, maybe do some exploration analysis.

One thing I'd like to see is the source code of contracts.

There were quite a bit of questions on this matter, but I'd like take look at it from different angle: I'd like to be able to download source code somewhat automatically. Is there any standardish way to do it?

Things I have considered:

Download code from swarm, however it looks like that it is not widely used (is that true?);
Use service like: https://etherscan.io --- however API doesn't provide source code and their Terms And Conditions forbid scraping;