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
1 answer
18 views

Hardhat chain fork on the test rather than config file

I saw that it is possible to test with Hardhat on a forked chain, via the config file. Is it possible to do it on the test file instead? In a beforeEach, maybe. I only want some of my tests to run on ...
user avatar
2 votes
1 answer
15 views

Truffle contract factory test with Javascript

Here is my smart contract source code. // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.9; contract CampaignFactory { address[] public deployedCampaigns; function createCampaign(uint ...
user avatar
0 votes
0 answers
15 views

I've been struggling to verify and publish my contract source code

I'm new to Solidity and Ethereum smart contract deployment, so I have been struggling with the verify and publish contract source code part. I don't know where I went wrong with this: // SPDX-License-...
user avatar
0 votes
0 answers
8 views

Decrypt Open SSL with a public key within Solidity contract

I wish to implement a whitelist function to my NFT minting solidity contract that also includes an NFT asset limit. For example, user A is allowed to mint 1 NFT, and user B 3 NFTs etc. I also wish to ...
user avatar
0 votes
0 answers
15 views

i'm working on an NFT collection following a tutorial video on web3 dao. my contract isnt compiling and it's showing the error below

//SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable....
user avatar
0 votes
1 answer
20 views

calldata encoding

I have been having an error with the following function call: IVault(VaultContract).depositFor( address(this), 47545929749321238, address(this) ...
user avatar
  • 925
0 votes
0 answers
24 views

Make user withdraw tokens

As a best -and most secure- practice, how do you make an user to withdraw tokens from your contract, without them having to initiate the withdrawal procedure (aka calling a withdraw function), instead ...
user avatar
  • 307
0 votes
0 answers
31 views

Passing array to external function in inline assembly

How can I pass a (nested) array to an external function if the call is made within an inline assembly block? I wrote the following little test contract and everything works just fine until I add the ...
user avatar
  • 3
1 vote
2 answers
32 views

window is not defined when used with next.js

I am trying to write a React-next.js app. I have the following file that exports an instance of Web3 by passing in window.ethereum to the constructor. import Web3 from 'web3'; const web3 = new Web3(...
user avatar
0 votes
1 answer
14 views

Not able to use "connect()" method to sign transactions with different account in HARDHAT

I am making a smart contract so that I can send messages and other addresses can also send messages in that contract. So the message, block.timestamp and the sender's address will be stored in an &...
user avatar
0 votes
1 answer
19 views

Ethers.js ignore revert

I'm using Hardhat to deploy my contract locally, and Ethers.js and Node.js run a Javascript file which makes sequential calls to the contract to simulate user activity. When the contract reverts (for ...
user avatar
  • 41
0 votes
0 answers
13 views

Why do some Solidity projects use a uint256 for user IDs as opposed to the users wallet address?

I noticed this on the Lens Protocol repo. It seems inefficient as they keep separate functions to ensure that the caller of a function is actually the owner of the profile ID.
user avatar
0 votes
2 answers
36 views

How to use an instance of an deploy contract using hardhat by forking mainnet?

I am an beginner in writing test cases, i want to fork mainnet to use uniswap routor contract instance in my contract. i am getting an error will running this code : 1) Splitter Deploy and ...
user avatar
  • 13
1 vote
2 answers
54 views

super keyword usage

Have this contract from oz // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC20/...
user avatar
  • 102
0 votes
0 answers
10 views

Trying to get the trasnaction information by trasnaction hash. Getting error

Im tryint to get the trasnaction ifnormation by the trasnaction hash. thats the code im using atm. web3.eth.getTransaction(web3.eth.getBlock(299394)[0], (error, result) => { if( ...
user avatar
  • 1
0 votes
1 answer
22 views

How to save an array in mapping and get the value in Solidity?

I want to create a mapping with an array of values. For example, I want to create a mapping of address that will hold the array of tokenIds that address holds. 0x0000XXXXX[0] = 989 0x0000XXXXX[1] = ...
user avatar
  • 3
0 votes
1 answer
16 views

How to rectify Parse error in Remix IDE

// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.13; contract Carshop{ constructor() {address[] carAssets; function createChildContract(string brand , string model) public payable{ ...
user avatar
0 votes
0 answers
22 views

How to send Wei with function call

I have a token mint function that is setup the following way struct HachiTicket { address to; uint256[] amounts; bytes32[] merkleProof; bytes signature; } ...
user avatar
0 votes
0 answers
20 views

tx.origin:time of initialization (i.e. at deployment or at the start of transaction)? ,fixed or unfixed? , understanding the condition?

I got the following code from: EthereumBook 1. contract Phishable { 2. address public owner; 3. 4. constructor (address _owner) { 5. owner = _owner; 6. } 7. 8. ...
user avatar
  • 1,215
0 votes
0 answers
28 views

Typechain: how to generate factory, d.ts files of contract abi

I have a command called typechain --target=ethers-v5 --out-dir src 'src/constants/abis/BoxContract.json' which created a BoxContract.ts file and a BoxContract__factory.ts, but it doesnt create a ...
user avatar
0 votes
0 answers
19 views

how to get data from contract A, and use it in contract B

I have gotten the data correctly from contract A...I cannot figure out how to use it in Contrtact B. One search led me to believe it may not be possible.. However what would be the point of Contract B ...
user avatar
0 votes
3 answers
46 views

Pushing a contract to an array in another contract

I am new to Solidity, and I have a small problem. For exemple I have these 2 contracts contract Dog { string name; constructor(string _name){ name = _name; } } contract Human { ...
user avatar
  • 3
0 votes
2 answers
16 views

my code doesn't run but shows "Downloaded binary would not execute, or returned unexpected output" in the terminal. Please help check where i am wrong

from solcx import compile_standard, install_solc install_solc("0.6.0") with open("SimpleStorage.sol", "r") as file: simple_storage_file = file.read() # compile Our ...
user avatar
0 votes
0 answers
24 views

Is it possible to do a transaction without gas? [duplicate]

Is it possible to do a transaction without gas? Metamask should suggest the gas? const transaction = { from: fromAddress, to: toAddress, data, value, } ...
user avatar
  • 15
0 votes
1 answer
20 views

Variable declaration

I am new to solidity.Below is the snippet of solidity source code which I came across :- pragma solidity ^0.5.1; library SafeMath { function sub(uint256 a, uint256 b) internal pure returns (...
user avatar
1 vote
1 answer
22 views

Solidity integer containing underscore

I'm using the following floating point library: https://github.com/paulrberg/prb-math/blob/main/contracts/PRBMath.sol It contains the following line: uint256 internal constant SCALE_INVERSE = ...
user avatar
  • 41
1 vote
1 answer
38 views

Why isn't this dutch auction returning the price or working?

I have set up a dutch auction with the specifics mentioned here: What is expected in setting up the following dutch auction? But it keeps reverting and doesn't seem to be returning the price which is ...
user avatar
0 votes
0 answers
18 views

Why is tx.gasprice always zero?

I have this modifier, and it never allows the method to be called as "tx.gasprice" always seems to be zero. Does anyone know why that is? modifier gasPriceIsValid() { require(tx....
user avatar
0 votes
1 answer
41 views

Error HH8: There's one or more errors in your config file: * Invalid value undefined for HardhatConfig.networks.rinkeby.url - Expected a value of t

I get this error when i try to run my script on the rinkeby network: Error HH8: There's one or more errors in your config file: Invalid value undefined for HardhatConfig.networks.rinkeby.url - ...
user avatar
0 votes
0 answers
17 views

how to call approve function in token contract using etherjs to allow other contract for spending of tokens

This is approve function abi: [ { "inputs": [ { "internalType": "address", "name": "token", "type": "...
user avatar
  • 1
0 votes
1 answer
29 views

How to access mapping in contract?

library Test{ struct Data { mapping (bytes => string) a; } function inc(Data storage self) internal { self.a[0] = 'ban'; self.a[1] = 'sam'; } } contract Example{ address ...
user avatar
0 votes
1 answer
20 views

Testing `approve` function

I would like to test a contract where I use the approve function of an ERC20 token. Is there any test suite that allows doing that? truffle? hardhat? Any suggestion would be highly appreciated!
user avatar
  • 101
0 votes
1 answer
21 views

Execution reverted when calling view function

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@uniswap/v2-core/contracts/interfaces/...
user avatar
  • 101
0 votes
1 answer
22 views

Clearing storage struct array with Solidity

We're implementing a Lottery where a player can buy multiple tickets. A ticket is defined with a struct and they are being kept in a storage struct[]: pragma solidity >=0.4.22 <0.9.0; contract ...
user avatar
  • 103
0 votes
2 answers
35 views

passing array of struct as a function argument and onlyOwner (web3.py) web3.py

hello dear community I wanted to ask why the transaction is not executed correctly. Code Solidity: // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.8.9; contract main{ struct data{ ...
user avatar
0 votes
0 answers
11 views

How to add time-sensitive data to governance proposals?

Many governance contracts use low level calls. In order to allow governance to call any contract, OpenZeppelin's governance bravo executes proposals through targets[i].call{value: values[i]}(calldatas[...
user avatar
  • 306
0 votes
1 answer
21 views

How to decode a bytes that represent a function call without having the function parameters types?

I have a Smart Contract that receives transactions proposal, these proposals go through a voting period and when this period ends, the transaction can be executed if it has the necessary approving ...
user avatar
0 votes
1 answer
42 views

Downsides of using ERC721A over ERC721?

At our project we're still contemplating wether to ERC721A over ERC721Enumerable. It's important for us to have stability. So has ERC721A proven so far that it's stable? I'm looking forward to answers ...
user avatar
  • 101
0 votes
1 answer
17 views

How gas fee to Mint an NFT are really calculated on Ethereum

I came across an NFT project listing their NFTs with 25.000 $ each. when I click on the button mint even though, I'll not buy it because I can' afford it. Metamask pops up with $28,827.05 Total ...
user avatar
  • 205
0 votes
1 answer
21 views

Avoid "out of gas" when calling a view function using truffle

I have a rather computationally expensive view function on my smart contract, which works with no problem on rinkeby (calling it from etherscan). However, deploying the contract into a local chain (on ...
user avatar
  • 101
0 votes
1 answer
23 views

Help: When I call TransferFrom after approve function it will revert

when I call depositTokens() which calls transferFrom() It'll revert : In react: const stakeHandler = async (amount) => { setLoading(true); token.methods .approve(defiAddress, amount) .send({ ...
user avatar
  • 3
0 votes
1 answer
21 views

How to access Struct values of Array invoked from solidity file on python brownie?

I look for a way to iterate struct values of Array that is returned from calling method of solidity file on eth-brownie python file. As I do some research on several topics asked on https://ethereum....
user avatar
0 votes
0 answers
9 views

Opensea listing signature arguments issue

We are developing an product where user could list their NFTs on bulk. We want to call Opensea's contract Wyvern Exchange Contract to sign transaction. However there are lots of arguments which we ...
user avatar
0 votes
0 answers
19 views

Slither errors in Openzeppelin's contracts-upgradeable

Using openzeppelin's UUPS upgradeable proxy contracts results in the following slither error. Are they false positives or should I be concerned? Enviornment: "@openzeppelin/contracts-upgradeable&...
user avatar
0 votes
1 answer
25 views

TokenURI Stack too Deep Errors

I am trying a slightly different approach to the TokenURI with dynamic metadata in my ERC721 NFT. As the metadata can change I generate the TokenURI in the contract as required, it works fine but I am ...
user avatar
0 votes
0 answers
16 views

The user gets rewards after reaching the time interval ,its happened one time only, it have to continues until the user withdraw his funds,how to fix

function mintreward(uint256 tokenId,string memory link) public { require(block.timestamp>=rewardInterval ,"Tokens are only available after correct time period has elapsed"); ...
user avatar
1 vote
1 answer
50 views
+50

Explain a decompiled smart contract

I decompiled a smart contract with below link: https://bscscan.com/bytecode-decompiler and I get these results: def _fallback() payable: # default function if not call.value: mem[96 len ...
user avatar
0 votes
0 answers
17 views

I tried a lot in an attempt to fork Mainnet but I am getting this CodedError: connection not open on send()

I am using ethers.js and truffle, while running truffle migrate, I am getting CodedError: connection not open on send() error This is my truffle-config file module.exports = { networks: { ...
user avatar
0 votes
1 answer
27 views

Dynamic uint array: push() returns a reference or new memory variable?

Solidity documentation 0.8.14: push(): Dynamic storage arrays and bytes (not string) have a member function called push() that you can use to append a zero-initialised element at the end of the array....
user avatar
  • 5
3 votes
1 answer
32 views

Can I import solidity code (or ABIs) into vyper?

Let's say I have a contract in solidity: pragma solidity 0.8.8; contract MyContract{ function getFive() public pure returns (uint256){ return 5; } } Could I import, inhert, etc in ...
user avatar

1
3 4
5
6 7
296