New answers tagged

0

You're overlooking the mining step. Contract deployment is the result of a transaction, but first a transaction has to mine. In the interim, the first response from sending a transaction, which new DepositPaying(address(this)) does, is a transaction hash. That response doesn't indicate that the transaction is processed. Only that it was sent and assigned a ...


1

Why do you need two nodes ? Are two different accounts, one for the "initiator" and the other for the "executor", not sufficiant ? Nodes validate transactions, they don't play a business role in your smart contract. To answer your question, if you want several nodes you have to build your own private blockchain using clients such as Geth ...


1

If you want to change parameters of the eth network, you can run ganache locally on your computer. This is an Ethereum simulator where you can change the parameters of the network. For example - this starts a simulate network with a higher gas limit (aka setting the blocksize larger) ganache-cli -l 0xFFFFFFFF Note when you run this command an output will be ...


1

You can simply pass the inputs to function B: function A (uint256 foo, uint256 bar) public { B(foo, bar); } function B (uint256 foo, uint256 bar) internal { // do something with foo, bar }


0

The parameters are not wrong, there's no error during deployment and the compiler is acting as expected. In Solidity, when you declare a variable as public, you are telling the compiler to create a public function with the same name of the variable, so that you can query the value of the variable from outside the smart contract. In your case, you are ...


0

You are executing uint256 r = getRental().depositAmount outside a function, although it compiles it doesn't seems to do what you are expecting. It seems you want to execute it inside requestDepositPaying function. function requestDepositPaying(uint256 _rq_depositAmount) public { uint256 r = getRental().depositAmount; require(_rq_depositAmount == r); }...


1

Payment memory payment = Payment(msg.value, now);//this stores ^ The comment //this stores is incorrect. This line just creates an instance of the payment struct and does not save it. memory variables are temporary variables that exist only inside the calling function (they cannot be declared outside of one). They get wiped after the function exits... ...


0

You can find more information in the Solidity official documentation, but it's important to note that: Tuples are not proper types in Solidity, they can only be used to form syntactic groupings of expressions. For this reason, in your case you should be able to read the standardDepositAmount variable without doing anything more, because it is already ...


2

Transaction status: Fail with error 'ERC20: transfer amount exceeds allowance' function stake1(uint256 _amount) public { ERC20TokenInterface token = ERC20TokenInterface(tokenAddress); token.transferFrom(msg.sender,address(this),_amount); } In order for this function to work, you first need to approve for contract transfer tokens behalf of owner (msg....


0

Reacting to https://ethereum.stackexchange.com/users/12743/adheep-mohamed-abdul-kader You should not use: Contract.GAS_LIMIT since it is deprecated: public abstract class Contract extends ManagedTransaction { // https://www.reddit.com/r/ethereum/comments/5g8ia6/attention_miners_we_recommend_raising_gas_limit/ /** * @deprecated ... * @see ...


0

There is no other way to get the current timestamp. now is an alias for block.timestamp and yes, it can be influenced by miners (a bit). But that is the best there is. Most of the time there is no reason for the miners to influence the timestamp. In some rare cases, when the possible reward is big enough, they might be incentivized to influence it. Such case ...


0

With respect to the ".value(...)" is deprecated. Use "{value: ...}" warning: You can use the following pattern to remove the warning: (bool success, ) = recipient.call{value:amt}(""); require(success, "Transfer failed."); I've not found this in the wild yet and can't seem to find it in the docs, so be warned!


0

If you are using Remix and MetaMask (ass your tags imply), then it should be calculated for you automatically (they use the eth_estimateGas RPC call under the hood). If that is the case, you should not manually enter a gasLimit of 500,000 and instead use their estimated gas. As a note, any gas that is unused in the transaction is returned to you. For example,...


0

pragma solidity >=0.4.21 <0.7.0; contract Election { // Model a candidate struct Candidate{ uint id; string name; uint voteCount; } // Store candidate //Read/write Candidates mapping(uint => Candidate) public candidates; // Store Cnadidates Count uint public candidatesCount; constructor (...


0

Use remix to debug your code. Here's the corrected code. pragma solidity >=0.5.0 <0.6.0 ; contract TodoList { uint public taskCount = 0; struct Task { uint id; string content; bool completed; } mapping(uint => Task) public tasks; event TaskCreated(uint id,string content,bool completed); event TaskToggled(uint id,bool completed); ...


1

As Ismael has mentioned, the solution is to when the meta mask window is poped up for your confiramtion of transaction, we can edit(increase) the gas limit there to get our expected result.


Top 50 recent answers are included