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
7 views

implement royalty in ERC20 for ERC721 trades

When NFT (ERC-721) is traded, I'd like its minter (creator) of the NFT to receive a royalty. In order to achieve this, I've tried call ERC20.transferFrom inside of ERC721.transferFrom -> it ...
0
votes
0answers
4 views

Should I test the flattened ERC20 contract in truffle?

I have an ERC-20 contract that I have deployed successfully on the Rinkeby testnet. I have also successfully verified the contract so that I can interact with it on Etherscan. I am learning Truffle ...
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 ...
1
vote
0answers
16 views

Deploying multiple contracts (.sol files) to one contract address

As an exercise, I am trying to deploy a large contract that is greater than the 24kB limit imposed by the Spurious Dragon hardfork. So, I am looking at Uniswap V3 as an aim and my goal is to deploy a ...
0
votes
0answers
10 views

Algorithmic complexity of abi.encodePacked

What is the algorithmic complexity of repeated string concatenation via abi.encodePacked? Specifically, if we have m strings s_i for i in [1, m], each of identical length n, is abi.encodePacked(s_1, ...
0
votes
0answers
5 views

Should I replace public variable calls with event listeners?

I am writing a contract that has an array or entrants. Currently, in web3, when a user enters I call contract.methods.enter().send(..) and it updates this array. I then call contract.methods....
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
7 views

How to check malicious code if it's safe to connect wallet to website?

The source code of this website doesn't show the contract address being interacted with when someone connects their Ethereum wallet to their site. Would like to check the underlying Solidity code of ...
0
votes
0answers
12 views

how to add two arrays in solidity smart contract

I am taking two arrays and i need to add them in solidity . is this the correct way ? // SPDX-License-Identifier: MIT pragma solidity 0.8.10; contract Types { // Declaring state ...
0
votes
0answers
9 views

Remix - Parser Error on pragma 8.11

I am using the newest version of pragma. 8.11 creating a contract for a token. I am getting a parser error at the bottom line stating expected pragma import directive. Can anyone help I feel like i ...
0
votes
0answers
7 views

Use OpenZeppelin with clean Python

as i failed to use Brownie framework with Flask (i have another question about this matter on the forum Working with Brownie scripts using Flask), I am currently trying with plain Web3 and python to ...
1
vote
0answers
4 views

Max amount of coins I can trade to a certain slippage

I want to calculate in solidity and uniswap dex the max amount of coins I can receive before touching 5% slippage with 0, 1 and 2 hops (or at least, approximately). For example, suppose I want to ...
0
votes
1answer
22 views

Help with a smart contract.Solidity

I am trying to make a simple smart contract where you can create a car. It creates a new contract that allows you to change the name of the car. I would like only the mechanics to change the name of ...
0
votes
0answers
4 views

How to encode bytes array for deployed contract compiled with solidity 0.4.x

I need to interact with deployed proxy contract compiled with solidity 0.4.23. The simple function declaration is: function execute(address _target, bytes memory _data). I have a interface for that, ...
1
vote
0answers
6 views

Working with Brownie scripts using Flask

My projects is built like this: React frontend -> Flask server to interact, save to SQL etc.. -> Brownie project. Now when trying to use a script from brownie in my flask file: from ...
1
vote
0answers
24 views

i want to make a time based transaction using solidity in smart contract

i am creating smart contract for lottery system and i am stuck on a problem, i want to make a time based transaction like a certain amount of players are added into the array then a time stamp should ...
0
votes
0answers
12 views

Web3 related jobs

I am looking for job opportunities in the web3 space. May I know what are some areas/ websites where I can find such jobs? Would greatly appreciate some help here. Thanks!:)
0
votes
0answers
3 views

Solidity chainlink/AggregatorV3Interface decimals() returns number 8 always

Hi i am learning Solidity and trying to get token price using chainlink/AggregatorV3Interface.I get it but when i try to get exactly price with decimals it returns 8. this is my contract pragma ...
1
vote
0answers
16 views

While writing a test using dapptools, how do I send a transaction as a specific wallet address?

I'm playing around with dapptools: dapp And I want to write a test that checks the gas for OpenZeppelin's ERC721 implementation of the transferFrom(..) function. Here's my test: // SPDX-License-...
1
vote
1answer
14 views

What is the most gas efficient way to initialise a struct?

Say I define a struct named MyStruct and a local variable called myStruct, what is the most gas efficient way to assign/update 1 or more fields/members of myStruct? If I wanted to assign a new value ...
0
votes
1answer
16 views

calling ERC20 function from ERC721 throws an error

I am calling ERC20.transfer inside of ERC721 contract. I have no problem in compiling and migrating it, but when that line of code is executed, metamask is throwing an error. Here is my code: The line ...
0
votes
0answers
19 views

How to access different contracts with same name in Truffle

I deployed three contracts where the contract itself is same but the parameters are different. const Token = artifacts.require("Token"); module.exports = async function (deployer) { // ...
0
votes
0answers
28 views

How can I fix a ValueError revert transaction on a sniper bot that reverts only when triggered by an event(PairCreated)..otherwise swap goes through?

THIS IS A BOT TO SWAP ON UNISWAP WHEN NEW PAIR IS CREATED BUT WHEN BUY FUNCTION IS TRIGGERED BY AN EVENT THE TRANSACTION REVERTS BUT BUY FUNCTION GOES THROUGH WHEN TESTING JUST THE buy() ...
0
votes
0answers
8 views

What happen when using Multicall if 1 call failed?

If I batch multiple transfers in Multicall and 1/2 transfers failed. Does it mean the entire transaction failed (no state changed)? or partial state changed?
0
votes
1answer
11 views

Can solidity Smart Contract written in higher version interact with another deployed smart contract written in older version?

Does it work? is there any gotcha that we need to watch out for?
0
votes
1answer
15 views

ParserError: Expected '(' but got identifier

I really can't figure out whats wrong with this function, its probably something stupid but I can't see it. Thanks. function duplicatefinder(mapping exists, uint256 intermediate, uint256[] ...
0
votes
0answers
14 views

Transfer Function Doesn't Pass Funds Onto Receiving Address

When transferring Ether using the transfer function in Solidity, the funds are sent out of the sending address and are received by the contract address, as expected. However, instead of being passed ...
1
vote
1answer
17 views

Unable to construct hash from address and uint256 for ecrecover and signature verification

I am creating a signature with web3.js form a hashed message that contains two numbers and an address: const tokenIds = [1,2,3]; const state = 1; const messageHash = web3.utils.keccak256(tokenIds....
0
votes
0answers
10 views

HELP! Accidently Deleted Remix Work Space

I accidently deleted a workspace in remix and cannot figure out how to get it back! my token launches in two weeks!
1
vote
1answer
11 views

Is it more gas efficient to declare variable inside or outside of a for or while loop?

In solidity does declaring a variable inside a while or for loop result in that variable being redeclared during each loop iteration? And if so does that make it less gas efficient than say declaring ...
0
votes
0answers
57 views

How to fix PancakeLibrary: INSUFFICIENT_INPUT_AMOUNT?

I'm trying to make a multiple swap function in my smart contract using solidity. For example we want to swap BNB->BUSD->USDT->ADA->BNB. The contract interacts with PancakeSwap. I deployed ...
0
votes
1answer
18 views

How can I divide with multiple decimals

I am running into some issues trying to convert this equation into solidity friendly code x * (0.933333 + y/z/3.75) I've tried converting values in the following way, but end up w/ incorrect results. ...
0
votes
0answers
9 views

Python Brownie: Import statement does not import solidity contract when run from python

I am trying to run the below script from python but it does not find the ADAI contract that I just compiled. It works fine when I do brownie run scripts/interact.py from the command line. Looks like ...
1
vote
1answer
14 views

Parser error expected " but got indentifer

constructor( address _DEMO, address _principle, address _treasury, address _DAO, address _bondCalculator ) { require(_DEMO != address(0)); DEMO = _DEMO; require(...
0
votes
0answers
7 views

Beyond ethereum stackexchange what are the other good resources for asking questions regarding truffle, ganache-cli, babel and solidity?

Beyond ethereum stackexchange what are some good resources for asking questions regarding truffle, ganache-cli, babel and solidity? Starting working on blockchain development need information on good ...
0
votes
1answer
33 views

Minimum and Maximum Values Returned by keccak256

In the statement: uint256 x = uint256(keccak256(abi.encodePacked(valuesToEncode))); What’s the minimum and maximum possible values for x? When I looped random valuesToEncode the smallest resulting ...
0
votes
1answer
12 views

What is the best practice when importing Contracts

I will try to clarify my questions with visual aid. The picure above is how I usually import contracts. For example, I import Both C and B contracts to A, even though B already imports C too. ...
0
votes
0answers
50 views

I get "There was a problem processing your request" when buying or accepting an offer on OpenSea

I made my own collection of NFTs on OpenSea and I'm trying to buy or accept offers. The network I'm using it Polygon (Mumbai). The problem is, that there's no way, or at least I couldn't find a way, ...
0
votes
1answer
19 views

What is the meaning of this arguments in this curly brackets

Pls how do i interprete this argument in this curly brackets marked in red. I'm a beginner in solidity programming and I am have a hard time interpreting this arguments and what does the arguments ...
0
votes
0answers
15 views

Solidity error basic programme

I am not able to find the error to this problem Can anyone please help me with it It is showing that hasDeceased function is having some error... Not able to access the function ...
0
votes
1answer
16 views

Ways to invoke contract methods

I'm just starting learning development on Ethereum. So far I created a couple of local projects using truffle / web3js / react-native. Right now I started solving exercises on https://ethernaut....
0
votes
0answers
17 views

TRANSFER_FROM_FAILED Adding New Pool to Uniswap

I created a new ERC20 token and I'm trying to create a new pool ETH pair with my token on Uniswap V2. However, when I get to the last step on Uniswap and press "Add" it doesn't do anything. ...
1
vote
1answer
24 views

what does ERC721 _checkOnERC721Received do?

function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to)....
0
votes
1answer
14 views

How do I pay functions in remix?

I am making an NFT vending machine. Here's the code: // SPDX-License-Identifier: MIT pragma solidity ^ 0.8.10; contract VendingMachine { address payable internal vendingAdmin; struct item { ...
0
votes
0answers
15 views

When you deploy a smart contract that uses a library, does the entire library get deployed?

I'm taking a Udemy course on Solidity. I'm learning about libraries and wondering about the cost, in gas, of deploying a smart contract that uses a library? Is the entire library that is called ...
0
votes
1answer
35 views

How to get token id from NFT contract

I have created an NFT with the help of openzeppelin wizard. I got the following response on mintable method. token.safeMint('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'http://wplugins.localhost/...
0
votes
1answer
22 views

Calling a function unsing Web3 - External or Public

I have this function in the smart contract: function _mint(address account, uint256 amount) external onlyOwner { require(account != address(0), "ERC20: mint to the zero address"); ...
0
votes
1answer
32 views

How to add a fee for each swap

I'm making a small NFT tool and I'm having troubles calculating the fee and making the user pay for it, the fee itself is 0,10% and I want to apply it to each time the function createMarketSale is ...
0
votes
2answers
25 views

What is the disadvantage of allocating a new memory array as a way to dynamically increase its size in Solidity?

Since dynamically increasing in-memory arrays is not allowed in Solidity, I thought about creating a helper method like the below to create a new array with one more element every time I wanted to ...
0
votes
0answers
14 views

Fullfill randomness type error when Importing chainlink functions

Trying to inherit the randomness functions into my main contract(lottery). Getting a type error and I can't work out why. Tried all sorts. Is there a better way to inherit or import chainlink ...