Questions tagged [solidity]

Solidity is a language for smart contracts for blockchain technologies like Ethereum. It is designed to compile code for the Ethereum Virtual Machine. Use this tag for questions about programming smart contracts using the Solidity language.

Solidity is an object-oriented language whose syntax is similar to that of ECMAScript, but with static typing, and it is designed to compile to code for the Ethereum Virtual Machine for use in smart contracts in blockchain technologies.

6642 questions
8
votes
6 answers

throw new Error 'Returned values aren't valid, did it run Out of Gas?

I am getting this error: Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not…
Rwitesh Bera
  • 389
  • 2
  • 3
  • 9
8
votes
3 answers

Call solidity function dynamically, based on its bytes4 function selector

In a smart contract, let's say I have a function which wants to invoke another function dynamically, based on some internal logic. Here it obtains the function selector as a bytes4 variable. After which it is possible to use branching logic to…
bguiz
  • 27,371
  • 47
  • 154
  • 243
8
votes
2 answers

Documentation for ethers.getContractAt()

Can somebody please point me to the documentation (official or otherwise ) that explains the function ethers.getContractAt(): the original context of this is as follows: vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock',…
maskara
  • 329
  • 1
  • 2
  • 12
8
votes
4 answers

TypeError: Cannot read properties of undefined (reading 'getContractFactory') when testing contract

First question so bare with me if it is not very clear, but I'll try my best. I am currently running through a youtube video to test my contract with hardhat, ethers, and waffle…
tito
  • 83
  • 1
  • 6
8
votes
2 answers

Solidity ^0.8.0. override virtual. "TypeError: Derived contract must override function .." but it already has the virtual override keywords

Context: Solidity ^0.8.0 Purpose: implementing a simple NFT contract Problem: the error throws i have to specify virtual/override keywords, but i've already done it. ERC721URIStorage inherits from ERC721 Verbose1: TypeError: Derived contract must…
8
votes
4 answers

Brownie doesn't automatically attach to local ganache when I have Ganache open in the background. It is stuck with ganache-cli

Brownie doesn't automatically attach to local ganache when I have Ganache open in the background. It is stuck with ganache-cli (1st image) (2nd image is what I am looking for). Can someone help?
waupelani
  • 107
  • 1
  • 3
8
votes
1 answer

Solidity: Testing reverted assertions with waffle + chai doesn't work

I'm testing a smart contract for an ERC721 token, that inherits from OpenZeppelin, using waffle and chai with NodeJS v14.18.0, but chai's reverted assertions don't seem to function as expected. Dependencies: "devDependencies": { …
Craigson
  • 131
  • 2
  • 8
8
votes
2 answers

How do I run Hardhat with the --constructor-args parameter?

I'm trying to run a script with Hardhat to deploy a contract which has constructor arguments. When I run npx hardhat run scripts\deploy.js --network rinkeby I get the error: Error: missing argument: in Contract constructor (count=0,…
Frank Furter
  • 508
  • 1
  • 6
  • 15
8
votes
2 answers

How to concat two string values in Solidity

Concat two or more string values- pragma solidity 0.8.9; contract StringConcatation{ function AppendString(string memory a, string memory b) public pure returns (string memory) { return string(abi.encodePacked(a,"-",b)); } }
MD SHOHAG MIA
  • 128
  • 1
  • 7
8
votes
2 answers

Rinkeby Authenticated Faucet is not working?

I need test ethereum for my pet project. I go to https://faucet.rinkeby.io/ , put a link with my tweet with my Ethereum address in MetaMask, choose 3 Ethers / 8 hours. The request was accepted, but 17 hours past and I haven't my test ethers. Did I…
Roman Matviichuk
  • 141
  • 1
  • 1
  • 7
8
votes
1 answer

_signTypedData method on ethers does not match with ERC712 solidity code

I've faced an ethers signature unmatched problem. Everything is normal. Already compared domainData, types, message variable in the js code with contract. Below is the JS Code to generate signature and call contract. const contractAddress =…
Kwang
  • 211
  • 1
  • 3
  • 7
8
votes
3 answers

How to transfer a NFT from one account to another using ERC721?

I'm writing an NFT smart contract using the OpenZeppelin ERC721Full contract. I'm able to mint NFTs, but I want to have a button that enables them to be bought. I'm trying writing this function: function buyNFT(uint _id) public payable{ //Get…
acampana
  • 461
  • 1
  • 3
  • 17
8
votes
9 answers

Can't import openzeppelin node_modules: File import callback not supported

Whenever I try to compile my solidity contract, the error ParserError: Source \"@OpenZeppelin/contracts/math/SafeMath.sol\" not found: File import callback not supported gets thrown. pragma solidity ^0.7.0; import…
AlienLobster
  • 111
  • 1
  • 2
  • 5
8
votes
3 answers

Check that object is null in solidity mapping

I have this solidity mapping mapping (string => Ticket) public myMapping; I want to check if myMapping[key] exists or not. How can I check?
Anas Hadhri
  • 159
  • 1
  • 2
  • 9
8
votes
1 answer

Web3 signature verification is failing - ethers.js

I'm trying to create a signed message off-chain using ethers.js and verify that message on-chain using ecrecover. I'm signing the correct message from my metamask wallet, and passing the r, s, and v from that signature into ecrecover, but not…
a94
  • 564
  • 1
  • 7
  • 16