Hot answers tagged

2

A function selector is the first 4 bytes in the hash of the function's prototype. A function prototype is defined as the function's name and its argument types by order. It allows you, for example, to call a function without knowing its exact return-value type: bytes4 private constant FUNC_SELECTOR = bytes4(keccak256("someFunc(address,uint256)")); ...


2

Think I found the answer actually: Call a smart contract payable function sending erc20 token User/me first needs to call the approve function in the LINK contract then my Remix contract can transfer tokens from msg.sender to itself itself using LINK's transferFrom function.


1

If all of these variables are the same then the cost is the same: contract code (including all contracts which are referenced) contract state used gas price sent transaction(s) In a test network you probably use at least a lower gas price so you lose less Ethers for transaction costs.


1

Maintain every non-integer entity in your code as a pair of numerator and denominator. If the same denominator is used everywhere (for example, 100 in your case), then you can maintain only the numerators (for example, 108383, 825 and 13137 in your case). Whenever you apply an arithmetic computation, try to "postpone" the operation / (or div if you'...


1

how do we register user in smart contract You're struggling to find this description because the task is already done for you, depending on what you mean by the process of "registering". get the userdata when he/she tries to login after register through our website This is full of hidden assumptions and ambiguities. who/what gets the userdata? ...


1

In your code, bonus is a global variable which is incremented by 10 each time the sendMoney method is called, regardless of the function caller. If you want to track the bonus points from specific accounts you should use a mapping structure : Replace uint public bonus; by mapping(address => uint256) public senderToBonus;. In sendMoney replace bonus+=10; ...


1

The easiest way is to select your implementation in the Contract drop down, then put your proxy address in the field At Address and validate. This way remix will load the abi of your implementation and call the proxy.


1

Sure, but the flow is a little counter-intuitive and takes some getting used to. You can send ETH and/or data to a contract function. The data can instruct a contract function to seize a certain amount of a token from someone, usually the msg.sender (but not necessarily). Your contract would use the ERC20, transferFrom(<funder>, <amount>) ...


1

With uint256 amount = 5000000, the type of the expression amount.div(24).div(60).div(60).mul(1) is uint256, and its value is 57. And when you divide uint256(57) by 100, the result is obviously 0. I don't know anything about the type ufixed8x2, but assuming that it handles arithmetic operations correctly, you should cast the intermediate result of 57 to this ...


1

All datetime values are stored as integers in Solidity. The block.timestamp (also known as now but that name will be deprecated in future versions) is the amount of seconds since year 1970: https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=timestamp#block-and-transaction-properties So to calculate the amount of seconds ...


1

Syntactically if you didn't write a constructor for Faucet it has the default non-payable constructor. So for the compiler you can't create and send ether to the contract. constructor() { faucet = (new Faucet).value(0.5 ether)(); } Before solc v0.6.8 there was a bug and the code generated didn't have the check in the constructor so you were able to ...


1

I used the below fallback function and it worked. receive() external payable {} This post was what I was actually looking for in my original question. Everything works well now. How do you send Ether as a function to a contract using Remix?


1

For the same reasons as to why it shouldn't be used after functions. ; is used to end a statement. A statement is usually introducing a variable or assigning a value to a variable. However the { } construct is to express a block. You shouldn't use semicolon ; to end a block.


1

This is a bug in geth that was resolved in v1.9.13. The original issue can be found in Issue #16999 and the fix can be found in PR #20783. The issue was basically that geth was subtracting 0 by (gasLimit * gasPrice), which underflowed and resulted in the large number you saw. In your case, you were probably using the default Remix values of gasPrice = ...


Only top voted, non community-wiki answers of a minimum length are eligible