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
0 votes
2 answers
354 views

Truffle best practices - unit vs integration tests

Think about having two contracts: MockToken Faucet (which takes token address as constructor parameter) To unit test Faucet I would create two new instances: const token = await MockToken.new() ...
0 votes
1 answer
6 views

What happens to the eth held by a contract once it is killed?

What happens to the eth held by a contract once it is killed? And how does it continues to receive eth after getting killed ? Where does the balance of the contract get stored in a EVM?
0 votes
0 answers
5 views

How do I decode call data in solidity?

I have data in memory that is used for a function call, so I guess that makes it call data rather than a calldata (data location). This call data, say bytes memory data, consists of a selector and the ...
0 votes
0 answers
5 views

Ethers-EIP712 wont work with strings

I tried to use eip-712 signature with my smart contract but I found out that it only work with fixed-size type. Does anyone know how I can use dynamically-Sized types like string, arrays and bytes ...
0 votes
0 answers
7 views

What are the common Solidty smart contract libraries like openzeppelin?

I am new in smart contract, can anyone recommend some Solidity library that experienced developers often use. And is there a list of widely-used libraries? or where can i find some widely used ...
0 votes
1 answer
22 views

Getting an Invalid Address error when trying to interact with smart contract in truffle express box

I have a function where I insert patient's info into a mapping and it works perfectly fine on remix and in the truffle console. function createPatient (uint _SecretNum, string memory _name, uint _dob, ...
2 votes
1 answer
29 views

How does Solidity implement C3 linearization?

The solidity documentation does not offer a lot of insights into their implementation of the C3 linearization to resolve methods in a multiple inheritance scenario. There it states that You have to ...
0 votes
1 answer
8 views

Initializing an array of contracts

I am just starting out with Solidity and I came across this code block meant to deploy a new contract and add the address to an array. Can someone please explain why the array is initialized this way? ...
1 vote
2 answers
943 views

I am getting error ERC1155: transfer to non erc1155 receiver implementer means

pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; contract newToken is ERC1155{ using ...
0 votes
2 answers
246 views

How to test internal members of solidity library or contract in brownie?

Say I have the following SimpleMath solidity library defined as follows: library SimpleMath { function add(uint a, uint b) internal pure returns(uint) { return a + b; } } How do I import ...
0 votes
1 answer
6 views

TypeError. Expect type conversion not allowed from “uint256” to “contract MyToken”

I followed the video, NFT marketplace on ICE, and could not compile because of the following TypeErrors. Expect type conversion not allowed from “uint256” to “contract MyToken”. Expect type conversion ...
4 votes
1 answer
187 views

What does super refer to when overriding multiple parents?

When inheriting from multiple contracts with the same method sometimes I am asked (by the IDE and the compiler) to override a function which is declared in both contracts. This usually happens when ...
0 votes
2 answers
754 views

ProviderError: max code size exceeded - Hardhat

Iam trying to deploy a contract in ropsten testnet using hardhat but its throwing max code size exceeded error. i tried this example bud didn't work added (allowUnlimitedContractSize: true) but didn'...
0 votes
2 answers
136 views

python-dotenv fails to import PRIVATE_KEY from .env file: "Cannot convert None of type <class 'NoneType'> to bytes"

I am learning solidity and when I use python-dotenv to import my PRIVATE_KEY from a .env file, export PRIVATE_KEY = 0xd6a5ea3d2c97b1dd03fd1b9c447e36791522135136665f23b0c08c6395f66d7a it imports it as ...
0 votes
1 answer
5 views

slither: KeyError: 2394

When I try to run slither . inside my contracts folder (hardhat project), I get this super weird warning ...python3.9/site-packages/crytic_compile/crytic_compile.py", line 291, in ...
0 votes
1 answer
12 views

HTTPError: 401 Client Error: Unauthorized for url: https://rinkeby.infura.io/v3/$WEB3_INFURA_PROJECT_ID

I'm following this solidity tutorial from Patrick Collins and when running a script: brownie run scripts/1_deploy_token.py --network rinkeby I get this error: INFO: Could not find files for the given ...
0 votes
0 answers
8 views

Paycheck contract keeps trying to send to a new random contract address/not working properly

I'm very new to Solidity and facing a dumb problem. I'm trying to create a contract that pays my employee Mike (ex). Here, withdraw() function worked as expected. It returns ETH to my wallet again ...
1 vote
1 answer
2k views

Force function execution

I have an approve method. function approve(address spender, uint value) public returns(bool){ if (msg.sender==_owner){ allowance[msg.sender][spender] = value; emit ...
4 votes
1 answer
1k views

Solidity link to external library address - use Lib for uint256 breaks

I'm trying to link my contract to an external library by defining an interface contract that defines the library functions and the main contract that refers to the actual library address. My library ...
1 vote
2 answers
214 views

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

I would like to know if there is any method of identifying if an address is erc721 or 1155 without calling the differentiating functions on both.
0 votes
0 answers
8 views

How to loop over an array and be sure to get enough gas?

in my contract a function loop over an array with undefined length : function tallyVotes() external onlyOwner { uint _winningProposalId; for (uint256 p = 0; p < proposalsArray....
0 votes
1 answer
737 views

Truffle migrate shows an error on open zeppelin ERC721

I'm very new to truffle and solidity it might be a rookie mistake. When typing truffle migrate --reset, I've got the follow errors : @openzeppelin/contracts/introspection/ERC165.sol:24:5: Warning: ...
0 votes
0 answers
15 views

How do I properly sign and utilize a signature to do a transaction

I know how to create signatures for accounts using web3.eth.sign(). However, My process could be wrong so please correct me. web3.eth.sign(accounts[0].address, text="test") I then have ...
0 votes
1 answer
21 views

_disableInitializers() vs initializer vs reinitializer(uint8 version) in Openzeppelin/contracts-upgradeable?

Initializable.sol provides an initializer modifier and a _disableInitializers() internal function. I need help in understanding why a _disableInitializers() might be needed if we already have a ...
0 votes
1 answer
3 views

missing encodePacket / .abi + keccak256

I'm not 100% sure how to describe my issue, total noob following the BlindAuction solidity tutorial and stuck unable to compile. any help is much appreciated. function generateBlindedBidBytes32(uint ...
0 votes
0 answers
7 views

TypeError: Different number of components on the left hand side (9) than on the right hand side (7)

Hey Team im get this same error in 4 function : _transferStandard _transferToExcluded _transferFromExcluded _transferBothExcluded function _transferStandard(address sender, address recipient, uint256 ...
0 votes
0 answers
19 views

what is the problem of this code?

//stuffs is object of a struct function sell(uint _id) public payable returns(string memory) { stuffs[_id].buyer.balance -= stuffs[_id].highestBid ; // error Expression has to be an lvalue. ...
0 votes
2 answers
53 views

Just got my contract drained- how?

I just got my contract drained, and am trying to understand how. Obviously I'm a noob, played with fire and got burned bad (shouldn't have big sums of money on contracts). I SHOULD have transferred my ...
0 votes
2 answers
488 views

Solidity MINT ERC20

I will try to be brief in my doubt, below I am putting a model of a Smart Contract referring to a currency that I am creating for my game. // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 &...
7 votes
2 answers
21k views

How can i transfer ERC20 tokens from a contract to an user account?

I have deployed an ERC20 token (contract A) and the tokens are being used for a service in my other contract (Contract B). I can easily transfer tokens from an user owned account(EOA) to Contract B ...
0 votes
1 answer
244 views

TypeError: Cannot destructure property 'interface' of 'require(...)' as it is undefined

While testing the solidity contract, I'm getting the error `const { interface, bytecode } = require('../compile'); ^ TypeError: Cannot destructure property 'interface' of 'require(...)' as it ...
0 votes
3 answers
489 views

How to write a first solidity contract in remix - ide online?

I have written a small contract which is just to set and get a name. I choose JavaScript VM, when I deployed it and set my name as "vijay" and when I selected getname. I didn't got output. It shows ...
2 votes
0 answers
15 views

Measure gas left in block in solidity

There is a gasleft() to check how much gas left for my smart contract execution in solidity. But how is it possible to check how much gas left in block? I am having quite a big solidity function, and ...
0 votes
0 answers
7 views

my exercise is delete owner after 4 weeks , whats worng with this code?

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.8 <0.9.0; contract test{ address owner; constructor(){ owner==msg.sender; } modifier onleyowner{ require (owner==msg....
0 votes
1 answer
202 views

Cannot swap eth for exact tokens: TransferHelper: ETH_TRANSFER_FAILED

I can't swap eth for exact tokens because of the error... Error: Returned error: VM Exception while processing transaction: revert -- Reason given: TransferHelper: ETH_TRANSFER_FAILED. The code, I ...
0 votes
0 answers
17 views

how to wrap specific amount of ETH to WETH?

I struggle with finding a way of wrapping BNB to WBNB when not knowing amount to wrap prior to contract all. Wrapping function is defined like this: function deposit() public payable { balanceOf[...
0 votes
1 answer
1k views

VM error: revert. revert The transaction has been reverted to the initial state

Here my contract pragma solidity >=0.4.21 <0.6.0; import "./CertificateOwnable.sol"; import "./CertificateStorage.sol"; contract Certificate is CertificateOwnable { CertificateStorage ...
0 votes
0 answers
10 views

Is 1 word 4 bytes or 32 bytes in solidity?

I'm confused about the term word in solidity. When I google word, it says 1 word = 2 bytes but whenever I read word mentioned in the context of solidity, it sounds like 1 word = 32 bytes? What is a ...
0 votes
1 answer
6 views

Why my code is showing error since the syntax is right near error keyword

Error ParserError: Expected ';' but got '(' --> me/RevertAndAssert.sol:9:17: | 9 | error throwError() | ^ //SPDX-License-Identifier:GPL-3.0 pragma solidity ^0.8.0; contract RevertAndAssert { ...
0 votes
1 answer
7 views

Execute "setApprovalForAll" on behalf of deployed smart contract (Solidity)

I have deployed a contract which implements Ownable and IERC721Receiver. The issue I am facing is that this particular contract does not implement any function to grant approval to other contracts in ...
0 votes
1 answer
261 views

Externally Owned Account use Contrast account to transfer ether

can I use a Externally Owned Account to call contract account function to transfer ether to other Externally Owned Accounts, and the ether is from contract account.
4 votes
9 answers
6k views

Hardhat console can't be resolved in VSCode

I created a new Hardhat project and used the advanced TypeScript example. I also have a VSCode installation with the Solidity extension running. //SPDX-License-Identifier: Unlicense pragma solidity ^0....
1 vote
1 answer
376 views

Unable to test Solidity Remix

I am writing my own smart contract in Solidity and trying to test in Remix. The main Remix site appears to be down (https://remix.ethereum.org/). I found another site: https://ethereum.github.io/...
0 votes
0 answers
7 views

i am faceing the issue in my Vs code please solve this [closed]

[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/bod8d.jpg this is the problem
0 votes
2 answers
27 views

Can you unpack a tuple into a struct? And vice versa?

Let's say I have a struct: struct NetworkConfig { bool myBool; uint256 myNum; } And I have it saved as a variable as such: NetworkConfig public activeNetworkConfig; If I were ...
1 vote
2 answers
777 views

web3.py provider error -- 'Web3' has no 'eth' member

Hi I am trying to use web3.py to connect some python code to a solidity contract and I am getting an error -- Web3 instance has no eth member. w3 = Web3(EthereumTesterProvider()) ...
0 votes
1 answer
523 views

Add liquidity by code is failing

I have the following code: contract Test is ERC20, Ownable { address constant routerAddress = 0x10ED43C718714eb63d5aA57B78B54704E256024E; constructor(uint initialSupply) ERC20("Test&...
1 vote
2 answers
487 views

What is from address and Topic address in Remix log

I am invoking the buyTicket function of contract from account "0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C" in remix IDE with 20 ethers which is clear from log but confused what is "from" and "topic" ...
0 votes
0 answers
10 views

How to transferOwnership of child contract to the account that created it and not the parent contract?

Hi I have a parent contract that allows users to invoke a function that creates a child contract. In the child contract's constructor I am trying to run the function transferOwnership, but when I do ...
1 vote
3 answers
6k views

Updated token metadata not refreshing on OpenSea

I've deployed a contract that lets users mint NFTs, which will have a "coming soon" artwork that will then be updated to reveal the real artwork at a later time. This was due to the fact ...

1
2 3 4 5
297