Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

1

For your question no. 1: Search for "type": "constructor" in your ABI. From this object, you can see the inputs that has an array of parameters along with their name and type. Example: { "inputs": [ { "internalType": "uint256", "name": "_ff", "type": "uint256" }, { "internalType": "string", "...


2

Here is an example from What is an ABI and why is it needed to interact with contracts? contract Foo { function baz(uint32 x, bool y) returns (bool r) { r = x > 32 || y; } } If we wanted to call baz with the parameters 69 and true, we would pass 68 bytes in total, which can be broken down into: 0xcdcd77c0: the Method ID. This is derived as the ...


1

I'm not the strongest player in this dialect, but this looks familier: await instance.purchaseTokens.call('12'); Try adding transaction arguments (gas, gasPrice, value) like this: await instance.purchaseTokens.call({value: <amount>}); call is probably wrong, so: `await instance.purchaseTokens({value: }); Hope it helps. p.s. If there are ...


1

You should not think of Ethereum transactions in the same sense as regular messaging / transactions / background runs in the "traditional" world. Information like exact timestamps is really irrelevant in Ethereum. A miner picks up transactions for his block and the miner decides in which order the transactions will be executed inside the block. All that ...


0

by making payable to my state variable and payable setTotalSupply will resolved this issue


0

The result of the contract call will be available only inside the init function. In order to make it available to other functions, you can return the result. const contractAddress1 = '0xc1847e91e386e11e4df447b3e333f1b18abd1aca' const contractABI = [{"constant":true,"inputs":[],"................]; var contract1 = new web3.eth.Contract(contractABI, ...


0

This is more of a javascript question rather than related to ethereum. The reason why your variable ot hasn't changed is because method contract1.methods.getTotalSupply() needs some time to query the blockchain for the result. This works on the same principle like Ajax request. What you could do is use async/ await or just place the variable inside the query ...


0

You are printing ot before call result was stored to it. Try this code: var ot="raw"; contract1.methods.getTotalSupply().call().then(function(result){ console.log(result) ot = result; console.log("ot : ", ot); }); Explanation: You are calling contract asynchronously, which means that result is not available immediately, but rather after some time. ...


1

No, the bytecode of a contract is generated by a compiler when your contract is compiled, not when it is deployed. When a contract is deployed, its address is deterministically computed based on the address of the creator. See this question for how contract addresses are computed.


0

As you can't hide information in the blockchain you have to use other means. If you are familiar with how the mining process works we can use the same logic here. The whole point of the mining (mathematically speaking) is that the actual mining is hard but verifying the results is trivial. So once a miner successfully mines a block he publishes the nonce ...


1

You were close with your final attempt, you just need to call the call() method as well. The proper syntax is: contract.functions.say().call() See the related web3.py documentation for more information.


0

Here is an example using Brownie that should help: import time from brownie import Contract, network, web3 abi = {} # contract ABI as a dict address = "0x00" # contract address as a string network.connect('mainnet') my_contract = Contract("MyContractName", address, abi=abi) height = web3.eth.blockNumber while True: result = my_contract....


0

These answers are good but I noticed they are a little on the old side and there is a way to send a transaction even when they have no ether. They just need a little help: https://medium.com/@andreafspeziale/understanding-ethereum-meta-transaction-d0d632da4eb2 It's tricky, but it doesn't depend on a protocol upgrade. A grossly summarized process works ...


Top 50 recent answers are included