New answers tagged

0

I assume you're getting error from your third function. Before calling it (TransferTokens) you need to call ERC20.approve() from the caller's address. Your second function here doesn't help the third function. your second function is basically just approving another address to use its ERC20 balance, which doesn't make much sense, cuz the the contract itself ...


0

Is it a contract that has functions that require a fee in token to get executed? if yes and the contract is deployed, send an amount the token to the contract address. This should solve your issue.


0

Same problem with me selected the wrong CONTRACT file, Select the contract file from dropdown and it will deployed


0

Looking at your contract, I see you have an issue in your Get_data function. Dynamic arrays cannot be stored in memory and must be stored in Storage. Storage variable cannot be defined within function so in your case you may opt for fixed-sized arrays, which can be stored in memory (but does not push array.push() method). This should fix your variable ...


1

In Contracts folder in Remix, make a new file (By clicking on Contracts folder and then clicking on folders above paper shaped icon). Copy your contract and paste it in the file you made. Compile the contract. Change network of Metamask into Rinkeby. In deployment page, instead of JavaScript VM (London) use Injected Web3. If it does not work, unlock Metamask ...


0

Check your remix url : https://remix.ethereum.org instead of http://remix.ethereum.org


0

What most mix is development and develop. When you set params in truffle.js for development you are setting for truffle console, when you set it for develop you are setting it for truffle develop so you should add this to your truffle.js and blocklimit will be fine. develop: { host: "localhost", port: 7546, gas: 50000000, gasLimit: 8000000, ...


0

Before calling the swapExactInputSingle of your contract you have to approve the contract to take the wETH from your account to the smart contract. Like so (brownie test example): weth_contract.approve( <YOUR_CONTRACT_ADDRESS>, sell_amount, {"from": accounts[0]}, ) This is what the // msg.sender must approve this contract line means....


1

Its not straight forward but here is an example from uniswap: uniswap createpair function It boils down to using the evm create2 opcode: create2


0

check out https://www.gemini.com/blog/exploring-the-nft-royalty-standard-eip-2981 for an article. They are using the openzepplin contracts vs. 0xcert the solidity code is on https://github.com/dievardump/EIP2981-implementation This is rough but I threw it together and did a couple transactions in Remix and it seemed to work - I'm still a beginner with this ...


1

Deploying contracts on Optimistic Ethereum is still in the whitelist stage, not for the public.


0

pragma solidity ^0.4.17; contract TugOfWar { int public score = 0; int constant endAt = 1 ether; bool public gameOver = false; **event ScoreChanged (int amount, bool direction); event GameEnded(bool gameOver);** function up() external payable { require(msg.value > 0); require(!gameOver); int value = int(msg.value); score += value; **...


0

// SPDX-License-Identifier: MIT pragma solidity 0.8.0; contract NFT { uint256 public fauouRiteNum; mapping(address => address) private wallet; function setNumber(uint256 _fav) public returns(uint256) { return fauouRiteNum=_fav; } function marketing(address _add) public { wallet[msg.sender] = _add; } ...


1

At the time of deployment of your contract in Remix, you get a drop-down option where you need to pass all the values defined in the constructor. This will be a predefined value for your contract. constructor(string memory _description, uint _value, uint _built_year) public{ private_car.description = _description; private_car.value = _value; ...


1

If you're using an injected web3 tool like metamask once its connected select the Account dropdown below the environment and swap between them


0

In my case, I had to switch from solc version 0.8.7 to 0.8.0 and it works.


0

The constructor should not have visibility attribute. So just remove the public keyword. Furthermore, you have marked your owner variable to be payable. Therefore you have to be sure that the msg.sender is of payable type. You can just cast it with payable(msg.sender) and get rid of the error, but that won't solve the issue that somehow you need to make sure ...


0

I ran into this error after updating my version of the solc compiler. The solution was to empty my build/ directory and re-compile my contracts.


0

When I deploy the contract I get it on the left side down. it called ‘low level interaction’ and depends on the input there the receiver or fallback function is called. My contract don’t have them therefore i get the red hint. And as I said your fallback function will not work because of the gas limit of that function, u need to find another way to do that. ...


1

Best Approach Deploy with any method you want (even a MNEMONIC stored in a .env file) then immediately transfer the ownership of the contracts to a Gnosis Safe multisig controlled by multiple signers. If you're using OpenZeppelin's Ownable.sol, you do this via transferOwnership. 2nd Best Approach Use a hardhat wallet like Ledger or Trezor, load your ...


0

I've find out where the problem is. when I input the input_material in ABI. I enter it in decimal form, but it seems like the decimal isn't supported. When I enter it in integer form, it worked.


1

Simply make new account on metamask. Whenever you change your account, Remix updates account and switches to account. Then from faucet receive testnet's coin or send from your first account


0

For the first one, I think it's because my local Hardhat Network is not forking mainnet correctly because of a configuration error, putting the network block outside of module.exports, leaving the contract in its own blockchain without any other contract. Once I confirmed it was forking mainnet by the warning that says Hardhat Network would be in decreased ...


1

It depends on how Ownership is implemented in these contract. If using OpenZeppelin Ownable approach then this would not work. There, ownership is stored as a single address (which for contract A would be contract B's address) and then restricted functions check to ensure the caller's address is equal to the owner's address, otherwise revert. Thus, if ...


0

You can add a function to B for calling C and transferownershipping. But be careful, you have to use msg.sender for checking the message owner instead of tx.origin


0

For the first problem, Which testnet are you using?! For the second problem, you declared a function named getReserves() which takes 3 parameters. No problem here but in the function you are calling getReserves() again and it makes a cycle forever (however you should give it parameters).


0

No, that's just a linear counter that disregards the EVM rule that push instructions increase the program counter (PC) by at least 2 (as compared to all others opcodes, which increase the PC by 1). The program counter is to be found on the column on the left-hand side, next to the opcodes:


0

It's better to UNCHECK the Generate contract metadata. from the setting as @Akrramo mentioned otherwise if you UNCHECK the Auto compile then you have to compile the code every time you do some modifications.


1

It is a typo in your code: numberslist.length


0

Yes, just add the suffix "ether". Fore example: msg.value - 1 ether I suggest using the SafeMath library when using maths though. https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol


0

let contract = new web3.eth.Contract(userABI); const bytecodeWithEncodedParameters = contract .deploy({ data: userByteCode, arguments: [first_name, last_name, user_name], }) .encodeABI(); const gasLimit = await web3.eth.estimateGas({ data: bytecodeWithEncodedParameters, }); Try like this for new contract deployment. It works ...


2

check this line " buildChainlinkRequest(jobId, address(this), this.fulfill.selector);" there is a typo instead of "jobID".


0

Solidity doesn't read external files. if you want to add a list of voters provide them using arrays. For example : function addVotersList(string[] calldata _names,uint[] calldata _ids , address[] calldata _voters)public { for (uint i = 0; i < _names.length; i++) { ...


0

You can't send a file to the function. But if you want to get done all of the process with one click, you can use arrays. function addVotersList(string[] calldata name,uint[] calldata id , address[] calldata voter) external I changed function visibility. Because if you are getting arrays in your paramaters, external very much gas saver. And I added calldata ...


0

It is important to note that 'Ether' is not a separate variable type. The suffix 'Ether' is just a convenience utility that coverts values in wei to the desired denomination. In your case, prices should be denominated in wei and stored as uint256 variables. On your front-end you can then convert wei price into ether price (1 ether == 1e18 wei). Thus, in your ...


1

EDIT: I believe I misunderstood your question; this is probably a better response: What does the "gas" readout in Remix refer to? The gas line is referred to the total maximum amount of gas provided with the transaction (you are including 80... gas to be used) the execution is how much gas is effectively used of the amount provided; so in your ...


1

Both of the current answers are excessive function random() private view returns(uint){ uint source = block.difficulty + now; return uint(keccak256(bytes32(source))); } Also you should not be using block.difficulty or block.timestamp as a source of randomness as they are exploitable by miners. Consider using Chainlink's VRF instead


0

I strongly recommend against inputting in ETH. You lose the value of having decimals and run the risk of a user inputting wei and having their price 10^18 times higher than they should. You should accept input as wei and your frontend should perform the conversion from ETH to wei


0

You have to give what constructor needs on deploy. For example if constructor wants 2 uint variables then you have to give them on deploying.


1

when you are calling setMessage function you should use send instead of call $("#setMessageButton").click(function () { var val = $("#userInput").val(); RemixContract.methods.setMessage(val) .send() .then(function(result){ console.log(result) }) }); Hope this helps


1

In line 91 you are calling a modifier which is not declared! function setSpaceAvailability(uint8 _space, bool _newAvailability) lessorOnly public {...} Declare a modifier named lesserOnly


0

Well, there are 2 simpile ways: Create a receive function in the newETH Contract to accept ether from outside. And to forward it to the owner, just transfer those ethers directly to the owner or via a function it's upto one's preference. Here, is the implementation of the same. I've also included some additional functions play with them and the concept will ...


0

Between the two answers above I was able adapt to solve the problem. Below is one solution for a "pure" string array deduper function. Without being able to use mappings and dynamic arrays there's a lot of iterating arrays necessary, but if it's used for display purposes, rather than updating in state, it won't incur gas costs. function ...


0

You have an extra } before the getters } } } // <<<<<------ Move to the end // *************** // GETTERS // *************** // This getter tells us if a space is available or not function


1

Using a hardware wallet was causing the problem here. I created the contract using a regular metamask wallet.


1

I think I found the issue. The problem here is mainly with declaring your dynamic array in memory rather than storage. As it will be a storage array then it should be declared outside your function. Secondly, your second iteration should consider deduped.length since this is the array your are iterating over for(uint j=0; j<keys.length; j++) Lastly, for ...


0

The problem is that you are mapping an address to a single Player struct that hold a single bet struct Player { // <--- A better name would be Bet uint256 amountBet; uint16 matchSelected; uint16 resultSelected; } mapping(address => Player) public playerInfo; You could use a Player array to store multiple bets. mapping(address => ...


0

Remix (and most web3 providers such as metamask) simulate the transaction beforehand ( this is useful, it allows to estimate the gas spent for example) so if they find out that the transaction will revert, they will warn the user about it. Something you could do is get rid of the revert statement. Like this for exemple function approve(address spender, uint ...


0

Web3 allows this: const MyContract = artifacts.require('MyContract'); ... const gas = await MyContract.new.estimateGas(arg1, arg2, arg3);


0

Add this code to top of your contract: contract Context { // Empty internal constructor, to prevent people from mistakenly deploying // an instance of this contract, which should be used via inheritance. constructor() internal {} function _msgSender() internal view returns (address payable) { return msg.sender; } function _msgData() internal view ...


Top 50 recent answers are included