New answers tagged

-1 votes

1inch swap function smart contract

use 'wmatic' address instead of 'matic'
user avatar
0 votes

How to get all array keys from solidity mapping?

Short answer, you can't get all mapping keys, but what you can do is create an array to store that information like this: contract AContract { // Array with all info ids, used for enumeration ...
user avatar
  • 1,164
0 votes
Accepted

How get hash for user transaction?

Probably what you want is to monitor pending transactions? If that's the case, you need to connect to a node via websocket and subscribe to the "PendingTransactions". Something like this: ...
user avatar
  • 306
0 votes

What are the most widely used open source DAO frameworks?

On top of the excellent list Mikko Ohtamaa already shared, I would add the following: Sablier enables money-streaming, which is ideal for salaries/vesting/grants Tally is an on-chain alternative to ...
user avatar
0 votes

How to show all ERC721 tokens in my page, like opensea or rarible?

In order to know what tokens an address owns, the only way is to keep track of all transactions of an address and keeping track of records. However, there are 3rd party services that provides that ...
user avatar
-1 votes

Transfer Balance in wei not i

This is the error I get with new code : Gas Estimation failed : Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? ...
user avatar
1 vote
Accepted

Returned value solidity

You need to let the Ethereum know that you're just returning a value and you're not modifying the state, which does not require a transaction. To do this, mark your function as a pure function: ...
user avatar
0 votes

Hardhat get deployed contract

import { ethers } from "hardhat" async function main() { const [deployer] = await ethers.getSigners() const Token = await ethers.getContractFactory("Token") const ...
user avatar
  • 342
0 votes

Example for type bytes32 in Solidity

If the tool in the link above is not working, one way to do this is to add this function to Remix pragma solidity 0.8.15; contract StringToBytesConverter { function stringToBytes(string calldata ...
user avatar
0 votes

Explain a decompiled smart contract

It seems to be calling a UniswapV2 pair getReserves() function. With a link to the contract it would be easier to decode this.
user avatar
  • 2,435
0 votes

How to return mapping type in solidity?

give that: mapping(uint256 => address) public tokenIdAndOwner; Because tokenIdAndOwner is public, a "getter()" is created for it. So, it can be retrieved as a function call. However, the ...
user avatar
0 votes

How to call a function that returns an array by implementing composability

This error happen because you declared two structs with the same name, in this case: Person. Thus, in sfGetPerson() method you must declare inside returns keyword the contract name and its relative ...
user avatar
  • 1,503
0 votes

How to construct deployable bytecode from runtime bytecode?

Using modern web3.js const bytecode = await web3.eth.getCode(contract) const creationCode = new web3.eth.Contract([]).deploy({ data: bytecode })._deployData
user avatar
0 votes

why i'm Showing this error when i fetch Market items?

The errors are due to the missing parentheses on _tokenIds.current vs. _tokenIds.current()
user avatar
  • 358
0 votes

Is there a way to identify if an address is erc721 or erc1155?

According to the IEP-165 you can, I had a similar issue/question this article helped me. Solidity get interface id and ERC165 by Nhan Cao Hope this helps you out as well!
user avatar
0 votes

How to implement a counter (variable that is updated every time the contract is called) in Solidity?

If the desired behaviour is that your contract stores an internal counter and anytime that the function show is called you retrieve the value of that counter and increment it by one afterwards, then ...
user avatar
  • 189
2 votes
Accepted

super keyword usage

Just expanding on what @Kof said. This doesn't accomplish anything. function _mint(address to, uint256 amount) internal override(ERC20, ERC20Votes) { super._mint(to, ...
user avatar
  • 51.2k
0 votes

What are the most widely used open source DAO frameworks?

Not in a particular order Snapshop is a popular tool for governance voting Aragon is an old project that provides tools for DAO governance Gnosis Safe is a multi-signature wallet, not a governance ...
user avatar
1 vote
Accepted

Contract via proxy missing functions

If you were to call the implementation functions interacting directly with the implementation contract, your functions will be run in a different context reading/writing to the storage of the ...
user avatar
  • 358
0 votes

In Solidity, what are the differences in purpose between overriding isApprovedForAll() and enabling meta-transactions?

OpenSea gave me this answer to the question: As a quick disclaimer, I am not a developer, but I can hopefully help to clarify a bit more on this. Generally, the 'isApprovedForAll' refers to Token ...
user avatar
0 votes

What is the correct way to implement meta-transactions for OpenSea using Polygon?

OpenSea gave me this answer to the question: I've checked in with our developers and they've let me know both examples you've provided should work; the code detailed in our developer docs was written ...
user avatar
1 vote
Accepted

Governor: proposal not successful

take a look at the following diagram: In order to be able to enqueue a proposal you should previously cast votes, met the required quorum (proposal in state ProposalState.Succeeded) And after the ...
user avatar
1 vote

How can I get the price of NFT on Opensea using chainlink?

As I understand it you are attempting to return the price of an NFT using price feeds. priceFeed = AggregatorV3Interface(0x495f947276749Ce646f68AC8c248420045cb7b5e); This interface needs to use the ...
user avatar
0 votes

super keyword usage

OZ's methods starting with _ are internal both for a clear distinction against external methods. The _mint doesn't make role checks, etc. it just mints, so it must not be public/external. You don't ...
user avatar
  • 2,435
1 vote

How to get the last element of an array in solidity?

You can use the array length for retrieve its last index. Then you subtract 1 to this value because array starts from 0. At this point, you must do a query inside array using last index (retrieved ...
user avatar
  • 1,503
0 votes
Accepted

Fakes on OpenSea

Verify the collection. You can't stop anyone from creating clones
user avatar
  • 104
0 votes

How to define a constant `bytes32` in Solidity v0.8 and above?

You just have to cast the constant values to uint256, like this: bytes32 internal constant FOO = bytes32(uint256(0x01)); Note that you can also optionally ditch the hexadecimal prefix: bytes32 ...
user avatar
0 votes

Can We Transfer Token to The HighestBidder Automatically in NFT- MARKETPLACE Contract? i want this auto

Smart contracts can never execute by themselves. Some entity always has to call them and pay for the gas fees. That entity can either be a user of your marketplace or some backend service of yours. ...
user avatar
0 votes
Accepted

Transfer contract ownership from one contract to another

You can create a function in your Factory.sol contract which transfers the ownership of the said project. Since you are the owner of the Factory.sol contract, you can easily do that. Although you ...
user avatar
1 vote
Accepted

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2)

Check to see if the keys in the networkConfig object in the helper-hardhat-config.js file match the argument array you set up in 01-deploy-raffle.js. const args = [ vrfCoordinatorV2Adress, ...
user avatar
0 votes

Error: Transaction reverted: function call to a non-contract account when adding liquidity through UniswapV2Router

There is an issue with createPair UniswapV2Library function. If UniswapV2Pair ischanged, it will return different pair address, different hex First solution: The purpose of this function is to get the ...
user avatar
  • 1
0 votes

Solidity - Is it possible to sort an Array of Structs? - UnimplementedFeatureError

Inspired to this answer. Сustomize a next sample: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Sort { uint public total = 5; mapping(uint => Item) private itemIdToItem; ...
user avatar
  • 101
0 votes

Calling mint function from UI causes Error minting character Error: cannot estimate gas

Seems that I was referring to the wrong contract. Code above is good to go for calls to a smart contract method.
user avatar
  • 1
0 votes
Accepted

How IncreaseAllowance and DecreaseAllowance function solve mitgation problem?

If you follow the links you'll end up to the description of the vulnerability: https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/edit . Basically an attacker (the one who ...
user avatar
0 votes

How IncreaseAllowance and DecreaseAllowance function solve mitgation problem?

In mitigation problem , If suppose Alice allows Bob to transfer N ERC20 tokens , initially and then changes want to change it to M. Then Bob can transfer N+ M Tokens , but using increaseAllowance or ...
user avatar
  • 21
1 vote
Accepted

How does Chainlink deal with faulty/malicious nodes?

All oracle networks don't necessarily take the same approach, however as the most used oracle network with a high focus on security and reliability, Chainlink specifically looks for outlier results ('...
user avatar
1 vote

Verify that a method call is initiated from a specific Smart Contract

Simplest way of doing it would be to create an address variable inside the Create contract, store the address of the Core contract in constructor and inside the Add function, add a check like require(...
user avatar
0 votes

What is the difference between:= and : in Solidity?

The = is the assignment operator in solidity. In assembly := is also the assignment operator. You cannot interchange them, := is invalid in solidity and = is invalid in assembly.
user avatar
  • 29.1k
1 vote
Accepted

Why does Web3j listen to events every 15 seconds?

On ethereum mainnet a block is generated each 15 seconds. that is why 15 is the default value for events. however you can change this by using this build method: /** * Construct a new Web3j ...
user avatar
  • 2,466
0 votes

execution reverted: "ERC20: insufficient allowance" on transfer method (not transferFrom)

Have you checked balanceOf() with address of smart contract? Does it show any balance? Also, I don't understand why are you writing IERC20 token = IERC20(tokenAddress); You have already ...
user avatar
0 votes

Call to contract doesn't work when sending a merkle proof (using ethers & JS)

Fixed it: By taking out the comma in the end of the ethers.utils.parseEther((0.01 * mintAmount).toString()),}); That last comma, now it looks like this: const response = await contract.mint(...
user avatar
  • 1
0 votes

Ethers.js filters events (Only new events)

get the startblock number from provider const startBlockNumber = await provider.getBlockNumber(); then check that with the blocknumber recieved from event. Full code: const startBlockNumber = await ...
user avatar
0 votes

What is the purpose of giving name to return variables in function declaration?

i benefited from this feature whenever i called functions from an external client such as web3 or ethers, the returned object has named properties, instead of iterating over the object properties to ...
user avatar
  • 15
0 votes

'web3' is not defined no-undef even after importing

I had the same problem trying to connect my website to metamask. If thats your case too, check this out -> How To Connect Web3 With MetaMask? PS you should edit the code after 'load', and add async
user avatar
0 votes

Uncaught TypeError: Cannot read properties of undefined (reading 'getInfo') at index2.js:20:20

The contract property you are refering to does not exists. But Contract does (capital c). So change this: mycontract = new web3.eth.contract(abi, contractAddress); to: mycontract = new web3.eth....
user avatar
0 votes
Accepted

Why require(minter == msg.sender) always throw error? I used the correct address as sender

I think this is a bug or maybe the network connection problems for goerli network. I tested the same code on truffle's local node, also on ganache, both of them are running ok.
user avatar
  • 160
0 votes

Should the constructor function be public?

Hey after solidity compiler versions 0.7.0 the use of public and internal keywords for specifying the visibility of the constructor is deprecated. You can check this question out from StackOverflow.
user avatar
0 votes

Loading data from JSON files to a smart contract

Generally it's not recommended to use Etheruem as a storage for files, it will be very expensive. 1 kilobyte costs 640,000 gas to store, with a gas price of 15 Gwei and ETH price of $1,000 you'll pay $...
user avatar
  • 2,435
0 votes

Linking to Compound Smart Contract

your CompoundERC20 is only an abstract contract. you should import from https://github.com/compound-finance/compound-protocol/tree/master/contracts
user avatar
  • 1
0 votes

How to get transaction history of ERC-721 token in Solidity

You can write a new event containing the transaction data you want and emit it within the _transfer function. You can query for these events on the frontend.
user avatar
  • 1

Top 50 recent answers are included