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
0answers
4 views

Generic questions about Dapp project

I'm new to dapp development and want to dive in the pool. I've followed a lot of tutorials about dapp development (most of them are lotteries and ballot projects). There were good introductions to SC ...
0
votes
0answers
10 views

Solidity: Is this a scam quiz? [duplicate]

So today I found this smart contract quiz with a balance of 15 ETH to be won, if you just answer the question right. Obviously you can read the answer of the question within the START function, which ...
0
votes
0answers
2 views

How to solve Unhandled Rejection (Error): invalid address error with web3 js

Whenever I run the code I get an error saying "Unhandled Rejection (Error): invalid address (argument="address", value=["0xF628D397c2C1c4cB485BDF5441ac723B229f4F8f"], code=...
0
votes
0answers
9 views

What's the definition of `_maxTxAmount` and `numTokensSellToAddToLiquidity`?

I saw these two parameters (_maxTxAmount and also numTokensSellToAddToLiquidity) on some contracts, can someone let me know what are they for? Thanks, their codes are below: function setMaxTxPercent(...
0
votes
0answers
8 views

What's the difference between these 2 solidity interfaces methods?

I've been following a new journey into solidity for about a month now, so far so good, however with the Interface I'm having a hard time understanding the difference between these 2 methods of ...
0
votes
0answers
6 views

solidity cannot verify ethers.js signed data

I have a simple contract which recover the signature signer signing: console.log(signer.address) const encoded = abiCoder.encode([ "uint" ], [ 1234 ]); console.log(encoded) ...
0
votes
0answers
4 views

Why listing a NFT (contract already deployed on Ethereum) in OpenSea don't need to send transaction?

Why canceling a listing requires send a transaction? Will the listing be submitted to Ethereum?
0
votes
1answer
10 views

What is the return of uint(keccak256(_str));?

I'm doing the chapter 1 of the crypto zombies course. uint id = zombies.push(Zombie(_name, _dna)) - 1; NewZombie(id, _name, _dna); } function _generateRandomDna(string _str) ...
0
votes
1answer
8 views

how to create limited quantity NFT

I want to create 50 pieces of the same artwork as NFT(for learning purposes). I want multiple wallets to own one or more of the NFTs. Should I create 50 different smart contracts or there is a special ...
0
votes
0answers
6 views

Minting NFT using Lazy Minting Method

I am trying to mint NFT using lazy mint method. I am using remix IDE to write contract using solidity. For the front end I'm using react and web3js. I wanted to know if it's possible to implement lazy ...
0
votes
0answers
7 views

Gas cost of mapping lookup and update inside mint transaction compared to getting a variable and then interfacing with another contract function

I have a mint function that does a lookup in a mapping to get some data and then after some computation updates that keys value, and mints. For the specific use case, i've identified an option of ...
0
votes
1answer
5 views

solc_version not working on VS Code (Mac OSX)

I tried running the code below and gave me the error message (bottom of post). with open("./SimpleStorage.sol", "r") as file: simple_storage_file = file.read() print(...
0
votes
0answers
6 views

How to use MintableToken, PausableToken, DetailedERC20 functions in open-zeppelin v4.4.2

I am trying to Create Token and Initial Coin Offering Contracts Using Truffle + Zeppelin Solidity. so i installed openZeppelin , truffle , node js , and solidity. The following veresions of these ...
0
votes
1answer
10 views

using SafeBEP20 for IBEP20

I created one token which is based on BEP20. I am writing another smart contract, where I will be using this token, and want to perform some action like transfer, transferFrom, etc. As I understand, ...
0
votes
0answers
3 views

How to deal with funds lost to rounding errors in DeFi protocols?

What are the different methods that DeFi protocols use to handle rounding errors? For example say I have an ICO contract that returns 1/1e10 of the ICO token per ETH, so if you deposit 1 ETH(1e18 wei) ...
0
votes
0answers
8 views

Audited ERC 20 token contract

I'm going to be launching an ERC 20 token, and I want the ERC 20 token to have an additional transaction fee of 1.05% on it. For example, if a person swaps 1 Eth for a token, I'm going to have an ...
0
votes
1answer
14 views

Recovering a deployed contract after my computer restarted

I am new to writing contracts so I appreciate any help you can give. I wrote a contract with Remix and then deployed it on the Rinkeby network. I have received a contract address so I know the ...
0
votes
0answers
4 views

What are the legal implications of reusing unlicensed smart contract code published on Ethereum? What if that code uses licensed open source code too?

Almost all smart contract Solidity code will inherit licensed open source code but may not include a license for the novel code. What are the implications of inheriting all this code into a new smart ...
0
votes
1answer
12 views

What am I doing wrong? cannot compile

Hi for some reason i keep getting this error, while trying to compile, im using a code I found in forums, but i seem not to be able to understand why it doesnt compile, what am I missing?. Thanks.
0
votes
1answer
14 views

How to populate a large amount of data into a mapping of struct

I'm working on a Game into Solidity and I want to be able to populate metadata into my smart contract to be able to access them directly from game-play functions. So I have a basic ERC721 to start: ...
0
votes
1answer
8 views

DeclarationError : Only constant variables are allowed at file level

i just start learning the solidity and smart contract and i got this error DeclarationError : Only constant variables are allowed at file level this is my code : // SPDX-License-Identifier: MIT ...
0
votes
1answer
17 views

Difference between Contract-level metadata and tokenURI in OpenSea?

What is the Difference between Contract-level metadata and tokenURI in OpenSea? Is the Contract-level metadata mandatory in OpenSea integration?
0
votes
1answer
11 views

ParserError: Expected ',' but got '}'

I saw similar questions, but my problem is not matching any of those answered questions. I've written a function in a library that also includes in-assembly code but getting an unexpected parser error....
0
votes
0answers
7 views

How to decode input field from transaction in Golang?

I have the abi and the input data as shown here https://lab.miguelmota.com/ethereum-input-data-decoder/example/ I want to get the output. How can I do this in Golang?
0
votes
0answers
11 views

how to add pending balance of address in solidity?

This contract is betting:https://testnet.bscscan.com/address/0xD6fDB5bB014b593fdb6793D6ce07403698e404eA#code The problem is when the prize is allocated to those winners for claim, the allocation is ...
0
votes
1answer
18 views

contract code size to big

Good day, i have maded a smart contract but it seems to be to big i have maded some libaries such as context ownable safemath but i still keep the same message can someone mayby explain me how to ...
1
vote
1answer
16 views

Burning ERC-20 tokens like BNB USDT etc with solidity

is it possible to implement burning of ethereum tokens such as USDT","BNB","USDC" for example, using solidity. Should I just send it to zero address and pass its value in wei? ...
0
votes
1answer
15 views

How do I let memory array return the actual length of the value?

I want to create a fixed array(w*h), w*his the maximum size, and when the condition meet(checkOwner(_temp) == msg.sender), the data(_temp) will store into the _array. My question is if only few ...
-1
votes
0answers
8 views

How to withdraw BEP-20 tokens from my website smart contract

I made a smart contract for my web app where users can send BEP-20 tokens, now I am facing a problem in withdrawal, I already have a function for withdrawal in my smart contract which is not working, ...
0
votes
0answers
5 views

Is there a way to upload a ERC-20 Binance smart change on Uniswap?

Sorry if this a basic question, but i have a serious doubt. Is there a way to upload a ERC-20 Binance smart chain token on Uniswap and what is the process to make it? I'd appreciate your help and ...
0
votes
0answers
13 views

Web3 and Smart Contracts usage

Hello everyone! I'm the new one in the blockchain stack and I would need some help to understand some technical details about blockchain, web3 etc. I've read some theoretical parts and have tried to ...
0
votes
1answer
14 views

Add arguments to get request

I'm trying to make a get request using the chainlink node. I'm following this tutorial this tutorial but the problem is that this is sending a request to this specific URL https://min-api....
0
votes
0answers
9 views

Storing data in mapping vs array for structs which are identified via index

I am writing a smart contract which will store structs within a dynamic array, something like this: struct MyStruct { uint256 data; } MyStruct[] array; These structs do not hold a unique ...
0
votes
0answers
6 views

BSC-Testnet Contract verification Fails: Error! Unable to generate Contract ByteCode and ABI

I've been struggling with this with different methods. As the most straightforward, I tried manually-flattening the code in REMIX, and verifying it on bscscan. Compiler version OK, Runs for ...
0
votes
1answer
11 views

How do I get a random enum?

enum Heroes { batman, superman, spiderman } Heroes hero = uint8(random % 3); Error: Type uint8 is not implicitly convertible to expected type enum Heroes. How do I get a ...
1
vote
1answer
4 views

How to get a contracts emitted events in brownie?

Say I have a contract that emits multiple events, how do I to get a list of all events emitted in brownie and sort them by event type? contract SimpleContract { event Deposit(address indexed ...
0
votes
0answers
27 views

How to get "dna" from the metadata file of a ERC721 token in Solidity

here is the context, I would like to be able to burn n ERC721 token based on the "dna" and the attributes "type" in the metadata (see below): { "dna": "602472F&...
0
votes
1answer
9 views

Javascript testing vs remix

So what would be the benefit of testing the smart contracts using javascript with truffle instead of remix? I just feel is really tedious. I'm guessing there is a reason, but I don't see it, so should ...
0
votes
0answers
7 views

How to mimic abi.encodePacked in ethers?

I've got some data that I need to pack into a single bytes variable. In solidity, it looks like this: uint16 id = 42; address creator = '0x...'; uint256 amount = 1337; bytes memory message = abi....
0
votes
0answers
11 views

How to find LP Tokens contract code to import

I add liquidity to Uniswap v2 (rinkeby) with myToken and ETH and got some LP Tokens (UNI-V2 ERC2-0). And I'm going to connect to LP Token's function transferFrom(). How I'm understanding I have to ...
0
votes
1answer
14 views

Calling a solidity function without a wallet using ethers.getDefaultProvider

I am trying to call a function from my solidity contract which shows how many nfts have been minted so far, I want the front end user to be able to see the number even if they don't have a wallet in ...
0
votes
1answer
7 views

How to delay sending a transaction in brownie?

Say I have a contract that has a method that implements a time expiration via a function parameter set by the user, how can I test that the expiration works as expected in brownie by delaying the ...
0
votes
0answers
31 views

ERC721 contract deployed to mainnet gives enormous minting fees

I'm experiencing some weird behavior of the ERC721 contracts on the mainnet. I developed two very simple contracts using OpenZeppelin that are based on ERC721, ERC721URIStorage, and ERC721Enumerable. ...
0
votes
1answer
15 views

Logical negation, conditions on struct, mappings

I'm still playing around with my first bigger smart contract, and I'm creating something like public sale, ICO, etc. Now I'm at the point where I want to specify some conditions like: one address can ...
0
votes
0answers
14 views

Some questions about BlockChain (ETH, BTC)

Guys i'm a super newbie in blockchain and similar stuff so I got even dummier questions that i'd like to have answers to. This is mainly connected with the Ethereum Network, but if your instances and ...
0
votes
1answer
20 views

Can't kick off the function which contains reference to another contract's function

I'm trying to test function (stake) which contains reference to another contract function (transferFrom). But when I test it I have a mistake. But MyToken has deployed and has address to hardhat ...
1
vote
1answer
25 views

Why is compiled bytecode about 10x larger than Solidity code?

I'm busy optimising my Solidity contract and I noticed some behaviour I don't understand. When I add the following two getter functions: function getBaseReward() external view returns (uint256) { ...
0
votes
0answers
14 views

Transfer condition modification

I am trying to add a condition that when the token is sold, change the fees to 7, in case it is a purchase, leave it at 1. Would the code shown be correct? In any case, what would be the best practice?...
0
votes
0answers
7 views

What are the gas costs for type casting or conversions?

I frequently cast unsigned integer types (e.g. uint8) to signed integer types (e.g. int24), this requires 2 casts first to the unsigned type (e.g. uint24) then to the signed type (int24). I know I ...
1
vote
0answers
9 views

zk-rollups library

Is there already a zk-rollups library that can execute contract code? I read about zkSync, Aztec, STARKWARE, polygon etc. But they are only for token transfert and none execute contract code.

1
2 3 4 5
259