New answers tagged

0

I'm speculating that the frontend is trying to call contract.SendAmount{value: ???}(), and metamask is asking you to approve the call to the contract. So the address you're seeing is actually the contract address. You don't need to approve every individual operation inside the contract's function, so you should never see you hardcoded _to address in metamask....


0

Hey so thanks again Haxerl for the assistance, it did help me figure out what's going on. Essentially I need to make another call from the ERC721 contract to allow this contract the right to sell on its behalf. So the issue wasn't really in this contract, it was due to a lack of understanding on my end. I think I understand a lot more now that I have ...


0

Basically you release code and get miners and users (and exchanges and other stakeholders) to use it. https://github.com/ethereum/execution-specs has a list of the hard forks and the links in the Blog column point to the code.


1

decimals() returns the number of decimals in the returned price. In this case, it is eight. I changed your getPrice() function a bit to exclude the use of decimals() pragma solidity ^0.8.7; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; contract FundMe{ mapping(address => uint256) public adressToAmountFunded; ...


0

Check web3.eth.getChainId(). You find the documentation here: https://web3js.readthedocs.io/en/v1.2.4/web3-eth.html#getchainid Also there is an EIP-1193 event in WalletConnect that tells you when the chain has been changed: https://docs.walletconnect.com/quick-start/dapps/web3-provider#events-eip-1193


1

The decimals value represents the number of decimal places in the answer and will always be the same. For this feed always posts answer that go out 8 decimal places.


0

Your contract had multiple issues which made it impossible to compile. Here is a version that doesn't throw any errors. The first issue (; required) was for the familyWallets[i].transfer line. // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract Will { address owner; uint fortune; bool deceased; constructor() ...


1

Sometimes Etherscan may identify similar contracts which is probably why your partners have the ABI of the contract already visible. You can make this happen for your contract manually by verifying the contract yourself on https://rinkeby.etherscan.io/verifyContract. For a single file contract it's easy but you can follow some tutorials such as this one or ...


0

It looks like your balance is 0.015 ETH, as shown in Etherscan. Blockchair shows the same balance. Also when querying eth_getBalance() via Alchemy API, we get 0.015 ETH too. Not sure why Blockchain.com shows a different value.


0

Per truffle docs, the .at functionality will yield a Promise. Based on what you're querying inside the terminal, shouldn't the syntax be more like: (await greeter.at(address)).greet()


0

I do not believe this is possible. If someone can find your contract address they can call it. You can still store data off chain, though that data would no longer be immutable. If this isn't a problem for your use case, then you can always provide the off chain data to the contract function at a later time.


1

When your createContract calls the mint function on one of your newToken contracts it will become the msg.sender. Therefore it will mint a newToken to your createContract. By definition ERC-1155 contract will check if the receiver of a token transfer is a contract and if this is the case call onERC1155Received (see ERC-1155 Token Receiver). This also applies ...


1

The idea behind the blockchain is that it's permissionless and transparent. Anyone can verify the blockchain state at any point. Etherscan is just one such UI and anyone can create a front-end to read the state (calling view functions). Regarding writing to the blockchain, anyone with a valid signature can call the external/public functions. So whatever you ...


0

There is a modifier onlyOwner/OnlybyOwner that allows only for the ones who deployed the contract to call the function. Additional owners can be added by the original Owner. ( Look at OpenZeppelin here) But you can create a custom one too, to better suit your requirements. ShortAnswer: You can create a modifier that will limit as to who can call a function. ...


0

As Ismael has mentioned in the comments, there is a metadata file for each NFT. You could use that metadata JSON file to link to a legal document or include some terms & conditions explaining that the owner of the NFT also owns a certain physical asset (or certain rights to it).


2

Assuming that your NFTtoken has enough balance of your ERC20 token (as you are transferring 10 tokens from the NFT contract to the NFT creator), I would say your implementation of the transfer method on the ERC20 contract is not correct. As you are transferring tokens to the to address you should add the amount to the to balance instead of substracting it: //...


0

I resolved this issue by not exporting the contract export default new web3.eth.Contract(abi, address); , but just bringing the loading of the ABI and address into a conditional when the required button is pressed.


0

To put it briefly , an Ethereum client is simply a piece of software that provide an application a gateway to interact with the ethereum blockchain . Full nodes running on ethereum clients validate transactions in ethereum . There are remote clients as well like metamask that depend on full clients for access of the blockchain . Remote clients cannot perform ...


0

Transaction malleability is a Bitcoin attack that was seen due to a bug in the Bitcoin implementation. Due to this bug, it became possible for an adversary to change the transaction ID of a transaction, thus resulting in a scenario where it would appear that a certain transaction has not been executed. This can allow scenarios where double deposits or ...


2

If is usually called after a token has been transferred (in same tx). If the receiver of the token is a contract, it checks if the contract implements the onERC721Received interface. If no, it reverts the transaction. If yes, the receiver contract has a onERC721Received method. The ERC721 calls this method, and now execution goes to the receiver contract to ...


0

The issue here is that you need to add --http.corsdomain=* --http.vhosts=*


0

You need to find a source of truth for the question "what is the value of NFT 'x'". You can always ask OpenSea what the last sales price they saw was but that's hardly the value of an NFT as a decent percentage of the NFT market is not on OpenSea's proprietary website.


0

Usually you just need to provide a fake implementation to the desired methods you use/test. Your mock can be clean without mocking(implement) all of the methods you wouldn't use in your business logic. Same OOP principles applies here. I noticed that some Mock contracts (ERC20, MockV3Aggregator) have something in common like constructors or return statement....


0

You can test your smart contract by using Truffle. There is even a command [truffle test] that will run all the written tests. That way you can double-check if your contracts work. If however, you want to test the deployment of your contracts. You can do it on your own local network, or one of the running test networks that are freely available online.


0

There's the EIP-2981 NFT Royalty Standard. A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal support for royalty payments across all NFT marketplaces and ecosystem participants.


1

By definition of EIP-214 any state change within a static call will cause an error. So if you define your function as view or pure this will not be possible, as this indicates the calling contract that they should use staticcall. BUT if you want to write a method and don't care about the view or pure you can do a little trick. You create a method that will ...


1

From the ethers documentation we can see that contract.callStatic is an utility that interacts with the node itself. It works by asking the node to simulate the transaction, without the tx being actually sent to be mined. A similar behaviour isn't available at a smart contract level as any state change is permanent if not reverted. A workaround could be re-...


0

If you are working with version >=0.8, you need: InsuranceClaim newInsuranceClaim = new InsuranceClaim(msg.sender); deployedInsuranceClaim.push(payable(address(newInsuranceClaim))); Note the use of payable here.


0

This depends on your js library that is used to interact with the contract. For Ethers (and probably also web3js) you can either use an object with keys or nested arrays. So for your example: const items = [ { name: "Item 1", value: 0, supply: 100 } ] contract.createCampaign({ name: "name", campaignType : 0, items })


0

In newer versions of Remix, use the field named Value above the deploy button. It is the same field that is used to choose the initial contract balance on deploy when the constructor is payable. Then click the button that calls the payable function that you need.


0

When triggering solidity methods you don't always get the returned values back to your JS environment. For call methods (e.g. view) - functions that do not change state, you can reliably expect return values. Whereas for write methods - those that change state, your JS library will not expect them by default. This is due to the unknown time of mining the ...


0

The constructor uses the pancake's router address from bsc net constructor (address marketingWallet) { _rOwned[_msgSender()] = _rTotal; _marketingWallet = payable(marketingWallet); //Pancake Swap V2 address IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E); But that ...


0

Binance Smart Chain is an EVM compatible blockchain. This means that any utilities you are accustomed to from Ethereum will work on BSC as well. The sendTransaction({..., value: x }) method will transfer the utility token of the blockchain in question: ETH on Ethereum, BNB on BSC, Matic on Polygon POS and so on. As for the network, the user is the one who ...


0

This happens if the access token is not set as the deployment key properly. Try running the command: graph auth --product hosted-service You should get the below message if successfull


0

If someone, like me, was trying to understand how to set some value to msg in Remix for a test, the trick is this: ///#value: 100 function testSomething() payable public { Assert.greaterThan(msg.value, uint(50), 'value should be > 50'); } If you run this code above it will be OK. Because you need to put "///#value: {desired value}" - With ...


0

In ERC721 specification (https://eips.ethereum.org/EIPS/eip-721#specification), it state that the transferFrom function must have this property /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE /// TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE /// THEY MAY BE PERMANENTLY LOST /// @dev Throws unless `msg.sender` is the ...


0

Deleting a mapping basically sets all elements of the struct to the default value. That could have been the issue. I made some small changes, by basically adding a bool that indicates if a task still exists. // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract TodoList { uint public taskCount = 0; mapping(uint => Task) ...


0

I resolved it by changing my encode_data task to this : encode_data [type="ethabiencode" abi="(bytes32 requestId, bytes value)" data="{\\"requestId\\": $(decode_log.requestId), \\"value\\": $(parse)}"]


0

here is one: https://github.com/ethereum-lists/tokens/tree/master/tokens/eth Sadly it's not comprehensive. Did you manage to find a better one?


0

There is quite some information missing to properly answer this question: What framework do you use and what programming languate? How do you create the myContractInstance (e.g. what ABI, is there a provider or signer)? Making some assumptions I would say the following: In the ABI that you use to create your contract instance the balanceOf method is not ...


2

Blockchains are often categorized by the consensus algorithm they use, therefore it is worth taking a look at Blockchain Consensus Encyclopedia. The site contains numerous blockchain projects that are listed in each consensus algorithm's "Used in" section. You can get a broad idea from this picture: PoW chains: Bitcoin Litecoin Ethereum PoS ...


1

The best sources I know that covers all blockchain would be cryptocurrency prices websites like coingecko. Most EVM compatible chains can be found here


0

There are two concepts in functions. return statement returns keyword return This is your standard return statement. Whatever is written after it is returned from the function. returns function getValue() public view returns (uint) { return simpleInt; } function getValue2() public view returns (uint simpleInt) { } The first case simply defines a ...


0

This is related to webpack setting. if you are using create-react-app, I posted an answer here: https://stackoverflow.com/questions/70472965/web3-issue-react-application-not-compiling/70512623#70512623 If you are using webpack, here is related answer: https://stackoverflow.com/questions/70559396/webpack-breaking-change


0

The problem is that contracts is declared as address[] public contracts; so it will only accept addresses. You could fix it by casting newContract as address function newCookie(string memory _name) public returns(Cookie newContract) { newContract = new Cookie(_name); contracts.push(address(newContract)); return newContract; }


1

The cause for the gas consumption might be connected to the error message. Before Solidity 0.8.0 if a contract fails because of an assert it uses an invalid opcode and therefore it uses up all remaining gas. So if you set a high gas limit it will eat up all the gas. If a contract fails because of a revert no additional gas will be used up. More info on this ...


0

Looking at https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md#eth_requestaccounts calling eth_requestAccounts seems like an async operation. So following the example in the linked EIP you need to await the result. The result of this should be an array of addresses. In any case if your MetaMask account was linked to your dapp (identified by the ...


0

I found out that I forgot to set array size in "getReserve" function and adding this piece of code to beginning of the function fixed the error reserves = new uint256[](2);


2

There might be many reasons for it. One obvious one might be that you have quite some factory contracts that deploy contract instances, that just differentiate in state (e.g. owners). An example for such factory contract is the GnosisSafeProxyFactory which creates the same proxy for all users and just changes the configuration which is stored in the storage. ...


0

Well, we have bridge smart contract that transform the assets from one chain to another or one token contract to another. So, for transferring asset the user perform the transaction with bridge contract, which make the transaction the part of token transaction list because the interaction with smart contract is internally thorough message call that why it ...


Top 50 recent answers are included