texts: Is gas cost of external calls included in gas cost of the main call?

texts:
When I call external methods of other contracts from my contract, is the gas fee of these calls included in the gas fee displayed by MetaMask?
My transaction reverts (execution reverted) for an unknown reason. May it be that it is because the price of inter-contract calls is not included into the gas price displayed by MetaMask, and for this reason my calling contract has not enough funds to pay for external calls?
If this trouble exists, how to calculate the full gas cost in advance, to be sure the entire transaction succeeds?


texts: block chain return the money back to the clients

texts:
I have this code (payable function):

function() payable inTime at_stage(Stages.InProgress)
active
{
    require(totalTokens <= totalTokensCapMax);

    require(token.isWhiteListed(msg.sender));

    require(msg.value>=minAcceptedAmount);

    totalTokens = safeAdd(totalTokens,safeMul(msg.value, intermedfinalConvRateETH));

    totalEtherContributed = safeAdd(totalEtherContributed,msg.value);

    insertToInvestorsArray(msg.sender);

    investedAmount[msg.sender] = contributor({
      amount:safeAdd(investedAmount[msg.sender].amount,msg.value),
      coin:"ETH"
    });
    beneficiary.send(msg.value);
    Contribution(msg.sender, msg.value, totalTokens);
}

now, the Crowdsale end without success.
how do I retrieve the ETH back to the clients? from the beneficiary account?

because now, only the beneficiary holds the money now - not the contract.

thanks!


texts: How to call fallback function because non existing function using truffle console?

texts: How I can test fallback function because non existing function in contract using truffle console?


texts: how to run my private geth node in https locally

texts:
i have my private ethereum blockchain but i need it to run in https://localhost:8545 or https://0.0.0.0:8545. currently it tun in http://0.0.0.0:8545 but when i try to connect it with Myethereumwallet
it shows the below error.

"Mixed Content: The page at 'https://localhost:8080/#/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://0.0.0.0:8545/'. This request has been blocked; the content must be served over HTTPS."


texts: Should I pre-buy gas to effect ethereum transaction?

texts:
I am new to ethereum. I have a few questions.

Should I pre-buy gas to effect ethereum transactions? Or can I just set what is the gas price I am willing to pay so that at the time of transaction the gas will be purchased automatically and deducated from the original transaction amount?
When I am doing an ERC20 token transaction, should I still have enough GAS in my account or can I use ERC20 token to buy the gas live at the time of transaction? Can you help?


texts: Going through large arrays with a for loop?

texts:
I am developing a dApp, and this line of code is in it:
    function generateActiveStakers() public  {
    delete actives;
    for (uint i = 0; i < stakers.length; i++) {

        if (isDeposited[stakers[i]]==true) {
            actives.push(stakers[i]);
        }
    }
}

This is working currently, but if I do this in the numbers of thousands of people, is it going to work? I am concerned about gas costs etc. If not, any alternatives?


texts: Is there an UserDefined Language of solidity for notepad++ available? If so does anyone can share a link?


texts: Access to providers in a cluster with web3 does not work

texts:
I have a blockchain deployed in a cluster. I have a geth instance running in a cluster-node and another one in another cluster-node, making a blockchain. I want to run an script which needs to access to the providers in both cluster-nodes. For example:

node1 - ws:127.0.0.1:3001
node2 - ws:127.0.0.2:3002

In the script I add the providers as:

var web3Provider_1 = new Web3(new Web3.providers.WebsocketProvider('ws://127.0.0.1:3001'));
var web3Provider_2 = new Web3(new Web3.providers.WebsocketProvider('ws://127.0.0.2:3002'));

Locally it works, but in the cluster the script cannot find the providers:

Error: Please provide an valid Web3 provider

What is the way to access to the providers to the different nodes in the blockchain from an script running in cluster-node?


texts: How to subscribe to future incoming ERC-20 token events?

texts:
I'm using web3j to subscribe to my ERC-20 token transfer events with transferEventObservable:
humanStandardToken.transferEventObservable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST).subscribe().
However, it only replays existing transfer events. How to subscribe to future incoming events?


texts: Running a geth light client, how do I resolve the error: "No trusted canonical hash trie"?

texts:
I've been running a geth light client to deploy smart contracts through Truffle Migrations to mainnet. I'm getting: "Error: No trusted canonical hash trie".

Any help in what this entails and how to resolve it?


texts:
I'm new to ethereum. I followed a tutorial and I ended up with a contract that looks like this

pragma solidity ^0.4.15;
contract HelloWorld {
  uint public balance;

  function HelloWorld()  {
      balance = 1000;
  }

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

After the contract is deployed at testrpc I try to call the deposit function with respect to the recent changes in syntax like so:

var hw = HelloWorld.deployed();
hw.then(function(i){
 return i.deposit(500)
})
.then(function(r){
  console.log(r)
})

but I get a Error: VM Exception while processing transaction: invalid opcode
How do I call this function?

Thanks.


texts: What geth sync mode to use for a blockchain-explorer-like analysis

texts:
I want to do analysis of the ethereum blockchain in a manner similar to what blockchain explorer sites do to answer a few more general questions.

I will need info on all addresses and transaction sizes.  But will not need debug trace info.  For example, we'll be asking questions like "what's the distribution of transaction sizes?"  "How long do addresses stay active?"  etc.

Can this be done with a "fast" sync mode in geth?  Or will I need to use "full" sync mode?  Does pruning matter here?


texts:
I have a question about my Ethereum Stack Exchange post: Metamask Out of gas error

I cannot transfer Ethereum from Metamask. It gives me out of gas error. I was trying to transfer just 1 of 5 ethers in my Metamask]2


texts: Regular address turns into a contract after receiving a transfer?

texts:
To accept payments in ether myself, I first tried how others have implemented it. So I bought an item in a store that uses Coinbase Commerce to accept crypto payments and paid for my item with ether. Here is my payment transaction:
https://etherscan.io/tx/0x229fc693785f97f905f9db953800edca58cced706592684d5f24ca9b69d80dac

At the moment I made this transaction, etherscan was showing the recipient address 0x6a173337f2bb7ad85c011dda499ab9cfc1016461 as a regular (external) address that has just received my payment and had the ether on its balance.

But 8 minutes (37 blocks) later a series of internal transactions appeared:
https://etherscan.io/address/0x6a173337f2bb7ad85c011dda499ab9cfc1016461/advanced#internaltx

Which included the contract creation and a transfer of the funds to another address. Here is the parent transaction:
https://etherscan.io/tx/0xc05d18302cf9363c858cea9068f1ba88827ef5b0d446553c44c5c9cab282c693

My question is: how could a contract be created on an existing address that was previously used as external? And what exactly has happened there in general? Does anyone understand such a scheme works under the hood? Any clues are highly appreciated, thanks!


texts:
Unfortunately this code doesn't work. It compiles, but the subtraction part doesn't work. Only without the checkValue function. Anybody has an idea whats wrong?

pragma solidity ^0.4.19;

contract Bank {
    uint private value;
    address private owner;

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

    function Bank(uint amount) {
        value = amount;
        owner = msg.sender;
    }

    function checkValue(uint amount) returns (bool) {
        return amount >= value;
    }

    function deposit(uint amount) {
        value += amount;
    }

    function withdraw(uint amount) {
        if(checkValue(amount)) {
        value -= amount;
        }
    }

    function balance() returns (uint) {
        return value;
    }
}

contract MyContract is Bank(10) {
}


texts:
I am following Theorem 2 from https://arxiv.org/pdf/1710.09437.pdf

I am referring to this example https://imgur.com/hwfYZor

Let a be the justified checkpoint with greatest height. Suppose that half of the validators have made votes s1 and s2, while the other half made votes s3 and s4. If the validators come to consensus that the chain with checkpoint d is indeed the canonical chain, I believe it would be impossible for them to finalize any checkpoint on that chain without validators violating slashing conditions, since the validators that voted for s2 would have to make surround votes. Hence, the casper protocol would get stuck.


texts: Transferring funds from a contract to an account using adresses

texts:
I had been trying for a long to transfer the complete fund with one of my contracts to a specific account. But nothing seems to be working.

pragma solidity >= 0.4.22;

contract reg{
  address owner;
  uint256 regFee = 2 ether;
  address[] private registered;
  uint a = 0;

  mapping (address => uint256) public balance;

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

  event registeration(address indexed _to);

  // function register() public{
  //     balance[(msg.sender)] -= 2 ether;
  //     balance[msg.sender] += 2 ether;
  //     emit registeration(msg.sender);
  // }

  function () payable external{
    balance[(msg.sender)] -= 2 ether;
    balance[address(this)] += 2 ether;
    registered.push(msg.sender);
    a++;
    emit registeration(msg.sender);
  }

  function list() public view returns(address, address, address){
    return (registered[0], registered[1], registered[2]);
  }
}

this the complete contract.

Another contract I want to write is to select one of the

  registered[0], registered[1], registered[2]

and transfer all fund of contract reg to contract subm. Following is the code to subm .

pragma solidity >= 0.4.22;

import "./Untitled.sol";

contract subm{
  address winner;
  reg public regi;

  mapping (address => uint256) public balance;

  function submissions() public{
    if (winner == address(0)){
        winner = msg.sender;
    }
    else {
        return;
    }
  }
}

Someone kindly help, confused due to new syntaxes.


texts: Is it beneficial to use events to store data when possible. I'd like to avoid storing excess data, as the data is only a reference for the outside world and has no functionality within that contract.


texts: How do you generate a EOA address with javascript?

texts:
With web3 you can use web3.personal.newAccount to generate a new EOA.
MyEtherWallet seems not to rely on its Geth node to generate such addresses. How would you generate EOA purely client side?


texts: How much liquidity to provide to Uniswap?

texts: So you deployed your brand new ERC20 token to Uniswap. I understand you need to provide liquidity for your token pair in Uniswap so people can start buying your token. Now, what I'm trying to wrap my mind around with is if the liquidity you provided was sold off, would that mean your token cannot be bought anymore?


texts:
I'm new in solidity and I'd like to have a little bit of debug.

this is my simple example (I'm using web3 1.0)

I have a simple function in my contract

function bar(address _address_usr) public  {
        uint res = 5;
        emit foo('test',res);
    }

And I have test about it

.....
it("...", async () => {

        let livello = await instance.methods.bar(accounts[0]).call();

        instance.events.foo(function (error, event) {
            console.log(event);
        })
            .on('data', function (event) {
                console.log("OK");
                console.log(event);
            })
            .on('changed', function (event) {
                console.log("OK");
            })
            .on('error', console.error);

    });
....

I'd like to know the result of res.
I tried with event but I have this error

err Error: The current provider doesn't support subscriptions: HttpProvider

Can I print some result/var in my console like console.log or something like that?

Thanks

  UPDATE

My web3 istance

helpers.js

const Web3 = require("web3") // import web3 v1.0 constructor

// use globally injected web3 to find the currentProvider and wrap with web3 v1.0
const getWeb3 = () => {
    const myWeb3 = new Web3(web3.currentProvider)
    return myWeb3
}

// assumes passed-in web3 is v1.0 and creates a function to receive contract name
const getContractInstance = (web3) => (contractName) => {
    const artifact = artifacts.require(contractName) // globally injected artifacts helper
    const deployedAddress = artifact.networks[artifact.network_id].address
    const instance = new web3.eth.Contract(artifact.abi, deployedAddress)
    return instance
}

module.exports = { getWeb3, getContractInstance }

my test.js

const {getWeb3, getContractInstance} = require("./helpers")
const web3 = getWeb3()
const getInstance = getContractInstance(web3)


texts: ERC20 method to keep track of current block number

texts: I'm looking for a method to include in my first smart contract which gets the current Ethereum block number. I've seen some indications that block.number will do this, but I'm not completely certain. Additionally, is there a list somewhere of all available methods?


texts:
I'm trying to find the python analog for the following function

In solidity

function getMineDigest(uint256 nonce, bytes32 challenge_digest, bytes32 challenge_number) public view returns (bytes32 digesttest) {
        bytes32 digest = keccak256(abi.encodePacked(challenge_number, msg.sender, nonce));

        return digest;
    }

I thought the python analog would be

web3.solidityKeccak(['bytes32','address','uint256'], [challenge_number, account, nonce])

But when I call the contract from python I get

getMineDigest(nonce, challenge_number, challenge_number).call()
output > b'S\x18\x0f\xc1\xf4\x99\\\xb7%N\x12\xf5\x94Ea\xb6\x08\x9a\xe4\x8d\xabD\xb6;#\xe3\xbf\xe9\x01\xef\x1b\xab'

And when I run the python analog I get

web3.solidityKeccak(['bytes32','address','uint256'], [challenge_number, account, nonce])

output > HexBytes('0xf44ce7626e2cb58df5fec54527ae88e1440661f4544fb5312fa79c35c216e45e')

It looks like one is in python bytes and the other is in hexbytes? Is that the only difference?


texts: Can I deploy a smartcontract with web3 1.0, without the metamask popup?

texts:
I'm using web3 1.0 to programmatically deploy smartcontracts and make transactions, and metamask to sign those transactions, since i don't want to have hardcoded fragile things.

I would like metamask to stop asking the permissions and do it automatically instead, is this possible?


texts: authentication needed: password or unlock

texts:
We're using Microsoft Azure, and NodeJS on the server. When we address Microsoft Azure via NodeJS, sometimes we get the 'Password or Unlock' error. But when we use Truffle and address the same setter, everything works fine. What could be the possible problem and what does this error mean as I've unlocked my account.

This is my code:

this.web3.eth.getCoinbase()
        .then(coinbase => {
            console.log("Setter method started!");
            return this.contract.methods
                .setCopyright(
                    queryParams.certificateNumber,
                    queryParams.typeString,
                    queryParams.nameOfObject,
                    queryParams.firstName,
                    queryParams.secondName,
                    queryParams.lastName
                )
                .send({
                    from: coinbase,
                    gas: 4600000,
                    gasPrice: '22000'
                });
        })
        .then(resolve)
        .catch(err => {
            reject(err);
        });


texts: Receiving and manipulating transaction data in smart contract

texts:
The idea is simple: you can send transactions using any ethereum wallet, and every such wallet has an additional data to send called "transaction data". For example, I want users to be able to type in that data field name of the product they are purchasing, a simple string or maybe an integer value (index of a product). Is that possible? I just want users be able to not only interact with my contract using metamask or mist, but also just using their maybe online wallets or etc.

As I read in docs, I have to use a standard fallback payable function, like

contract Test {
   function() payable {}
}

and somehow read the msg.data. How is that possible to read it?
I searched the questions but none of them had the right answer.
But there is more: fallback function executes only 2300 gas, so how can I handle it then?


texts: What is the difference between the STATICCALL and CALL EVM opcodes?

texts:
Besides the regular and very common CALL, the Ethereum Virtual Machine has the STATICCALL opcode. In which ways does it differ from the regular CALL?
Edit: This is not a duplicate because this question is about STATICCALL, that question is not!


texts: How to change push() method to simple code?

texts:
I have this code but it's static and I wanna change it dynamically.

function addCandidates(){
 if( own == 1 ){
    candidate[0].candidate_ID[0] = 1;
    candidate[0].candidate_ID[1] = 2;
    candidate[0].candidate_ID[2] = 3;
    candidate[0].candidateslength = 3;

    candidate[0].voteCount[0] = 0;
    candidate[0].voteCount[1] = 0;
    candidate[0].voteCount[2] = 0;
 }
}

It's static code in UPPAAL toll and I wanna change this above code to solidity code that is:

struct Candidate {
        string name;
        uint voteCount;
}
Candidate[] public candidates;
function addCanditate(string memory _name) ownerOnly public {
        candidates.push(Candidate(_name, 0));
}

So how can I use 1st UPPAAL code to 2nd solidity code without using push method dynamically?
Anyone have any idea it will be appreciated.


texts: Which contract(s) are exceeding block gas limit? (truffle.js)

texts:
Similar to this question, I am trying to debug a setup that is exceeding the default gas limit since upgrading to Truffle 4.

Turning on the newly disabled (by default) optimizer seems to be a commonly suggested solution that commonly does not work (as in my case). I tried increasing the gasLimit in my truffle.js file and the contracts indeed compiled and passed their tests as they did with Truffle 3.

I want to find out which contract or contracts are too large and therefore need to be refactored to pass the default gas limits. The error message currently gives no indications which contract or contracts are exceeding block gas limits. Any debugging techniques would be helpful.

Thanks!


texts: Can't see the source code with the new Etherscan user interface?

texts:
everyone! A few days ago, Etherscan has updated their user interface - and now I have no idea, how to get the verified contract's source. Before it was located no the #readContract tab, but now there's a list of static methods.

Have you met this problem? And how did you solve it? Thanks in advance!


texts: Is there a reason Ropsten doesn't have the same block gas limit as mainnet?

texts:
It appears as though Ropsten still has a limit of 4.7m gas while mainnet is almost 8m.  This makes testing for real-world dapps difficult.

Why is it that ropsten and mainnet are not in alignment with the block gas limit?


texts: No Data is Deployed on this contract address, no admin page

texts:
I am following this tutorial to create the My advanced token using this tutorial: https://ethereum.org/token

When I deploy the contract, I always get "No data is deployed on the contract"

I am running a private blockchain and I have tried 8 times the gas suggested by Mist. If I go too much further, it says block limit excited.


texts:
Wanted to build a graph of all the peers that my geth node is connected to.

Is there any option in geth where I can display all the peers that are in my node's kademlia k-buckets?


texts: Using smaller parent contract consumes less gas?

texts:
Here's my Test Code

pragma solidity ^0.4.20;

// StandardToken is from zepplin-solidity.
import "./StandardToken.sol";

contract Callee {

    address public caller_;

    function setCaller() public {
        caller_ = msg.sender;
    }
}

contract DirectCaller is Callee, StandardToken {

}

contract IndirectCaller {

    function call() public {
        // "0xb87..cfa" is the address of DirectCaller contract
        Callee(0xb87213121fb89cbd8b877cb1bb3ff84dd2869cfa).setCaller();
    }
}

DirectCaller inherits two parent contracts, Calle and StandardToken. Since StandardToken of zepplin-solidity is pretty big, DirectCaller's compiled bytecodes are also big.

IndirectCaller calls Callee.setCaller() function using DirectCaller contract with its parent Contract. In my Remix, DirectCaller.setCaller() consumes 20394 gas and IndirectCaller.call() only consumes 7056 gas.

Is the reason that IndirectCaller.call() loads less byte codes that is related with its Parent(in this case, Callee) Contract?

Then, why don't all of us use small sized abstract interface for saving gas consumption?


texts: from token transaction detail, how can I know if token is actually transferred?

texts:
I am implementing support of multiple tokens in my application.
I want to listen new token received transactions.

I got that I need to decode the input data in any transaction to get the toAddress and Amount of token transferred.
But I am confused at a point how can I know if token is really transferred or not? because method in input data can be different for different contracts.

So I know that transfer, transferFrom are methods used to transfer the token. so I can confirm if token-transfer is happened.
But I found Transfer and Sweep two methods for a contract. (for eg. Omisego Contract, Omisego Transaction-1, Omisego Transaction). but then I found depositToken method for another contract(for eg. Sharder Contract Sharder Transaction).

So my questions.

How can I get a list of transfer-methods for different tokens?(for eg. transfer-transferFrom for Omisego, depositToken for Sharder etc..)
is Mint method too a type of token transfer method, its here Omisego Contract?
or may be, if transaction is on Etherscan, assume tokens/ETH are always transferred from one address to another address/contract.

Thanks in advance for the help.


texts: Is Ethereum and other smart contract like blockchains considered a protocol or a framework?

texts: I'm not sure how to explain Ethereum or other smart contract systems like eos/tron/ardor/waves. Are these protocols or are they frameworks? How should it be classified? I want to explain to clients that I'm building on top of a protocol or a framework? My application doesn't require any ETH, but only interactions with crypto addresses and reading of transactions on each blockchain.


texts:
I am running a private node on my machine using geth. Everything is perfect.

Even my friend is doing the same on his machine.

Is there any way in which I can connect the node on my machine with my friend's such that the transactions on my machine can be visible to him too.

I am sure it involves something to do with the genesis file, but I'm not sure how to proceed.


texts:
Is there a way to move coins from one account to another (both in the same Ethereum node) without publishing it on blockchain?
On a Bitcoin Node I can do it with "move" command. Is there an equivalent for Ethereum?

Thanks


texts:
I am trying to run a simple contract in solidity :

contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address => uint) public balances;

// Events allow light clients to react on
// changes efficiently.
event Sent(address from, address to, uint amount, uint data);

// This is the constructor whose code is
// run only when the contract is created.
function Coin() {
    balances[tx.origin] = 1000000000000000000000000000000000000;
    minter = msg.sender;
}

function mint(address receiver, uint amount) {
    if (msg.sender != minter) return;
    balances[receiver] += amount;
}

function send(address receiver, uint amount, uint data) {
    if (balances[msg.sender] < amount) return;
    balances[msg.sender] -= amount;
    balances[receiver] += amount;
    return Sent(msg.sender, receiver, amount, data);
}

}

calling the send method using this :

function sendCoinTest() {
var meta = Coin.deployed();

var amount = 1;
var receiver = accounts[1];ElementById("receiver").value;
var data = web3.toHex("HelloWorld");

console.log("data : " + data);
setStatus("Initiating transaction... (please wait)");
meta.send(receiver, amount, data, {from: account}).then(function(result) {
    setStatus("Transaction complete!");
    console.log("Here I MA");
    var tx = web3.eth.getTransaction(result);
    console.log(tx);

    console.log("input" + tx.input);

}).catch(function(e) {
    console.log(e);
    setStatus("Error sending coin; see log.");
});

};

the last console gives me:

> input0x67df93f2000000000000000000000000ce76eebdf91149284fc9c596a9bd113ec8dae871000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000048656c6c6f20576f726c64

However I get a huge hex string on the last console statement, when I am trying to decode it using web3j.toAscii(), I get some garbage values like ^^&*(*%%bb^*HelloWorld

What is wrong with my code?


texts: trading a secret message with some person only after money is paid

texts:
I want to build a DAPP where person A trades a message with person B for ether. Since the message is secret, person A encrypts the message by using public key of person B and stores the message in contract.As soon as he encrypts and puts in blockchain, person B can see that by using his private key.
whereas  I want person B to see the original content only after he pays ether.How to achieve this ?


texts: Is possible to transfer data between nodes using cpp-ethereum's whisper protocol?

texts: Right now I am working on developing a standalone application in C++ using libraries of cpp-ethereum, I was looking at the source code for cpp-ethereum and an idea stuck into my mind that wouldn't it be cool if we can use whisper protocol of cpp-ethereum for transferring actual data like actual file transfer? Can we do it?


texts: Today I learned that for Bitcoin, the probability of a hash being valid is approximately 1/(D*2^32), whereas D denotes to the difficulty. Is this also true for Ethereum, or in general for other cryptocurrencies? If not, what would be the equivalent for Ethereum?


texts: How can i get my var in Web3, i always get Promise {  }

texts:
var gogo =web3.eth.getBalance("0xXXXXXXXXXXXXXX")
.then(console.log);

console.log(gogo);

if (gogo > 123) {
    console.log('enough.');
}

how to run if in this case? Thanks for helping me.


texts: Returning 2D array with dynamic sizes from a function

texts:
This 2D array works when setting the array lenghts with constant values.  But i'd prefer to use a dynamic array size:

function funWith2DArray(address[] array1,  address[] array2) public view returns (uint[50][50]) {
    uint[50][50] memory result;
    // ...
    return result;
}

This 1D array works, when dynamically setting the array length:

function funWith1DArray(address[] array1,  address[] array2) public view returns (uint[]) {
    uint[] memory result = new uint[](array1.length * 2);
    // ...
    return result;
}

How can I do a 2D array with dynamic lengths?:

function funWith2DArray_2(address[] array1,  address[] array2) public view returns (uint[][]) {
    // Not valid syntax
    // uint[][] memory result = new uint[][](array1.length * 2)(array1.length * 2);
    // Not correct either, error: Identifier must be declared a constant
    // uint[array1.length * 2][array1.length * 2] memory result;
    return result;
}

Note: This function must have the view modifier so I can call it (reading data only) without paying gas.

My current workaround is just cramming all the response data into one array and just knowing where to look to find it (which is okay)


texts: How would zkSNARKs reduce computation on Ethereum mainnet?

texts:
cmiiw, zkSNARKs mean that computations can be verified by a single node and therefore not executed by every node on the network-- link, and work is being done to include this feature in the mainnet.

How do zkSNARKs fit into the broader picture: as a requisite for scalability (alongside Plasma/Swarm, and sharding?), or for privacy?


texts: How to return a ENUM in string instead of integer

texts:
A State is defined and function to return state in smart contract:
enum State { ForSale, SellerDelisted, BuyerCancelled, BidPlaced, DepositMade, InDispute, Complete }
State public state;

function returnState() view external returns (State) {
    return state;
}

For a state = State.Complete, the state return is 6. How can I get a string Complete returned instead?


texts: zk-SNARK use cases in blockchain (except payment)?

texts:
Is there other examples of using zk-SNARK for supporting "private transactions" except Zerocoin or Zchach ? (For example, is it possible to use zk-SNARK for health data ? or any other use cases in which the data privacy is important ?)

The only example I found was related to the "payment use case" such as Zerocash . Does it mean zk-SNARK use case in blockchain is limited to use it only in the payment use case ?

Is there other research papers on using zk-SNARK for supporting data privacy and private transactions in the blockchain except payment use case?


texts:
I have contract and function which accepts ether. How can I transfer ether from contract to any other wallet?

I'm using ganache-cli. Function work, and I spent 10 eth on contract(private network). Now I want to get them back

  contract Account {
    mapping (address => uint) balance;

            function accept(uint postId) payable public {
                balance[msg.sender] += msg.value;
                uint beforeWeight = posts[postId].weight;
            }

this function takes my ether from wallet, I want to take eth from contract to my wallet

 function transfer(uint amount) payable public {
            address(this).transfer(amount);
        }

    }


texts: Why transaction hash isn't available inside solidity function call

texts:
I recently bumped into this
Is it possible to get the transaction hash from within a Solidity function call? while I was looking for a way to save the transaction hash inside my contract. And accoriding to that thread the transaction hash is not available as global variable inside solidity contracts. So I am wondering, why it is not available although the hash is predetermined?, Is there a reason for that?


texts: How do fronrunning and sniper bots work?

texts:
If you ever traded in defi, you probably have seen coins getting sniped at the very second of their launch and drastically inflating the prices.
I assume these bots are written in js, ad using web3 and other blockchain API to interact with smart contracts. In theory, I can assume that the algorithm basically buys those coins that are recently launched with high gas, and since it is an algorithm it performs this faster than any other human.
However, my question is how are these sniper bots really work? How do they time the launch so well? Sometimes a launch can get delayed, in that case when they send queries to blockchain aren't they losing money?
For instance, this BOT just made 1 million dollars by just sniping PAID Network in 2 minutes.
But, what if the launch was delayed how was it going to execute trades? If it started sending 'buy' queries before the launch would it not lose money?
Any opinions on this subject?
I would really appreciate if you enlighten me about this, I've been wondering about this for some time now


texts: Can I use a separate pc to run a full eth node and connect to it?

texts: Since running a light node doesn't work (no peers connecting) and running a full node on my pc takes up basically all the RAM while syncing I've decided to run a full node on my old laptop instead. Will it be possible to connect ganache to my laptop if it's running on the same local network? If so what flags do I need when starting up geth on my laptop?


texts: How to I extract the wallet Vault on Chrome using a command in MacBook?

texts:
I forgot my seeds phrase for MetaMask in my Macbook. I tried to follow guideline (https://metamask.zendesk.com/hc/en-us/articles/360018766351-How-to-use-the-Vault-Decryptor-with-the-MetaMask-Vault-Data) but I got an error.
Steps I did

Go to Extensions in Chrome

Right click and open Inspector

Go To console

Copy and paste below commond got from the guildline
chrome.storage.local.get('data', result => {
var vault = result.data.KeyringController.vault
console.log(vault)
})
**** Not sure whether I put above command correctly in console.***

Got below error

Please help me to recover my seeds phrase.


texts: Say I have the Ballot Smart Contract on my Mist Remix IDE. Where do I go from there? I am completely lost. I compile the code. Then how do I deploy it. How do I provide the names for the proposals? How do I run this on the web server?


texts: How can I demonstrate attacks on Quorum-based smart contracts in my local test network?

texts:
Currently, I am conducting a research regarding the security and privacy vulnerabilities of Quorum-based smart contracts. However, so far I've been struggling to implement attack vectors in order to demonstrate possible attacks. An overflow or reentrancy vulnerability is fairly easy to implement and exploit, but other vulnerabilities listed in the Quorum documentation (https://docs.goquorum.consensys.net/en/stable/Concepts/Security/Framework/DecentralizedApplication/SmartContractsSecurity/#common-contract-vulnerabilities) such as time manipulation are less trivial. Moreover, little academic literature regarding this topic exists. Could you please provide some tips on how to implement these kinds of attack vectors and which tools to use to this end? So far, I have set up the 7nodes example using Docker and I use Remix with the Quorum plugin in order to deploy smart contracts.
Thank you in advance.


texts:
I'm using web3j to analyze transactions.
How can I get transactions of a specific contract (assuming I got it's address) in some time frame (or blocks interval) and how can I know if ERC20 tokens were transferred in a transaction once I get it?


texts: I need to be able to retrieve all transactions that happened in a certain time period for arbitrary token on ethereum network. What is the proper way to do it?


texts: Getting the "VM Exception while processing transaction: revert" error for a pay() function

texts:
I'm getting the following error during the testing in Truffle:

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

It simply says "revert" without the contingency message, which tells me that it's not coming from any of the "require" functions I've defined.  I've also tried running the test with everything else commented out, except for the "pay()" function, including all the other test, but still didn't work.

testing

it("can pay the payout from the pending credit to the proper beneficiary", async () => {
    // ARRANGE
    let beneficiary = accounts[2];
    let flightAddress = accounts[4];
    let initialBalance;
    let postBalance;
    let eventEmitted = false;
    // ACT
    try {
      initialBalance = await web3.eth.getBalance(beneficiary);
    } catch (e) {
      throw new Error(e);
    }
    await config.flightSuretyData.buy(beneficiary, 100, flightAddress);
    await config.flightSuretyData.creditInsurees(beneficiary);
    await config.flightSuretyData.pay({ from: beneficiary }); // right here!
    await config.flightSuretyData.contract.events.InsurancePayoutPaid(
      function () {
        eventEmitted = true;
      }
    );
    try {
      postBalance = await web3.eth.getBalance(beneficiary);
    } catch (e) {
      throw new Error(e);
    }
    assert.equal(
      postBalance - initialBalance,
      result,
      "The insurance payout failed"
    );
    assert.isTrue(eventEmitted, "The event InsurancePayoutPaid is not emitted");
  });

contract

    function pay() external payable requireIsOperational {
        require(msg.sender != address(0), "Not a valid address");
        require(
            insurance[msg.sender].isValue == true,
            "The caller is not insured"
        );
        require(
            pendingCredit[msg.sender] != 0,
            "The pending credit amount is 0"
        );
        uint256 payout = pendingCredit[msg.sender];
        pendingCredit[msg.sender] = 0;
        msg.sender.transfer(payout);
        // address(uint160(msg.sender)).transfer(payout);
        emit InsurancePayoutPaid(msg.sender, payout);
    }

I thought maybe it had to do with the gas limit so I tried :

await config.flightSuretyData.pay({ from: beneficiary, gasPrice: 0 });

or

await config.flightSuretyData.pay({ from: beneficiary, gas: 0 });

But none worked.

I've tried :

web3.utils.fromWei(postBalance) - web3.utils.fromWei(initialBalance) for the assertion

or

"web3.utils.fromWei(100)" for the argument for the buy() function, but that wasn't it either.

Finally, I've deleted the build, truffle migrate --reset and then tried testing again, but still the same result.


texts: Stack too deep error in Solidity v0.8.4, no error / debug info from compiler

texts:
I have been facing the Stack too deep error, and it is being displayed without any line number / contract info. It is compiling all my contracts together (over 10) and I have no clue where this error is happening and how I am supposed to fix this. Any clues to make the compiler more verbose? I have already read through many of the posts talking about this, and I have worked on reducing local variables / moving to structs wherever possible, though it has not changed anything. I don't have a single function with over 7 parameters (and that one was compiling fine for a long time before this error appeared).
Any help will be much appreciated!!
I am using Solidity v0.8.4.


texts: msg.sender not address payable? (Solidity 0.8.2)

texts:
I've switched from Solidity 0.7.2 to 0.8.2
And the addresses declared as payable (owner) are reporting they are "NOT payable" in the contract.
pragma solidity ^0.8.2;

contract MyContract {
  address payable public owner;

  constructor(address oracleAddress) {
    owner = msg.sender;
    priceFeed = AggregatorV3Interface(oracleAddress);
  }

Results in..
TypeError: Type address is not implicitly convertible to expected type address payable

Was there a change that in 0.8.2 that causes this? What is the work around?


texts: "Error: base fee exceeds gas limit" when using the withdrawal pattern

texts:
When I am testing the withdraw() method from "WithdrawalContract" from http://solidity.readthedocs.io/en/develop/common-patterns.html using Remix and testrpc, it reported the following error. Testrpc gas limit is set to 0xffffff. Any hint on why does this problem appear?

callback contain no result Error: Error: base fee exceeds gas limit
at runCall (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88096:17)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11855:24
at replenish (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8948:17)
at iterateeCallback (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8933:17)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8908:16
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11860:13
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74400:16
at replenish (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74347:25)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74356:9
at eachLimit (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74280:36)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:75460:16
at VM.AsyncEventEmitter.emit (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74051:3)

FYI The contract code is

pragma solidity ^0.4.11;

contract WithdrawalContract {
    address public richest;
    uint public mostSent;

    mapping (address => uint) pendingWithdrawals;

    function WithdrawalContract() payable {
        richest = msg.sender;
        mostSent = msg.value;
    }

    function becomeRichest() payable returns (bool) {
        if (msg.value > mostSent) {
            pendingWithdrawals[richest] += msg.value;
            richest = msg.sender;
            mostSent = msg.value;
            return true;
        } else {
            return false;
        }
    }

    function withdraw() {
        uint amount = pendingWithdrawals[msg.sender];
        // Remember to zero the pending refund before
        // sending to prevent re-entrancy attacks
        pendingWithdrawals[msg.sender] = 0;
        msg.sender.transfer(amount);
    }
}


texts:
We want to start accepting ether from our clients and I'm learning API to make correct architechture.

Need to find correct answers for two questions:

Usually (working with btc), we create new incoming address for each new incoming transaction. In ether it's made via geth account new and it creates new wallet with new address.
Is that correct and common way of accepting incoming payments?

If we have thousands of clients, creating new account for each new incoming trasaction will get us tens of thousands accounts. And to transfer ether from those children wallets to main wallet will cost us a commission (since there is no move method like in btc blockchain).

May be it more appropriate to require client send us ether with unique message and use the same address all the time? But I dont see how to attach message to transaction in eth_sendTransaction command.

I couldnt find any method to list all incoming transaction to my wallet, The only way I could figure out that there is incoming transaction is to request eth_getBlockByNumber method and than go through all transactions in block to find those that were sent to my address. Is that correct and common way of acquiring incoming transactions?

thanks for help


texts:
Im testing wheter a require function does its job by reverting and want to test in within a truffle test.

  it("The URI should be unique", async () =>{

    const dupURI = await token.mintUniqueTweetTo(account1, tokenUri1, {from: accounts[0]}); // Mint a new token
    expect(dupURI).to.throw();
    console.log(dupURI)

  });

The thing is that when the require reverts I get the following error:

Error: Transaction: 0xaf416881ff8627e6fe5fe6eaed2512035d7b7e659aeb0638e2f1bd362f380d57 exited with an error (status 0).
Please check that the transaction:
    - satisfies all conditions set by Solidity `require` statements.
    - does not trigger a Solidity `revert` statement.

And my test does not continue, does anybody have an idea on how to fix this?


texts: How to maintain list of contributors and their contribution?

texts:
In my smart contract I have a map which map a person and his/her contribution. Say for example a contributes 20 ether, b contributes 10 ether. Everything works fine, but when I checking it shows:

{
    "0": "address: contributor 0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db",
    "1": "uint256: amount 20000000000000000000"
}

But actually he contributed 20 ether only. How can I maintain the exact amount? So, finally I can return their exact amount. Thank you.


texts: How can a Dapp store seed keys of non-HD wallets?(tumbleweed)

texts: As the title suggests, is there a Dapp that exists to store seed keys of wallet?


texts:
I want to do the following:

contract Base {
    bool public active;

    modifier canSetMetadata() {
        require(active == false);
        _;
    }
}

contract BaseWithMetadataControl is Base {
    address public metadataControl;

    modifier canSetMetadata() {
        if(msg.sender != metadataControl) {
            super.canSetMetadata();
        }
        _;
    }
}

So the child class should call the parent's class modifier. It doesn't seem to be possible but I don't want to duplicate the modifier code because it's likely to change...


texts: Working with Ethereum Light Wallet. Converting a string of text into a 12 word mnemonic?

texts:
I'm trying to create an ethereum address from a string of text using https://github.com/ConsenSys/eth-lightwallet

But it seems that the wallet requires a 12 word mnemonic in order to generate an address. I couldn't figure out a way where I can provide a string of text to generate the 12 word mnemonic which generates the address. How would I go about this?

The input has to be a string of text, in my case its a bitcoin private key that needs to converts into a 12 word mnemonic to get an ethereum address. If I can use any string of text and skip the mnemonics, that would work too!


texts:
I have a function which is accepting a string argument as input parameter.
This string is an IPFS hash and I would like to check that the input is actually just that and not a malicious link or the like. How can I use require check to achieve this?
 E.g. check that the input argument is on pair with a format such as mtYgPpHdWEz79ojWnPbdGgPpHdWEz7 and not malware.com


texts: Understanding solidity inline assembly code

texts:
Here is a code from solidity documentation:

 function sumAsm(uint[] _data) public returns (uint o_sum) {
        for (uint i = 0; i < _data.length; ++i) {
            assembly {
                o_sum := add(o_sum, mload(add(add(_data, 0x20), mul(i, 0x20))))
            }
        }
    }

Can any one explain this code.
_data is an array of uint. How are can we add 0x20 to an array. If the array name represents the address of first element why are we offsetting it? How does this line (add(add(_data, 0x20), mul(i, 0x20))) give the address of the first and the subsequent elements of the array.


texts: Test complains on 'await is reserved word'

texts:
I write test for my contract. By some reason compiler complains on await It is reserved word, but it used properly -- the rest of test functions works well.

await is a reserved word (42:2)
  40 |  it (`client buy good on the market - one good available on the market - no goods on the market`, function() {
  41 |      let goodSample = "Fruit";
> 42 |      await market.sell(accounts[0], web3.fromAscii(goodSample), 10, {from: accounts[0], gas: 300000} );
     |      ^
  43 |      let good = await market.getCostForGood(web3.fromAscii(goodSample));
  44 |
  45 |      let goodResult = await market.buy(web3.fromAscii(goodSample));
    at Parser.pp$5.raise (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:4454:13)
    at Parser.pp$3.checkReservedWord (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:4347:10)
    at Parser.pp$3.parseIdentifier (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:4324:10)
    at Parser.pp$3.parseExprAtom (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3648:21)
    at Parser.pp$3.parseExprSubscripts (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3494:19)
    at Parser.pp$3.parseMaybeUnary (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3474:19)
    at Parser.pp$3.parseExprOps (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3404:19)
    at Parser.pp$3.parseMaybeConditional (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3381:19)
    at Parser.pp$3.parseMaybeAssign (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3344:19)
    at Parser.pp$3.parseExpression (/home/user/Workspace/myether/datadir1/ttruffle/node_modules/babylon/lib/index.js:3306:19)

let market;

beforeEach(`create subject instance before each test`, async function() {
    market = await Market.new();
})

it(`client put good on the market - one good - one good is available on the market`, async function() {
    let goodSample = "Apple";
    await market.sell(accounts[0], web3.fromAscii(goodSample), 10, {from: accounts[2], gas: 300000} );

    let good = await market.getCostForGood(web3.fromAscii(goodSample));

    assert.equal(good[1], 10);
    assert.equal(web3.toUtf8(good[0]), goodSample);
})

it(`client put good on the market - two different goods - two goods are available on the market`, async function() {
    let goodFirstSample = "Fruit";
    let goodSecondSample = "Laptop";
    await market.sell(accounts[0], web3.fromAscii(goodFirstSample), 10, {from: accounts[1], gas: 300000} );
    await market.sell(accounts[0], web3.fromAscii(goodSecondSample), 100, {from: accounts[1], gas: 300000} );

    let goodFirst = await market.getCostForGood(web3.fromAscii(goodFirstSample));
    let goodSecond = await market.getCostForGood(web3.fromAscii(goodSecondSample));

    assert.equal(goodFirst[1], 10);
    assert.equal(web3.toUtf8(goodFirst[0]), goodFirstSample);
    assert.equal(goodSecond[1], 100);
    assert.equal(web3.toUtf8(goodSecond[0]), goodSecondSample);
})

it(`client put good on the market - two same goods - one good with two quantity is available on the market`, function() {

})

it (`client buy good on the market - one good available on the market - no goods on the market`, function() {
    let goodSample = "Fruit";
    await market.sell(accounts[0], web3.fromAscii(goodSample), 10, {from: accounts[0], gas: 300000} );
    let good = await market.getCostForGood(web3.fromAscii(goodSample));

    let goodResult = await market.buy(web3.fromAscii(goodSample));

    assert.equal(good[0], accounts[0]);
    assert.equal(good[1], goodSample);
    assert.equal(good[2], 10);
})

Any clue why does it happen?


texts:
I want to sign a message with my ethereum account in a javascript application.
I do not want to work in a web-browser or with metamask.
I want to build a stand alone javascript program.
Is there a way to do that with ethereumjs-wallet for example ? I have searched for tutorials and i did not found anything.
Thanks


texts:
pragma solidity ^0.4.0;

contract Storage {

    uint8[5][5] public data;

    function Storage() public {

    }

    function setData(uint8[] _data) {
        for (int i=0;i<5; i++)
            data[i][1]=_data[i];
    }

    function getData() public constant returns(uint8[5][5]){
        return data;
    }

}

on my web3 page i call the contract to store the data:

        var byteArray = new Uint8Array(25);
        var randomArray = [0x80, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05,
                          0x01, 0x02, 0x03, 0x04, 0x05];
storeSC.setData(byteArray , function (error, result) {
        if (!error)
            document.getElementById('response').innerHTML = 'Success:' + result
        else
            console.error(error);
    });

Anybody can explain me why passing randomArray everything works but I send out a lot more data than needed, passing  byteArray I get:

invalid number of arguments to solidity function

I just want to be able to pass a set of bytes to the method setData, any help on how to do it please?


texts: Testing library functions with Javascript & Truffle

texts:
I'm trying to test functions of a library with Truffle. But they don't seem to be available.

The library is named Commons and I include it as I would include a contract:

var Commons = artifacts.require("./Commons.sol");

But if I do

let foo = Commons.new();
let returnValue = foo.getBalancePeriod(5);

I get:

TypeError: foo.getBalancePeriod is not a function

If I instead do

let returnValue = Commons.getBalancePeriod(5);

I just get:

TypeError: Commons.getBalancePeriod is not a function

I made sure that the function name is exactly as it was defined in the library but the function just doesn't seem to exist.


texts:
Is it generally better to define a contract instance once, then pass it through your components like...

    class Parent extends React.Component{
      constructor(props){
        super(props);
        this.state={
          contract = new contract(contract.abi, contract.address)
          }
        }

      render() {
        return{

            <Child contract={this.state.contract}/>

        }
      }
    }

    class child extends React.Component{
      constructor(props){
        super(props);
      }

      async function = () => {
        //use this.props.library in here to call contract methods
      }

      render() {
        return{

            <other stuff />

        }
      }
    }

Or is it alright to define a new contract instance every time you need to use it?

    class Parent extends React.Component{
      constructor(props){
        super(props);
      }

      render() {
        return{

            <Child />

        }
      }
    }

    class child extends React.Component{
      constructor(props){
        super(props);
      }

      async function = () => {
        //use this.state.library in here to call contract methods
      }

      render() {
        return{

            <other stuff />

        }
      }
    }


texts: Transferring aToken(aDAI) in my truffle tests reverts with unspecific error

texts:
I'm having issues with setting up a truffle test to transfer aTokens (aDAI) to my contract. I'm using Aave v2 and running ganache with a fork from mainnnet.
This is what I did so far:
1- Started a mainnet fork w/ the following command, to unlock an account w/ enough DAI and aDAI tokens.
ganache-cli -f https://mainnet.infura.io/v3/{YOUR_INFURA_KEY} -m "bla bla bla bla bla bla bla" -i 999 --unlock {UNLOCKED_ACCOUNT}
Grabbed aToken ABI from here: https://github.com/aave/aave-protocol/blob/master/abi/AToken.json
Then, setup an initialization method for my unit tests to transfer some aDai token to my contract:
// loads the aDai token from the Mainnet address
let interestBearingToken = new web3.eth.Contract(aTokenABI, '0x028171bCA77440897B824Ca71D1c56caC55b68A3');

// Check unlocked account balance to make sure it has enough tokens to transfer. I removed the console.log, but I unlocked an account w/ thousands of aDAI.
const aDaiUnlockedBalance = await interestBearingToken.methods.balanceOf(unlockedDaiAccount).call({ from: admin });

// This method fails with: "Returned error: VM Exception while processing transaction: revert"
await interestBearingToken.methods.transfer(MyContractAddress, 10).send({ from: unlockedDaiAccount });

The transfer method fails with : Returned error: VM Exception while processing transaction: revert
At first, I thought that maybe the funds were locked at Aave (due to being used for collateral), so I decided to check if the transfer was allowed, using the following read call:
interestBearingToken.methods.isTransferAllowed(unlockedDaiAccount, daiAmount).call({ from: admin });

This method also fails with Returned error: VM Exception while processing transaction: revert
I thought it could be due to something related to the Proxy used by aTokens, so instead of using the entire aToken ABI as shown above, I decided to use web3.eth.call just to check if the transfer would be allowed, by doing the following:
    let abi =   {
                    "constant": true,
                    "inputs": [
                      {
                        "internalType": "address",
                        "name": "_user",
                        "type": "address"
                      },
                      {
                        "internalType": "uint256",
                        "name": "_amount",
                        "type": "uint256"
                      }
                    ],
                    "name": "isTransferAllowed",
                    "outputs": [
                      {
                        "internalType": "bool",
                        "name": "",
                        "type": "bool"
                      }
                    ],
                    "payable": false,
                    "stateMutability": "view",
                    "type": "function"
                };

                let functionData = web3.eth.abi.encodeFunctionCall(abi, [unlockedDaiAccount, daiAmount]);
                let allowed = await web3.eth.call({
                    from: admin,
                    to: '0x028171bCA77440897B824Ca71D1c56caC55b68A3',
                    data: functionData
                });

However, this attempt also reverts with the same error: Returned error: VM Exception while processing transaction: revert
PS: If I use the same steps but instead of aDAI ABI and address (from Aave) I use DAI's ABI and address, everything works.
Local environment:
Truffle v5.1.56 (core: 5.1.56)
Solidity - 0.6.11 (solc-js)
Node v10.23.1
Web3.js v1.2.9

Any ideas of what may be the issue with the above? Any help is appreciated.


texts: External Javascript isn't updating account balance

texts:
I have a simple smart contract that is supposed to record input strings on the blockchain using events:

pragma solidity 0.4.19;

contract Recorder{
  event Record(
    address _from,
    string _message,
    uint _cash
  );

  function record(string message) public payable {
    Record(msg.sender,message,msg.value);
  }

  function () public payable {}
}

I have deployed it on my testrpc network and it works fine. I have this external javascript code that I execute view truffle console:

module.exports = function(callback) {
const Recorder = artifacts.require('Recorder');
//const artifacts = require('./build/contracts/Recorder.json');

recorder = Recorder.at(Recorder.address);

recorder.record.sendTransaction("123",{from: web3.eth.accounts[0],value: 70}).then(console.log(web3.eth.getBalance(Recorder.address)));

console.log(web3.eth.getBalance(Recorder.address));

}

It works fine, but the account balance doesn't update in the script. The console.log portion shows a balance of 0 at the address.

If I console.log the account balance in the truffle console after running this external script it shows the correct balance.

If I run the external script again it shows a non-updated account balance. If I run the script once it shows a balance of 0. The second time I run the console.log portion only shows 70, etc.

The truffle console is always up to date, but the external script is always one run behind. It isn't a big issue, I just want to expand my understanding of what is going on in the background.


texts: Solidity ecrecover and web3j Sign.signMessage() are not compatible, is it?

texts:
Using Web3j to sign and verify a message is fine but when I use the signature generated by Web3j to verify using ecrecover in solidity it doesnot seem to work correctly. The signer address is different when executing the solidity code.

On searching for a solution, I found out that newer geth version prepends string "\x19Ethereum Signed Message:\n32" on signing.

Reference here: Totally baffled by ecrecover

I tried to use the solution in reference question but it does not seem to work. My question is what is different with respect to Web3j?
Can anybody familiar with Web3j provide me a working example for message signing and verification?

Here is a simplified version of the contract I was working on:

pragma solidity ^0.4.0;

contract Auth {

    string public name;

    function Auth(){
        name = "Auth 1.0";
    }

    function verify(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
        address signer = ecrecover(_message, _v, _r, _s);
        return signer;
    }

    function verifyWithPrefix(bytes32 _message, uint8 _v, bytes32 _r, bytes32 _s) constant returns (address) {
        bytes memory prefix = "\x19Ethereum Signed Message:\n32";
        bytes32 prefixedHash = sha3(prefix, _message);
        address signer = ecrecover(prefixedHash, _v, _r, _s);
        return signer;
    }
}

Here is the java code using Web3j.

    // Message to sign
    String plainMessage = "hello world";
    byte[] hexMessage = Hash.sha3(plainMessage.getBytes());

    // Use java to sign and verify the signature
    Sign.SignatureData signMessage = Sign.signMessage(hexMessage, ALICE.getEcKeyPair());
    String pubKey = Sign.signedMessageToKey(hexMessage, signMessage).toString(16);
    String signerAddress = Keys.getAddress(pubKey);
    System.out.println("Signer address    : 0x"+ signerAddress);

    // Now use java signature to verify from the blockchain
    Bytes32 message = new Bytes32(hexMessage);
    Uint8 v = new Uint8(signMessage.getV());
    Bytes32 r = new Bytes32(signMessage.getR());
    Bytes32 s = new Bytes32(signMessage.getS());

    String address = contract.verify(message, v, r, s).get().getValue().toString(16);
    String address2 = contract.verifyWithPrefix(message, v, r, s).get().getValue().toString(16);
    System.out.println("Recovered address1 : 0x"+address);
    System.out.println("Recovered address2 : 0x"+address2);


texts: Why is the value of "net.peerCount" keep changing, though, I've ONLY 2 nodes in my Local Private Ethereum Network?

texts:
I'm currently setting up Local Private Ethereum Network using Puppeth. And followed the steps provided in tutorial: Provisioning a Local Private Ethereum Network with Puppeth .

As per the above documentation:

7. Connect the two nodes.

console2> admin.nodeInfo.enode {ENODE-URL}
console1> admin.addPeer({ENODE-URL})

If everything went well, net.peerCount should be 1 in both consoles.

But, below is what I'm getting:

Console 1:

myMac:console1 admin$ geth attach ipc:../node1/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.3-stable/darwin-amd64/go1.9.2
coinbase: 0xf8b09187db667abb9cb1494237e65b3e2c3373a0
at block: 0 (Wed, 10 Jan 2018 21:36:58 +04)
 datadir: /Users/admin/EtherNet/testnet/node1
 modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> admin.addPeer("enode://f48fcf69ba27442ff3813912ec12ea1ad249f14739dabfcadb3985c3654540e047700030adba5800bf33d0adbdd9ca5f1c47aae2498a0d9dafb8c2fd730969b4@[::]:3002"
... ^C
> admin.addPeer("enode://f48fcf69ba27442ff3813912ec12ea1ad249f14739dabfcadb3985c3654540e047700030adba5800bf33d0adbdd9ca5f1c47aae2498a0d9dafb8c2fd730969b4@[::]:3002")
true
> net.peerCount
3
>
> admin.addPeer("enode://f48fcf69ba27442ff3813912ec12ea1ad249f14739dabfcadb3985c3654540e047700030adba5800bf33d0adbdd9ca5f1c47aae2498a0d9dafb8c2fd730969b4@[::]:3002")
true
> net.peerCount

5
> net.peerCount
1
> net.peerCount
1
>

Console 2:

myMac:console2 admin$ geth attach ipc:../node2/geth.ipc
Welcome to the Geth JavaScript console!

instance: Geth/v1.7.3-stable/darwin-amd64/go1.9.2
coinbase: 0x3fd97155061e47960b59b563a178fa248493017c
at block: 0 (Wed, 10 Jan 2018 21:36:58 +04)
 datadir: /Users/admin/EtherNet/testnet/node2
 modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

>
> admin.
admin.addPeer              admin.getNodeInfo          admin.nodeInfo             admin.sleepBlocks          admin.toLocaleString
admin.constructor          admin.getPeers             admin.peers                admin.startRPC             admin.toString
admin.datadir              admin.hasOwnProperty       admin.propertyIsEnumerable admin.startWS              admin.valueOf
admin.exportChain          admin.importChain          admin.removePeer           admin.stopRPC
admin.getDatadir           admin.isPrototypeOf        admin.sleep                admin.stopWS
> admin.nodeInfo.
(anonymous): Line 2:1 Unexpected end of input
> admin.nodeInfo.enode
"enode://f48fcf69ba27442ff3813912ec12ea1ad249f14739dabfcadb3985c3654540e047700030adba5800bf33d0adbdd9ca5f1c47aae2498a0d9dafb8c2fd730969b4@[::]:3002"
> net.peerCount
1
>
> net.peerCount
2
> net.peerCount
1
> net.peerCount
2
>
> net.peerCount
3
> net.peerCount
5
>

I've ONLY 2 nodes and node2 is attached to node1. So, there is ONLY ONE PEER for each. But, why does the 'net.peerCount' keep changing, on subsequent execution of the same command?


texts:
I have been trying to use the sendTransaction function to transfer Ether from one account to another:

exampleCode:

web3.eth.sendTransaction(transactionObject [, callback])

source: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction

but the issue I am having is understanding the different parts of the transactionObject. From the github wiki, here is the explanation:

Explanation:

Object - The transaction object to send:

from: String - The address for the sending account. Uses the web3.eth.defaultAccount property, if not specified.

to: String - (optional) The destination address of the message, left undefined for a contract-creation transaction.

value: Number|String|BigNumber - (optional) The value transferred for the transaction in Wei, also the endowment if it's a contract-creation transaction.

gas: Number|String|BigNumber - (optional, default: To-Be-Determined) The amount of gas to use for the transaction (unused gas is refunded).

gasPrice: Number|String|BigNumber - (optional, default: To-Be-Determined) The price of gas for this transaction in wei, defaults to the mean network gas price.

data: String - (optional) Either a byte string containing the associated data of the message, or in the case of a contract-creation transaction, the initialisation code.

nonce: Number - (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
Function - (optional) If you pass a callback the HTTP request is made asynchronous. See this note for details.

so from this explanation, I would assume that something like this would be composed:

transactionObject = {
  from: "0xA0A0A0A01",
  to: "0xA0A0A0A02",
  value: web3.eth.getBalance("0xA0A0A0A01"),
  gas: "----",
  gasPrice: "----",
  data: "----",
  nonce: 0,
}

QUESTIONS/SITUATION:

I'm not sure about any of the values that are under the value value. Should they even be set? I understand that for instance gas is what is used as the currency for transactions over ethereum, but how do I know the maximum I can put the gas to be or the minimum? And what is the default: To-Be-Determined mean?


texts: Could I mine specific transactions that other miners would ignore?

texts:
So let's say I write my own little script to create an ethereum transaction that transfers some amount to another address. I set a really low gas price. Then I sign it using a private key that has enough funds associated to make the transfer. Then I paste the transaction into the mainnet using etherscan.io.

If I understand ethereum well enough, if the gas price is too low, other miners won't (in the current proof of work situation) be motivated to do the work to mine that transaction.

But, if I have a synced node, could I cherry pick that transaction and do the work to mine it? If I were willing to forget about the benefit I gain from mining (the rewards in the form of gas), could I guarantee to some extent that the transaction would make it into the chain?

Is this likely to be expensive in terms of electricity? Is this something that would never make sense unless the transaction rake were significant such that I would make a large amount of money out of getting that transaction through.


texts: Solc Compiler oversight? Innappropriate mapping declaration overwrites storage

texts:
I have written a contract that has the mapping storage variable A & B. These variables get initialized with some values in constructor. A method getBalance returns the balance from mapping A & B.

In the method I declared another mapping - thinking that it would give a compilation error (since mapping allowed for storage only). Instead it lead to a strange behavior - appears that the new local mapping overwrites mappingA.

Result without local mapping (100, 200) as expected
Result with local mapping (500, 200) <<< Why?

/** Tested in Truffle/TestRPC **/

contract Mapping {

  mapping(address => uint)  balancesA;
  mapping(address => uint)  balancesB;

  function Mapping() {
    // constructor
    balancesA[msg.sender] = 100;
    balancesB[msg.sender] = 200;
  }

  function getBalance(address addr) returns(uint, uint) {

    // If these 2 lines are commented then behavior is as expected
    mapping(address => uint)  balancers;
    balancers[msg.sender] = 500;

    return (balancesA[addr], balancesB[addr]);

  }
}


texts: How to create wallet with web3j and web3swift like with web3js web3.eth.accounts.create(); function?

texts:
With web3js v1.0.0 you can create accounts with web3.eth.accounts.create(); and access the public address and private key with newWallet.address and newWallet.privateKey.

How can you do this with web3j or web3Swift.

The documentation is difficult to find this in.

Thanks for any help.


texts: Should we call send function to actually deploy a contract to the network

texts: I am using the web3.js 1.0 version for creating a contract and communicate to the network. On the web3.eth.Contract object, Should we call the send function, after the deploy function resolve to actually deploy a contract to the network.


texts: How to transfer any ERC20 token trough a function with Metamask?

texts:
I'm developing a function that accepts any kind of ERC20 token, and transfer it to the provided address.
The idea is to execute the function connecting Metamask address, and transferring the desired kind of ERC20 tokens to the desired Ethereum address.
It is not exactly a payable function, since it is not only receiving ETHer.
In the examples I have seen, they specify the address contract of the desired ERC20 token, but in this case it could be any ERC20 token.
How could I get the selected token from Metamask, to specify the ERC20 contract address to my Smart Contract?
UPDATE:
I think Uniswap do something like I want to achieve in this contract.
They import IERC20 standard Smart Contract, and use it to initialize any pair of tokens.
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
    require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
    token0 = _token0;
    token1 = _token1;
}

Thanks


texts: How to use array of arrays with mapping in Solidity

texts:
I'm developing a smart contract handling document signing. Mainly, there are two things to consider 1) Signers 2) Sign Types.

1) Signers: Mandatory sign the document
2) Types: Types of signs such as eSign, hardware key, etc.

Currently, data is stored in this way:

Agreement
   |
Sign Types
   |
Signers

Code:

struct Agreement {
    bytes32 id;
    address owner;
    string fileHash;
    address[] signers;
    uint256 timestamp;
    uint256[] types;
    mapping(uint256 => mapping(address => Stamp)) stamps;
}

struct Stamp {
    address signer;
    uint256 blockNumber;
    uint256 timestamp;
}

function createAgreement(
    bytes32 _id,
    address _owner,
    string memory _fileHash,
    address[] memory _listOfSigners,
    uint256[] memory _types
)   public returns (bool success) {

    agreements[_id].id = _id;
    agreements[_id].owner = _owner;
    agreements[_id].fileHash = _fileHash;
    agreements[_id].timestamp = block.timestamp;
    agreements[_id].signers = _listOfSigners;
    agreements[_id].types = _types;

    return true;
}

It was working fine till now, but there are changes of optional signers.

Optional signers can optionally sign the document (consider optional signers always in a group of two or more). Meaning that a single person from the group can sign and the document should be considered as a signed.

To avoid an array of arrays, I have used mappings and structs as follows.

struct Agreement {
    bytes32 id;
    address owner;
    string fileHash;
    address[] signers;
    uint256 timestamp;
    uint256[] types;
    mapping(uint256 => mapping(address => Stamp)) stamps;
    mapping(uint256 => OptionalSignerGroup[]) optSignerGroup;
}

struct OptionalSignerGroup {
     uint256 groupId;
     mapping(uint256 => OptionalSigner[]) signers;
   }

struct OptionalSigner {
    address signer;
}

But, I'm not sure how to add and retrieve data into optional signer groups.

Here is the new flow

          Agreement
             |
           Sign Types
         |         |
Signers(mandatory) Optional Signer groups
                      |
                   Signers


texts: How to see data sent using a smart contract?

texts:
See this transaction:

https://rinkeby.etherscan.io/tx/0xf38b9f1fdb1a6f309bb4671bbcee235c9b75685ac96f99955d59b9a112db1156

Is referred to the creation of this contract:

https://rinkeby.etherscan.io/address/0xc05e3556824a30d9ac2187339c9a60b954b127c1

This is the code

pragma solidity >=0.6.0;

contract test001 {

    int private age;

    function setAge(int _age) public {
        age = _age;
    }

}

I invoice setAge passing 25 as parameter, see the tx

https://rinkeby.etherscan.io/tx/0xbeee3e737020e9ca41e08f26a49f7890e42ccc1f6475637dd01f1682848dd762

My goal: I'd like to be able, saving the txid, to retrieve the data I sent; in this specific case, can I see that use setted 'age' = 25.

The ultimate goal is to save persistent certification data (a little group of integers and short strings) into the blockchain and be able to consult the data sent invoking a contract's function.

I have NOT the need to store all data into the contract, I think, if I am able to consult data sent using a common blockchain explorer link etherscan.io

If is it possible to consult the data I sent, how can I do this?

Probably I totally misunderstood visibility of data on the blockchain. Be patient, I'm new


texts: Why does a multisignature wallet in mist only require one signature?

texts:
I've created one new contract wallet from an account in mist and this account is supposed to required two signatures. When I test it to send some coins, it asks me to enter one password from one account only and doesn't ask me for the other account. Is it normal?

I thought all this was for more secure things?


texts:
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/we                                                                             b3/node_modules/sha3/.node-gyp'
gyp ERR! System Linux 4.15.0-70-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gy                                                                             p/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/web3/node_modules/sha3
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3@1.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional log                                                                             ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/yuching/.npm/_logs/2019-11-27T17_08_23_043Z-debug.log


texts: Is it safe to leave your account in an untrusted computer, as long as it is encrypted?

texts: No modern OS is 100% free of viruses or hacking - and, even if it was, people can always just steal your computer. Assuming you can't be safe nobody will access your machine, is it still safe to keep your accounts in your PC, as long as they are encrypted with a strong enough passphrase? Or will that passphrase be useless in the case somebody gains full access to the backup files?


texts: How can I specify a date picker in one of the fields in my ContractForm React component?

texts:
I'm using the ContractForm React component available in the drizzle-react-component library. It's super nice and easy to setup and use, but I am dealing with a date in one of the fields (which is specified as string in my contract) so the ContractForm gives me the possibility to input a string and not to overload that particular input field with, say, a date picker.

Is there a way to either overload or bypass ContractForm in order to have that field as a date picker, transform the date the way I decided to handle them in Ethereum, and let ContractForm call the function on chain for me?

Thank you!


texts: 1) How can we use Ethereum Alarm Clock for Scheduling a txn in Private network(using geth/ganache)

texts:
2) Can we schedule a txn in such a manner that it could be executed multiple times in a particular time window?(For eg: if we need to schedule the txn everyday 5.00 pm) or the EAC has the option of scheduling the txn only once?

If so pls explain me how to implement EAC in our own smart contract

Thanks in Advance !!


texts: Are there any risks of undefined behavior when calling a function which doesn't return anything using a prototype of it which returns bool?

texts:
According to the ERC-20 Token Standard, functions transfer and transferFrom should return a boolean value indicating success or failure:

interface IERC20Token {
    function transfer(address _to, uint256 _value) public returns (bool);
    function transferFrom(address _from, address _to, uint256 _value) public returns (bool);
}

Nevertheless, there are quite a few ERC-20 Token contracts which were deployed on mainnet without conforming to this requirement, i.e., without returning anything.

Suppose I use this interface in order to call these functions on the address of such contract:

IERC20Token token = IERC20Token(someAddress);
token.transfer(someAccount, someAmount);

And of course, because I'm not sure whether or not it returns a bool, I simply ignore the return-value in my code.

The compiler, however, possibly allocates a slot on the stack for this return-value.

Could this possibly yield any sort of unexpected behavior?

Of course, I can force my code to assume that this function does not return anything, by declaring this interface:

interface INonStandardERC20Token {
    function transfer(address _to, uint256 _value) public;
    function transferFrom(address _from, address _to, uint256 _value) public;
}

And then using it:

INonStandardERC20Token token = INonStandardERC20Token(someAddress);
token.transfer(someAccount, someAmount);

But the thing is, I have no knowledge as to which one of these interfaces is implemented by the ERC-20 Token deployed at someAddress.

So I'm even more worried about unexpected behavior in my second example, since in this case the compiler surely doesn't allocate any slot for the return-value, yet the function can possibly return something.

Any idea which approach of the two given above is safe?

Could the returndatasize instruction possibly be useful here?

Thank you very much!


texts:
I am a newbie and I am a bit confused about the deploying process of the DAPPs, I have some unclear points

Can I access DAPPs outside Mist browser? Can I access them using Chrome for example?
Should all the DAPPs use IPFS protocol?
I saw many tutorials showing DAPPs using IPFS throw HTTP? what is the point of IPFS if I would use HTTP to access it!
If I will be able to access DAPPs throw HTTP, then the serverless concept will be broken, and I am wondering, How can chrome Handel protocols such as Wishper ?


texts: are all bits of a keccak256 'uniformly distributed'?

texts:
If I have a truly random data source, and generate keccak256 hashes of the numbers of this source:

N1 = keccak256(rnd1)
N2 = keccak256(rnd2)
N3 = keccak256(rnd3)
...

are all 256 bits of the resulting hashes uniformly distributed, or are there specific bits for which a 1 is more/less likely than a 0 for example, or which stand in some predictable correclation to specific other bits?


texts: Are the parameters fromBlock and toBlock of getPastEvents() and events.MyEvent() inclusive or exclusive of the block number?

texts: Using Web3, are the parameters fromBlock and toBlock of getPastEvents() and events.MyEvent() inclusive or exclusive of the block number?


texts: Error: Internal or external type is not allowed for public or external functions

texts:
This is the function. I am very new to this. Can someone please tell me what is wrong in this.

function getData(string Key) constant returns (string[], string[]) {

    uint length = data.length;

    string[] memory key = new string[](length);
    string[] memory hash = new string[](length);

    for(uint i=0; i < data.length; i++ ) {
        Data memory currentData;
        currentData = data[i];

        key[i] = currentData.key;
        hash[i] = currentData.hash;
    }

    return (key,hash);
}


texts:
No matter what I set gas price to on EtherDelta.com when I try to make a deposit I get this error

You tried to send an Ethereum transaction but there was an error. Make sure you have enough ETH in your "Wallet" column to pay for the gas fee. If you already have a pending transaction (enter your address on Etherscan to find out), please wait for it to confirm, or increase your "gas price" (in the upper right dropdown) and try again.

I have 1.519 ETH available in my balance and I've tried to deposit as little as 1ETH (0.519 available for fee).

This site says recommended gas price is 47 https://ethgasstation.info/
I don't see how a gas price of 150 and 0.519 ETH aren't enough

Am I missing something?


texts: I'm unable to send ethereum from my Metamask..its showing error as "insufficient fund for gas" despite having 5 ethereums in my account.


texts: How to create an external account ( personal.newAccount()) equivalent in the ethereumj ? I know I could use the jsonrpc api to do so ? But I read https://github.com/ethereum/ethereumj/issues/335 , which says it could create an account, but it could not, it just generates the address, but does not include/add it to the keystore. How can I add this to the keystore.


texts: The secret phrase is used to encrypt a bid, and then to decrypt it. What type of encryption and decryption is used?


texts: What's the point of holding an ENS auction for a name nobody can see?

texts:
Earlier today I decided to register an ENS domain name for my wallet.  As I read through the process on various sites about how it works, I think I understand it but I'm very surprised and confused about one thing:

Why are the domain names hidden until after the auction ends?  And if they are hidden, what is the point of having an auction in the first place?  Who would ever bid on a name without knowing what name they are bidding on??

At first when I read that I had to go through a 5 day auction process, I was disappointed.  You mean I can't just buy a domain if it's not reserved like you do with internet domain names?  But now that I know none of the other bidders will know what they are bidding on, I feel relieved--surely nobody is going to outbid me if they don't have any idea what they're bidding on right?  Or are there really some people out there who just bid on random hashes hoping that it's a good domain name?

Like... hey everyone, I'm having a garage sale and y'all can bid on the items I'm selling... but I won't tell you what items they are until I see all the bids.  Might be a chair, might be an old book or toy, might be a lawn mower--who knows what you'll get but be sure and get your bid in!  Isn't that the same thing?

Yes, I'm aware that in some special cases the domain names are visible.  (So I can see why an auction makes sense in those cases.) But as I understand it, that's not the case for most domain names.  Why have auctions for hidden domain names?

Surely I must be missing something.  While the whole thing seems absurd--all of the descriptions I've read of how it works seem to confirm that this is the way it works, and yet the strangest thing is--nowhere else I've seen has pointed out how absurd it sounds.  So what am I missing here?


texts:
According to this, web3 should contain the function soliditySha3. It can take an object (JSON), serialize it, and use the result as input to Keccak256. According to the documentation, the arguments are ABI converted and tightly packed before being hashed. How do I get this function using Nethereum?

soliditySha3
Will calculate the sha3 of given input parameters in the same way
solidity would. This means arguments will be ABI converted and tightly
packed before being hashed.


texts: In solc 0.4.x assembly, how can I check if a non-constant function returns 'bool' or nothing?

texts:
I know how to do it for a constant function, for example:

pragma solidity 0.4.25;

contract Callee0 {function func() external pure returns (bool) {return false;}}
contract Callee1 {function func() external pure returns (bool) {return true;}}
contract Callee2 {function func() external pure {}}

contract Caller {
    bytes4 private constant FUNC_SELECTOR = bytes4(uint256(keccak256("func()") >> (256 - 4 * 8)));

    function funcReturns(address _callee) external view returns (bool) {
        uint256[1] memory output = [uint256(2)];
        bytes      memory input  = abi.encodeWithSelector(FUNC_SELECTOR);

        assembly {
            let success := staticcall(
                gas,            // gas remaining
                _callee,        // destination address
                add(input, 32), // input buffer (starts after the first 32 bytes in the `input` array)
                mload(input),   // input length (loaded from the first 32 bytes in the `input` array)
                output,         // output buffer
                32              // output length
            )
            if iszero(success) {
                revert(0, 0)
            }
        }

        return output[0] < 2;
    }
}

Here is a Truffle 4.x test to assert this method:

contract("Caller", function(accounts) {
    it("test", async function() {
        const callee0 = await artifacts.require("Callee0").new();
        const callee1 = await artifacts.require("Callee1").new();
        const callee2 = await artifacts.require("Callee2").new();
        const caller  = await artifacts.require("Caller" ).new();
        const callee0_funcReturns = await caller.funcReturns(callee0.address);
        const callee1_funcReturns = await caller.funcReturns(callee1.address);
        const callee2_funcReturns = await caller.funcReturns(callee2.address);
        console.log();
        console.log(`callee0_funcReturns: ${callee0_funcReturns}`);
        console.log(`callee1_funcReturns: ${callee1_funcReturns}`);
        console.log(`callee2_funcReturns: ${callee2_funcReturns}`);
    });
});

The printout of this test is:

callee0_funcReturns: true
callee1_funcReturns: true
callee2_funcReturns: false

Would anybody know how to achieve the same when the function (func in the example above) is non-constant, without ending up having it changing the state of the contract?

Thank you!


texts: I want a to write a function to get user data by giving the id of the user

texts:
pragma solidity ^0.4.23;

contract ChainList  {

  struct  data  {
    uint   ownernumber;
    uint   id;
  }

  uint value;
  mapping (uint256 => data) public  datamatching;

  function storedata (uint _ownernumber, uint _id) public {
    var  persondata  = datamatching[value];
    persondata .ownernumber = _ownernumber;
    persondata. id  =  _id;
  }

  function getData(uint256 userId) returns (uint, uint){
    return (datamatching[userId].ownernumber, datamatching[userId].id);
  }
}

// I have written the function but I tought that when I call the get function it will return all the child varables but it  is not working

truffle(development)> app.storedata(123344,1)
{ tx: '0x1fad231de1e19b004c8004871036a7cf47be06ab4123614130f1b1371371433b',
  receipt:
   { transactionHash: '0x1fad231de1e19b004c8004871036a7cf47be06ab4123614130f1b1371371433b',
     transactionIndex: 0,
     blockHash: '0xbff254564dc0d2e8affc80ca5994a66be5c06377f98ff425783c9b02fd36c75c',
     blockNumber: 20,
     gasUsed: 62379,
     cumulativeGasUsed: 62379,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }
truffle(development)> app.getData(123344)
{ tx: '0x327089e695085696d00c5656db322bce490bc17bf0edaa19f17dad38cdf74377',
  receipt:
   { transactionHash: '0x327089e695085696d00c5656db322bce490bc17bf0edaa19f17dad38cdf74377',
     transactionIndex: 0,
     blockHash: '0x85ccd6ccc26417365681525442b0349ce29a1a46b9de4184ca1f1e3ec4b66fd4',
     blockNumber: 21,
     gasUsed: 22454,
     cumulativeGasUsed: 22454,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }
truffle(development)>
undefined
truffle(development)>
undefined
truffle(development)> app.storedata(123344,3)
{ tx: '0xafb132e70bfb82e1d41227bf41d787faaf6ee9d99c63fa3145752e2178b5a4e6',
  receipt:
   { transactionHash: '0xafb132e70bfb82e1d41227bf41d787faaf6ee9d99c63fa3145752e2178b5a4e6',
     transactionIndex: 0,
     blockHash: '0x61dacd6a0a2d48627b3becc2a815ec7b72a7fe175497ef66964dffdd3bdf2c6f',
     blockNumber: 22,
     gasUsed: 32379,
     cumulativeGasUsed: 32379,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }
truffle(development)> app.getData(123344)
{ tx: '0x63c83f31d384494ed8ad6389c43d2a5745a6e229242c5fb6218386b3387d6409',
  receipt:
   { transactionHash: '0x63c83f31d384494ed8ad6389c43d2a5745a6e229242c5fb6218386b3387d6409',
     transactionIndex: 0,
     blockHash: '0x7c3252574ffcd2f65f207b279d1b7501655e2638ddd52397c8fde93a9be4cb00',
     blockNumber: 23,
     gasUsed: 22454,
     cumulativeGasUsed: 22454,
     contractAddress: null,
     logs: [],
     status: 1 },
  logs: [] }

When I call getData with id  123344  it should return the two values  1 and 3 because I used the same id  to store the both varibles but it is showing a different hash.

I want to getdata to show the hash of the two transactions id's  and the values  1 and 2 when user calls it.


texts:
Simple question but I couldn’t find the answer in the documentation.

How do I declare a fallback function in my contract ?


texts: external function called from another contract

texts:
I heard external functions are a nice performance improvement, when called  from outside the contract.
Can I use an external function when it's called from another contract ( not by ethereum account )? Example

contract One {
    Two two;
    function makeCall() {
         two.someExternalFunction();
    }
}

contract Two {
    function someExternalFunction() external {
       //...
    }
}

it compiles well, but should it be used that way, or may there arise some consequences ?


texts:
I have set automated registration smart contract to register nodes as they are added to a private network. The contract works, however I have run into a problem. When the nodes are set up they have no ether, therefore they cannot send a transaction to the smart contract.

I would like to either:

1) automatically send ether to the nodes when they appear as admin.peers on a master node
or
2) set up a “bank” smart contact which I could fill with ether, which would allow the nodes to request a small amount of ether so they could subsequently send a transaction to the registration smart contract.

Is either approach feasible?

Cheers,
P


texts:
I am considering writing a contract and can see potential problems (cheats) if multiple transactions/calls are allowed per block for the same address.

When I say "transaction/call" I am meaning a function that will modify the blockchain.

I'm not sure if my understanding is correct about how double spending is prevented and what implications it has on the blockchain. I think it limits transactions/calls to one per block per address and thus also prevents the potential situation I am concerned about (two or more function calls in an uncertain order).

Is each address limited to one transaction/call per block?


texts: Solidity 0.6.0 address(this).balance throws error invalid opcode

texts:
Whenever I try to execute a function that uses address(this).balance I get an invalid opcode error. It compiles fine using 0.6.0.

Using truffle debug I get the following error:

Transaction halted with a RUNTIME ERROR.

There was no revert message.  This may be due to an in intentional halting expression, such as assert(), revert(), or require(), or could be due to an unintentional exception such as out-of-gas exceptions.
Please inspect your transaction parameters and contract code to determine the meaning of this error.

I checked the docs but there's no breaking change for using address(this).balance. Am i missing something?

Edit:
I just tested this code in remix and it throws as well:

    pragma solidity 0.6.0;

    contract A {
        uint public total;

        receive() external payable {
            total = address(this).balance;
        }
    }


texts: Which Pattern to follow to create contract?

texts: I have an ad campaign and I want to store data(like campId, number of impressions, start date, end date etc.) of each campaign on blockchain. Also, whenever I will pass campId, I should be able to access data of that particular campaign. I am just wondering should I just create simple contract and create new instance of it for every campaign and save the address of each contract in the relation db or I should use some pattern like Factory or Registry patten?


texts: "Dropped" transaction - is it rejected or will it come back?

texts:
I have a dropped transaction. Now I am wondering: Should I create a new transaction or will that same transaction maybe "go back" into the txpool? So is this transaction now completely cancelled or will it be put in again?

Thanks!


texts: Why is it fine to reference a contract type but not use it to create a new contract?

texts:
I am going through the solidity docs and I have seen, in the code example given that:
// `TokenCreator` is a contract type that is defined below.
// It is fine to reference it as long as it is not used
// to create a new contract

Why can one not create a new contract from the contract type?


texts: How would ethereum personal accounts helpful?

texts:
I have setup ethereum server node and created one test network. started mining, ether is generating in eth.accounts[0]. i have follwoing questions.

How multi accounts(eth.accounts[0], eth.accounts[1],...) will helpful?
if i do any transaction by account, accounts should have ether. So one account is enough for one node.
How make my customer do transaction through my node? should i create each account for them?
if i create each account for my customer, then how can they get ether in their account? should transfer ether from coinbase accounts to other accounts?


texts: web3py: get public key from private key (without prior transaction)

texts:
Is there a way to get the public key from a private key with web3.py? I know I could get it by checking a transaction signed by that key but that's not working for me in this example.

It should be accessible somehow as the address is derived from it. So there must be an internal way within web3.py to access it.

Unfortunately there is no information on it in the docs and all I found was this solution for web3j which isn't portable to web3.py.


texts: How can I get a snapshot of the whole ethereum blockchain?

texts: I'm currently running a geth node (fast mode) on my machine. And I want to know is there any way to get a snapshot of the whole blockchain from geth? Thank you so much if anyone has any suggestions.


texts:
When calling any method on a contract https://testnet.etherscan.io/address/0xabc7a3a72af1f94ff6029ef01bc0f7c49e2ed637 using Browser Solidity https://ethereum.github.io/browser-solidity/ on Ropsten Testnet, the message "Waiting for transaction to be mined..." never quits and transaction doesn't even show at the origin account https://testnet.etherscan.io/address/0xe5f68950d479fab12797dabbe5a4b0d88ec7a722

The contract was deployed yesterday and I could call methods using Metamask with no problems. But today, it isn't working anymore...

People is suffering similar situation at Solidity stuck at mining transaction but in this case I am working with new Ropsten testnet and Metamask.

Any idea how to solve this issue? How can I trace metamask transaction to find out where it gets stuck? Thx!

24 hours later I realize the call transaction have been performed at https://testnet.etherscan.io/tx/0xf087a137e7f4962260da26928d205cabd71eed68fd79f8f35fb1027073f03812

It seems it took a lot of time to mine, but I don't know exactly how much nor the reasons to that delay.


texts: Why do I need to have exact same code to load contract from address in Remix IDE?

texts: I tried to interact with the deployed contract and i don't have its code. so i found out the contract address and tried to load contract from address in Remix IDE! isn't this possible? WHY?


texts: Add Two peer from two different machine into one machine

texts:
I have created three node on three different machines. I have used same genesis file for all three nodes. Here is my screenshots of nodes
Node-1

Similarly, I have set up two more node on two different machine.

I have created accounts on each node and started mining in the first node by miner.start(1). After that, I have added peers such as node-2 and node-3 into node-1 by
"enode://5a5532c24bed8f6317a69dd7525a918b3fe9efb14be3733f33741bdff255bc5090c2b21187d3ff79478e44d3ec8da138e8e25e0c7135909bc3ce6b9c7238e0df@172.16.3.233:30303?discport=0"

"enode://d9bdfd131a5d70e2551dccabe7ff5664b46a9a214dad493e00687cc19a7e94d1cd2b8ae9028dedc9aef578b075d031ab6d86c4579f1dcf5d60a4bb1a29b12942@172.16.3.234:30303?discport=0"

Now,the issue is that when I type admin.peers, it only shows one peer which is node-1. Like this

Sometimes, it shows both the peers and sometimes, admin.peers return empty.Please help me out to understand this.