Questions tagged [solidity]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.

Filter by
Sorted by
Tagged with
1
vote
1answer
341 views

An unexpected error occurred: Error: Cannot find module '@nomiclabs/hardhat-waffle' [Hardhat, openzeppelin]

I keep getting this error when doing: npx hardhat run scripts/sample-script.js --network testnet. Edited the name of my computer for security reasons. How do I put in the module 'nomiclabs/hardhat-...
0
votes
0answers
3 views

How to send funds to a Governor treasury?

I am working on creating a DAO using the ERC20Votes and Governor contracts. I created the governor using the wizard, however I don't see any function for adding funds to the Governor treasury. I ...
0
votes
1answer
11 views

Is the smart contract receiving funds or is it the address?

//SPDX-License-Identifier: MIT pragma solidity 0.6.12; contract ExceptionExample { mapping(address => uint) public balanceReceived; function receiveMoney() public payable { ...
0
votes
0answers
6 views

What is the gas limit for a view function call *not made from a contract*?

So this question seems trivial but I can't find any comprehensive answer, though reading through: Is there a gas limit for view requests? Why view/pure functions need gas? Exceeds block gas limit ...
0
votes
0answers
4 views

I am running my tests in the hardhat environment but it gives me 0 passing all the time

I am facing rather unusual behavior from hardhat. I have written my test cases in a file inside test folder when i run yarn teston the terminal it gives me 0 passing. Don't have any idea as to why it ...
0
votes
1answer
8 views

have been having this error, ParserError: Expected ';' but got '}'

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract will { address owner; uint fortune; bool deceased; constructor() payable public { owner = msg....
0
votes
1answer
11 views

How do nework bridges work e.g. ethereum to polygon/matic bridge

I understand what a bridge does but I 'm interested in knowing how it works under the hood. How does it work when transferring assets from one network to another. Lets take for example the ethereum to ...
0
votes
1answer
36 views
+50

How can I list my nft on my custom Token

I want to create an NFT Game in which users can buy NFT with my custom token. for example, Decentraland has a token called Mana. as you can see they listed the NFT with Mana! Decentraland NFT example ...
0
votes
0answers
8 views

Problem with events catching in web3js

So I have a function "mint" and also I have a backend code that is listening to the contract's events. The weirdest thing is that I can catch the event "TransferSingle", but I can'...
0
votes
1answer
5 views

Basic question about github forking and dependencies

This is a very basic question but usually when you fork a repo in github and then clone it locally it brings the dependencies and node modules with it right? Or do i have to run npm install after I ...
0
votes
1answer
7 views

How do I have the Eth in one contract pay for the gas costs for operations in another contract?

I've got a semi-newb question about paying for gas to make an operation happen in Solidity. Can someone tell me whether something like this would worK? And if it can be done, if someone could point me ...
0
votes
1answer
7 views

ABI and Contract source code is not visible on etherscan's Smart contract

I recently posted a small Lottery contract on the ethereum rinkeby network. The contract got deployed successfully however I am not able to see Contract source code and ABI on the Etherscan portal. ...
0
votes
1answer
21 views

Which address is paying the gas fee? And, can the smart contract pay the gas fee by itself?

pragma solidity ^0.8.1; contract SendMoney{ uint public publicBalance; uint public lockedUntil; function receiveMoney() public payable{ publicBalance += msg.value; ...
1
vote
0answers
21 views

Transfer an NFT token from Polygon to Ethereum - Solidity smart contract

I am new to blockchain development, NFT and Solidity and i need your help. I have fount this twit and this Polygon documentation Most of the assets are pre-existing on Ethereum chain. But new assets ...
0
votes
1answer
11 views

Chain link external api call does not work

I'm trying to make external api call from my contract. I am using chain link to make this request. After transfer some tokens from one account to another it should make api request to my test ...
0
votes
1answer
14 views

Binance Smart Chain contract with withdraw and replenishment in both BUSD and USDT currencies

I have a task to make Solidity smart contract based on Binance Smart Chain network. That contract must withdraw and replenishment of funds with supporting both USDT and BUSD currences. But in contract ...
1
vote
0answers
7 views

Cannot interact with deployed contract - negative hex string

I am working on several contracts and I can deploy and test fine on hardhat-network. However whenever I switch to Ganache or Rinkeby I get the following behaviour: The contract deploys fine Whenever ...
1
vote
1answer
307 views

why does it not work if I don't handle the return value of call/callcode/delegatecall?

This is my Contract code : pragma solidity ^0.4.15; contract D { uint public n; address public sender; event CallStatus(bool); function callSetN(address _e, uint _n) { if (!_e.call.gas(...
1
vote
2answers
275 views

No events where emmited. Why?

This is not a duplicate question. The other one doesn't answer the problem in any way. Can anyone explain to me why do I get No Events where emmited when running truffle test? Ganache is listening in ...
1
vote
0answers
17 views

How to test overriden function with mocks

I have the following contract contract TimeHelpers { function getTimestamp() internal virtual view { return block.timestamp; } } I have the contract that inherits from this contract ...
0
votes
1answer
13 views

How to converted a string into four numbers in smart contract?

I want to have a string that can be converted into four numbers. For example, it converts a string from E17B1237 into (225, 123, 18, 55), this is converted from hexadecimal into decimal. E1 => 225, ...
0
votes
1answer
18 views

Sending eth to deployed contract between 2 metamask wallets

pragma solidity >=0.7.0 <0.9.0; contract StructMapping { mapping(address => uint) public balanceReceived; function getBalance() public view returns(uint) { return address(...
0
votes
1answer
12 views

Why does this contract on etherscan show more source code than what was used during contract creation?

Etherscan shows two contracts in the source code at this address: https://etherscan.io/address/0xdab5dc22350f9a6aff03cf3d9341aad0ba42d2a6#code If you then look at contract creation code it only lists ...
0
votes
0answers
7 views

AttributeError: 'int' object has no attribute 'buildTransaction' - Python Web3 Solidity

I'm using this code to swap token USDT to token A but it has been stuck by this error: AttributeError: 'int' object has no attribute 'buildTransaction' Here is my code: path = [tokenA,tokenB] ...
0
votes
1answer
7 views

If a function returns two or more values and I wish to use one of the two in another function, how do I do that?

I have a function xyz : uint256 a; uint256 b; function xyz() internal view return(uint256,uint256){ return (a,b); } Now, I wish to use the first return value in another function (for eg): uint256 c; ...
0
votes
1answer
5 views

What is the most gas efficient way to read and write to global contract state?

Say I have a complex(list, mapping or struct) global/contract variable. What is the most gas efficient way to update that variable in a function that changes the value of one or more indexes, values ...
0
votes
0answers
12 views

solidity ^0.8.0 - receiving payment failed at require(msg.value == ___ ether)

ide: remix injected web3 on ropsten network, issue: I'm new to solidity and reverse engineering a little 3 year old project while learning the breaking change from 0.4+ to 0.8.0 I'm not sure what I'm ...
1
vote
2answers
51 views

Message call to another contract with argument not working

Here I am trying to call contract A's callMe function from contract B using the low level function, call (bool success, )=_b.call(abi.encodeWithSignature("callMe(uint)",val)); But when I do ...
0
votes
0answers
12 views

How can I fix this Uniswap Router bot?? It's making me put a time.sleep(40) just before buy() function?

This uniswap router bot triggers a swapExactETHForTokens transaction but it always fails with an "out of gas" error unless I put a time.sleep(40) just before the buy() function. I tried to ...
2
votes
2answers
665 views

How do I use filter EVM log events by an indexed field in web3j?

I've looked through the documentation, but there doesn't seem to be this scenario listed. What I want to do is filter the Ethereum event log of a specific contract by an indexed field with Web3j. ...
3
votes
2answers
27k views

TypeError: Cannot read property 'then' of undefined

I am having an error with Web3. After going through all possibilities I decided to post a question hoping for someone with a solution. The error I keep getting is: TypeError: Cannot read property '...
1
vote
1answer
10 views

Chainlink Keepers - Multiple Upkeeps in a Single Contract

From ChainLink docs Here, I know we can create upkeeps using the checkUpkeep and performupkeep functions. Is it possible to create multiple upkeep checks and performs in the same contract? may I know ...
0
votes
0answers
15 views

why does my contract say honeypot?

https://bscscan.com/address/0x4451f5016724867fd00438eb30d5b2f23d3d69bd This is my code source. TokenSniffer does not pick it up and staysafu says its a honeypot, the token is tradeable
0
votes
0answers
5 views

How to test a function which calls another contract from inside the function?

newToken.sol import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; contract newToken is ERC1155 { using Counters for Counters.Counter; Counters.Counter private ...
1
vote
1answer
14 views

Weird error: reverted with panic code 0x32 issue when testing with hardhat

I am having this weird code issue when testing my solidity contract with hardhat. I will show you two use cases. One doesn't work while the other works. Doesn't work: It leads to this error: ...
0
votes
0answers
4 views

Ganache Storage not updated after minting ERC721 token

I am using a standard OpenZeppelin ERC721 token API to mint a NFT. The code looks as below: pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@...
1
vote
1answer
43 views

My ERC-721 minting gas fee is almost $10000. Too high. How fix it?

I just deployed NFT Dapp on mainnet. Estimated gas fee is too High. It's almost $10000 How can i fix it? I never knew on local canache or rinkeby testnet There was fine gas fee.. is it depend on ...
1
vote
0answers
22 views

Assign a portion of an array into another array

I want to create a new string array with elements from another array. After that, my randomization will go through this new array. What is the best way to do this? Here's example code piece: // SPDX-...
0
votes
0answers
22 views

Interacting with Contract instance works on hardhat local rpc but throws error on mumbai testnet

So I'm currently working on an nft marketplace and I have this function that gets all the collections(which are proxy contracts) in the marketplace and gets basic info from the contract, like the name,...
0
votes
2answers
178 views

How to run Dapp on the Fantom blockchain?

I have deployed 2 contracts on Fantom that were running on Rinkeby. Worked really well. However, when I run my Dapp using "yarn dev", I get nothing. It cannot connect to the blockchain. So ...
0
votes
1answer
14 views

Contract address balance function returns BN in truffle but actual balance in remix

I am very new to solidity, contracts, and truffle, and I ran across a disconnect between the results of calling the getBalance() function of this basic contract: contract TruffleTutorial { address ...
0
votes
0answers
11 views

I'm trying to create a Token on TRONSCAN and I'm getting a constant error. "Compiled error: solidity or solidityFile is required."

pragma solidity 0.5.16; interface IBEP20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the ...
0
votes
1answer
13 views

TypeError: Greeter.deployed(...).greet is not a function

Getting error Code: address payable owner; constructor () { owner= payable(msg.sender); } function kill() public { if(msg.sender== owner) {selfdestruct(owner);} } } ...
0
votes
1answer
20 views

How to add separative commas every 3 digits in solidity to an input integer?

Is there a way to add separative commas to large input numbers? let's say the input was 1000, I want the output for this function to be a casted string that has this format "1,000". Note: I'...
1
vote
1answer
882 views

Is it possible to show multisig wallet transactions on metamask?

I am trying to implement multisig wallet, where one contract address is set as a wallet with multiple owners. I want to show multisig transactions on MetaMask. Is it possible to do that? My contract ...
2
votes
2answers
2k views

How to transfer Ether to ERC20 token contract?

I have a function that needs to make transfers to a token smart contract as well as personal accounts upon satisfaction of some conditions. function completeSale() onlyOwner public { if (...
1
vote
5answers
1k views

Contract methods calls return empty array

I'm quite stuck with this issue. It seems like it must work, but it doesn't :D Have a contract on rinkeby network which is working perfectly through remix(load by address) and truffle console. ...
1
vote
2answers
710 views

what is use of body less '_beforeTokenTransfer internal virtual ' function

Inside _transfer function there is a call goes to _beforeTokenTransfer(sender, recipient, amount); and that function is written as function _beforeTokenTransfer(address from, address to, uint256 ...
1
vote
1answer
24 views

Do I need to initialize the 'i' variable in a for loop?

Do I need to explicitly initialize the 'i' variable in a for loop? Since i is a uint and its default value is 0, why should I spend gas in a MSTORE operation to initialize the variable with 0? The ...

1
2 3 4 5
255