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

Difference between address.code and type(Contract).runtimeCode in solidity

Can anyone please clear my doubt about the difference between address.code and type(Contract).runtimeCode in solidity. Shouldn't they be same.
0
votes
1answer
16 views

How can I call contract which created from another contract (In TESTING)?

Hello guys now Im testing my contract, but I dont know how to call contract which created from another contract, If someone did it please help) Create I mean like following code. function ...
0
votes
1answer
15 views

Call function in event callback

I have a contract that sends an event when the transaction is done. In my React/Web3 application, I'm listening to this event and when it's triggered I would like to run another function. My code ...
1
vote
1answer
102 views

TypeError: Member "toString" not found or not visible after argument-dependent lookup in uint256

im having a big trouble trying to resolve this problem. Maybe anyone here can help me find it. This is the .sol contract and im having this error: TypeError: Member "toString" not found or ...
0
votes
0answers
6 views

best way to delete or clear nested mapping?

How would I clear/reset this mapping of mapping? mapping (address => mapping (address => bool)) nomineeApprovals
0
votes
0answers
26 views

Refund gas fee Solidity

I have a solidity smart contract function which can only be called by the owner (onlyOwner modifier). A Node.JS app calls this function, it has the owner wallet mnemonic, and the function executes. ...
0
votes
0answers
11 views

How to listen for events in a well-known contract (Compound cDai) called by my contract

I don't know how to debug the situation where I wrote a contract (MyDeFiProject) which calls a well-known contract developed by someone else (in this case Compound cDai on Rinkeby). The transaction ...
0
votes
1answer
25 views

Handling transactions fees when using Chainlink

I have a smart contract which must reach out to an off-chain data source (custom API) in order to verify that the wallet calling the function can do so. My understanding is that this is done via a ...
0
votes
1answer
41 views

How to bit shift a bytes in solidity / assembly?

I can bit shift uint_n_ easily but I don't manage to bit shift a bytes memory myBytes. When doing myBytes << i I have a compile error and when using assembly I receive 0. See my MWE for assembly ...
0
votes
0answers
8 views

Reflect.finance token-type deployment: change distribution on constructor

I am developing a token based on reflect.finance / safemoon way of work with reflections between holders, but I always reach an error when trying to distribute the initial token supply between ...
0
votes
1answer
28 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
1answer
13 views

Large array as constructor arguments fails

My goal is to pass two fairly large arrays to my constructor: constructor(AggregatorV3Interface _chainlinkFeedAddress, IERC20 _currency, address[] memory _whitelistedAddresses, uint256[] memory ...
0
votes
0answers
10 views

So, anyone can access any smart contract just by using interfaces right? [duplicate]

If true, how can I restrict access to my future contracts to only me?
0
votes
0answers
10 views

I am trying to establish the price relationship for the USDT token sale [duplicate]

I am trying to make a token price per stablecoin relationship, but it is not being easy since the ouput always returns 0 uint256 baseDivisor = 18; uint256 public priceTokenPerDai = (1 / baseDivisor); ...
0
votes
0answers
15 views

Need your help with technical realization Binance Smart Chain contract with top up and withdraw balance in both USDT and BUSD currencies?

How to create smart contract for binance smart chain, where users can top up his balance and withdraw their balance in both: USDT and BUSD currencies? But their balance in the smart contract should be ...
0
votes
1answer
32 views

Get list of all child contract addresses from contract factory in solidity

I have a factory contract with the below code: //SPDX-License-Identifier: no-license pragma solidity ^0.8.9; interface ChildInterface { function getStateVariable() external returns(uint); } ...
0
votes
1answer
16 views

Block address of a contract

In solidity we retrieve owner address by using msg.sender, 1.But how to retrieve the block address on which the contract was deployed ?
0
votes
2answers
24 views

Solidity fund transfer is redirecting to another address

I am trying to send funds in solidity using the below code / SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract SendEther { function sendAmount() payable public {...
0
votes
0answers
18 views

Logic for vesting tokens that will release tokens to each role after every 15 minutes

I need to develop Ethereum Token Vesting contract on ERC20 Token. With total supply of 100M tokens. Investor : 50M Contributor : 25M Founders : 25M Need to write an algorithm for vesting which will ...
0
votes
0answers
18 views

Hello everyone..I am trying to understand what does this mean in a smart contract (50 uint256)..someone said solidity doesn't recognize decimals [closed]

Picture of block chain contract Hello everyone..I am trying to understand what does this mean in a smart contract (50unit256)(Tax Fee). Someone said solidity does not recognize decimals and that this ...
0
votes
0answers
33 views

filter specific event by address web3js

I'm creating a betting dapp, in the smart contracts I've made an event "betPlaced" triggered every time someone is placing a bet. event betPlaced(address indexed bettor, Side indexed bets, ...
1
vote
1answer
28 views

Is it better practice to use smaller uint sizes when applicable?

My understanding of uint sizes is that smaller sizes will decrease gas costs. In my current dapp I'm building, I am dealing with time, for which it seems that uint32 will be plenty for my purposes (...
0
votes
0answers
7 views

How to see bytes in bytecode to estime gas cost of deployment

Pretty much title, trying to estimate my gas cost. I know each byte costs 200 gas. When I compile on Remix I see this object property. Is counting the number of characters in that an accurate measure? ...
0
votes
0answers
12 views

Which UML diagrams should be used for Smart contract Development?

I am a smart contract developer and I am attempting to apply the UML diagrams to the Smart Contract Development lifecycle that I am following but I am not clear as to which UML diagrams would be the ...
0
votes
0answers
18 views

How to deduct a specific percent from ERC-20 token on every transaction and send it to multiple wallets?

I would like to ask if there is a template code for the deflationary ERC-20 token that deducts 10% as a tax on buy and sell and how I can distribute this tax income to different wallets? After that ...
0
votes
1answer
32 views

BSC Flashloan getting Pancake:Locked

im trying to get a flashloan in pancakeswap - BSC, but i'm getting locked from the locked modifier in the pair: modifier lock() { require(unlocked == 1, 'Pancake: LOCKED'); unlocked = 0; _;...
0
votes
1answer
21 views

Why can't I see my updates I made with truffle test in ganache?

making my first steps in blockchain technique I picked the most simple example SimpleStorage I'm using truffle and ganache. I coded the contract simple_storage.sol: // SPDX-License-Identifier: MIT ...
1
vote
1answer
19 views

Help with using different ERC-20 tokens with my smart contract.Solidity

Hello im making some smart contracts and i would like the user to pay in stablecoin for example usdc. uint price=500; function sendUSDC() public payable { address.send(price in USDC) } I would ...
0
votes
0answers
60 views

Can't import chainlink using web3j

I am making simple contract using AndroidStudio and Java.In my contract i am using import statement: import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; but when i ...
0
votes
1answer
22 views

reverted with reason string 'Dai/insufficient-allowance' Testing

I am trying to test a simple function transferring Dai balance. test --> const [owner] = await ethers.getSigners(); const amount = await _hardhatPresaleERC20.calculateAmountTokensPurchased(1); ...
0
votes
0answers
14 views

SWC-126 Insuffixient Gas Griefing attack: why not simply requiring a successfull sub-call?

I'm trying to learn more about the SWC Smart Contract Weakness Classification and Test Cases. I'm stuck on understanding SWC-126: https://swcregistry.io/docs/SWC-126. Especially, I don't understand ...
0
votes
1answer
29 views

check if key exists in mapping of mapping

I have below data structure used in my solidity code. // map(address => map(questionId => voted)) mapping(address => mapping(uint256 => bool)) public mapUserVotes; My requirement is that ...
0
votes
0answers
18 views

How to avoid user to get metadata from non-minted ERC721 token?

I'm building ERC721 and ERC1155 tokens but I have something I didn't understand.. My Tokens represent characters with attributes, where every attributes have a different rarity. So every character are ...
0
votes
0answers
11 views

Uniswap V2: Using the "SupportingFeeOnTransfer" methods for all tokens?

Looking at the contract source code of Uniswap V2, it seems the only difference between the "SupportingFeeOnTransfer" methods and the normal methods is that the "SupportingFeeOnTransfer&...
1
vote
1answer
44 views

Does the EVM calculate the gas used for a transaction in real time?

Does the EVM calculate the gas used to execute a transaction on the fly as opcodes are being executed? So if there's a branch in code whose conditional is satisfied then additional gas is used to ...
0
votes
1answer
25 views

Stablecoin smart contract

Drop in smart contract links for ERC-20 stablecoin. There is no list defined anywhere. There should be easy to understand resources in one place for new lerners. what should be the best boilerplate?
0
votes
0answers
27 views

Error: Returned error: VM Exception while processing transaction: revert Transaction failed -- Reason given: Transaction failed

I am following a youtube tutorial for coding a smart contract for a MultiSigWallet. The code is working fine in Remix. All the functions, submitTransaction, confirmTransaction and executetTransaction ...
0
votes
0answers
38 views

Solidity: Disable Buying and Selling if CurrentPrice is below LastTransactionPrice?

Solidity: Disable Buying and Selling if CurrentPrice is below LastTransactionPrice? Disable Buying/Selling if the price (Ask/Bid) is below LastTransactionPrice? Is the LatestPrice from Chainlink the ...
0
votes
1answer
14 views

Function can send ETH without using payable?

I understand that a function must be declared as payable in order to send ETH to some address. I am trying this piece of code using Solidity 0.7.1 pragma solidity ^0.7.1; contract SendMoney { uint ...
1
vote
1answer
28 views

Math and Variables In Solidity

function cells() public { uint256 canvas = 4000; uint256 c = 1; uint256 columns = 4; uint256 x = 400000000000000000 * (100000000000000 / 400000000000000); ...
0
votes
0answers
23 views

Truffle deployment error in VS code [duplicate]

I am using Ganache and Truffle to deploy a practice smart contract from VS code. When I run: HelloWorld.deployed().then(function(instance){return instance}); in the truffle development console, I get ...
0
votes
0answers
19 views

Error came when i tried to do batchtransfert .. any help please?

hello I just add function batch transfer to my contract .. the contract deployed with successfully but when I try to do batch transfert to other address this message came in remix etherium : ...
1
vote
1answer
37 views

How to send funds to a Governor treasury?

I am working on creating a DAO using the ERC20Votes and Governor contracts. I created the governor using the wizard, however I don't see any function for adding funds to the Governor treasury. I ...
1
vote
1answer
47 views

What is the gas limit for a view function call *not made from a contract*?

So this question seems trivial but I can't find any comprehensive answer, though reading through: Is there a gas limit for view requests? Why view/pure functions need gas? Exceeds block gas limit ...
0
votes
1answer
22 views

Is the smart contract receiving funds or is it the address?

//SPDX-License-Identifier: MIT pragma solidity 0.6.12; contract ExceptionExample { mapping(address => uint) public balanceReceived; function receiveMoney() public payable { ...
0
votes
2answers
56 views

I am running my tests in the hardhat environment but it gives me 0 passing all the time

I am facing rather unusual behavior from hardhat. I have written my test cases in a file inside test folder when i run yarn teston the terminal it gives me 0 passing. Don't have any idea as to why it ...
0
votes
1answer
21 views

Have been having this error, ParserError: Expected ';' but got '}'

// SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; contract will { address owner; uint fortune; bool deceased; constructor() payable public { owner = ...
0
votes
2answers
49 views

How do nework bridges work e.g. ethereum to polygon/matic bridge

I understand what a bridge does but I 'm interested in knowing how it works under the hood. How does it work when transferring assets from one network to another. Lets take for example the ethereum to ...
0
votes
0answers
16 views

Problem with events catching in web3js

So I have a function "mint" and also I have a backend code that is listening to the contract's events. The weirdest thing is that I can catch the event "TransferSingle", but I can'...
0
votes
1answer
32 views

ABI and Contract source code is not visible on etherscan's Smart contract

I recently posted a small Lottery contract on the ethereum rinkeby network. The contract got deployed successfully however I am not able to see Contract source code and ABI on the Etherscan portal. ...