Most Popular

1500 questions
18
votes
2 answers

Call contract and send value from Solidity

I have a pre-deployed contractA with known ABI. I would like to call function func1(string,string) in the contractA (and pass the arguments) from a new contractB and send some value at the same time. So far, I managed to write the following (which…
k-zar
  • 442
  • 1
  • 4
  • 8
18
votes
7 answers

Undefined results for "web3.eth.accounts" in truffle console

truffle(development)> web3.eth.accounts[0] gives output as "undefined" truffle(development)> web3.eth.accounts instead of showing all accounts details gives the below output Accounts { currentProvider:…
Yash Shukla
  • 375
  • 1
  • 4
  • 11
18
votes
1 answer

Can a contract with no payable function have ether?

The question in the title says it all. To the best of my understanding, the only way to deposit ether into a contract is by calling a payable function, and set msg.value larger than 0 (and of course, the function should complete successfully without…
goodvibration
  • 26,003
  • 5
  • 46
  • 86
18
votes
3 answers

How to get values returned by non constant transaction functions?

As per my understanding when I invoke a constant function without a transaction in a contract and if the function returns some result I am able to get it in EthereumJ or Go-Ethereum, But when a transaction is performed on a function it is returning…
madhan siva
  • 581
  • 1
  • 4
  • 8
18
votes
1 answer

Member function "transfer" not found or not visible after argument-dependent lookup in contract?

I am having a problem with my smart contract making value transfers. My current environment: Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2) Solidity v0.5.0 (solc-js) Node v8.11.1 I created the following test function to help track down the…
Robert Oschler
  • 841
  • 1
  • 9
  • 20
18
votes
2 answers

How would a miner cope with a huge block time?

Given that: According to the white and yellow paper a block's timestamp must be bigger than the parent's. According to the white paper a block's timestamp can be within 15 min of the parent blocktime. Would that imply that if a differential…
Roland Kofler
  • 11,638
  • 3
  • 44
  • 83
18
votes
1 answer

What happens if transaction runs out of gas before transaction completes?

As gas cost can only be estimated until the transaction is executed against the actual contract state at the time of execution on the blockchain, what happens if transaction runs out of gas before the transaction is completed? Presumably the…
zanzu
  • 5,360
  • 4
  • 25
  • 43
18
votes
3 answers

How to do Solidity percentage calculation?

I'm trying to calculate a percentage of a number in solidity with the following code. The percentage is technically basis points (10000ths, instead of 100ths) because I want decimal percentage values. uint128 is enough for expressing the normal…
Svante
  • 450
  • 1
  • 3
  • 10
18
votes
1 answer

How does Casper solve the "Nothing at Stake" issue?

One of the criticisms of proof of stake is that stakers can vote for multiple blockchain forks with only a trivial cost. I believe NXT solves this by not giving out a mining reward, so that the reduced security of voting for multiple blockchain tips…
Murch
  • 257
  • 4
  • 18
18
votes
6 answers

How to retrieve revert() reason for past transactions?

I run a geth/parity node for broadcasting user's transactions to Ethereum blockchain. Some of contract functions provide reasons for revert (see example below): contract Example { function test (uint i) { require(i == 1, "ERROR_CODE") …
user3184743
  • 371
  • 1
  • 2
  • 8
18
votes
4 answers

Delete all elements from an array?

I am writing a smart contract to be the backend of a game. Instead of using a mapping, I have decided to use an array to store the addresses of accounts who have paid my contract. (I know it is common practice to use a mapping for this but I find…
Bryan Campbell
  • 421
  • 2
  • 5
  • 10
18
votes
2 answers

Truffle: how to get balance of any address or contract's address

For example I have a testing block like this: contract('CreeptomaPresale', function(accounts) { describe("adopted over allow quantity", function () { it("test get balance", async function () { let instance = await…
hqt
  • 449
  • 1
  • 3
  • 12
18
votes
5 answers

What is a blockchain? What is the concept behind it?

I have been going through some docs, and I understand that BlockChains are mostly like the building blocks in an Ethereum network. So, can someone give a dumbed down explanation/definition about what it is, for a starter?
Dawny33
  • 2,007
  • 2
  • 16
  • 27
18
votes
3 answers

How to send ether to a contract in truffle test?

For some reason I cant figure out how to send ether to a contract when testing in truffle. This is my attempt: await myContract.send(10, {from: accounts[0]}); the error message is: Error: VM Exception while processing transaction: revert I get…
mak
  • 193
  • 1
  • 1
  • 4
18
votes
3 answers

Contract address.transfer method gas cost

Who will pay the gas in the following scenario? Lets say we have the following simple function. That sends an amount from the contract back to the sender.. just an example. function withdraw() public payable { address member =…
Cody Popham
  • 245
  • 1
  • 2
  • 10