New answers tagged

0

Okay it seems you are already failing in the deployment part. The transaction you posted: https://kovan.etherscan.io/tx/0xeef83dae54ba0143aa1a654f328496af154775a3877e30af6cc5e8c520688bdc is a failed deployment. The reason it fails is because you are sending 1 Wei along with the deployment. But the constructor is correctly not declared as payable and thus the ...


1

You can use timestamp format in solidity and convert it to and from datetime in javascript client side. For exmaple you can see this page and use these methods to convert timestamp to and from datetime format: https://stackoverflow.com/questions/19485353/


1

All Remix files are stored in your browser's local storage. So there is no file size limitation coming from Remix. If you want to check the storage for lost files, check out this link to learn how to back up or restore local storage files. if you don't find any files there, I'm afraid all of your files are gone. Next time you use remix, make sure you have a ...


1

This: const Web3 = require("web3"); console.log(Web3.utils.asciiToHex("foo")); console.log(Web3.utils.asciiToHex("bar")); Gives: 0x666f6f 0x626172 So I believe that one of the following should work for you: [0x666f6f, 0x626172] ["0x666f6f", "0x626172"] [...


0

If there was a shared code, it could be more convenient to say the issue. but, as you may be aware, before letting the UniswapRouter to do the swap you should "approve" the token like token.approve(_spender, _amount)


0

You can use any of the built-in Solidity time units. For example, you can do: function f(uint start) public { if (block.timestamp >= start + 365 days) { // ... } }


2

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? ...


0

There are two reasons for the error you are getting: The contract's balance is empty. The address you are going to transfer ether is not payable. I speculate that the first reason is much more probable. You need to either transfer some ether to your contract via fallback function or deploy the contract with some ether via msg.value in the remix IDE.


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>) ...


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.


0

I had bad imports: from web3 import Web3, HTTPProvider, IPCProvider, WebsocketProvider from web3.auto import w3 Fixed imports: from web3 import Web3


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'...


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)")); ...


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

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

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 ...


0

Per what goodvibration said in the comments: Within Remix you will get the error Unable to import 'remix_accounts.sol' File Not Found" when you try to compile in the "Solidity Compiler" tab. (This tab is usually the second or third tab down on the left of the remix screen). But if you switch to the "Solidity Unit Testing" tab (the ...


0

selfdestruct method sends all of the contract balance to passed address and with recent solidity breaking changes all addresses that are receiving ETH must include the keyword payable. Example: address payable public contractOwner;


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?


0

After deploying the ERC-20, your address receives the total supply of the token, as you can see here : constructor( uint256 _totalSupply) public{ totalSupply_ = _totalSupply; balances[msg.sender] = totalSupply_; } _totalSupply is a constructor parameter so you have to fulfill the corresponding section in Remix. Be aware of the decimal system of ...


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.


0

Testing a software, or a smart contract, it's the same, is a bit more than making you sure that you have no bugs. You should read a few articles about why testing software. A non exhaustive liste of reasons is: no having to test manually each time you make a change on your code prevention regression explain what the code does and what to expect give ...


0

To begin with, given: address public daiAddress = 0x6b175474e89094c44da98b954eedeac495271d0f; address public kyberAddress = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755; You should probably change this: KyberNetworkProxyInterface KNPI = KyberNetworkProxyInterface(daiAddress); To this: KyberNetworkProxyInterface KNPI = KyberNetworkProxyInterface(kyberAddress);...


Top 50 recent answers are included