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
1
vote
1answer
970 views

“couldn't decode uint8 from ABI: 0x” when returning a large fixed array with web3

I'm trying to return a fixed size array. It works fine with a uint8 array of up to 360000 or so. I've only tested on the rinkeby testnet so far. I've tried increasing the gas limit for my call but ...
1
vote
1answer
7 views

Instantiating a smart contract in Uniswap using assembly and create2

I am studying Uniswap source code and there is something I do not understand in this file: https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol: This factory can ...
0
votes
1answer
7 views

how does library end up in contract?

library C { function a() public returns (uint) { return 15; } } contract A { function a() public returns (uint) { return C.a(); } } This is the code I am using. I ...
0
votes
0answers
9 views

Transfer token failed due to Gas estimation failed

Have issue transfer token, hope to get support from this. my contract https://rinkeby.etherscan.io/address/0x6D96673922d54108e8eFaFDe191Dc473dCeE709B pragma solidity ^0.5.0; import "github.com/...
0
votes
1answer
20 views

SushiSwap Fork reverting at createPair()

I have forked sushiswap recently from the repo. I am getting the following error when calling createPair() from UniswapV2Factory.sol during my deployment, the code has not been touched and I have no ...
0
votes
0answers
7 views

how do i call a constructor from another constructor?

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint supply) public { // ...
0
votes
0answers
14 views

Is an ERC721 Burn event to send ERC20 tokens to that owner possible?

Trying to burn a minted ERC721 token and have the contract transfer to that owner a number of ERC20 tokens deposited beforehand to the ERC721 contract address. However I get a Remix JavaScript Vm ...
0
votes
1answer
268 views

Multiple addresses initialization in constructor function

Usually we have one address initialization in constructor function. And that address becomes owner of the contract. While studying erc721 token and going through several examples online i found ceo ...
0
votes
1answer
11 views

Passing Object to smart contract's payable function

I'm developing a contract where I should be able to pay multiple user's addresses. I'm using TRON blockchain. I can use the TRONIDE developer API to send funds. But they recently shutdown their API ...
0
votes
1answer
570 views

How to access data stored in Ethereum Blockchain using Smart contract?

I want to write solidity contract which stores hash table as mapping(uint => string) documents data structure in ethereum blockchain. Now, each time I run a function "storeDocument" in this contract,...
2
votes
1answer
91 views

Truffle test: how to get the block number of deployed contract?

In my test I would like to get the block or block number of when the contract was deployed. const instance = await MyContract.deployed() const contractDeploymentBlockNumber = await instance.?
0
votes
1answer
17 views

Returning a dynamic array of structs

I'm trying to return a dynamic array of structs created on the fly from storage data, similar to how we return ViewModel from DB data in MVC. What is the best way of doing it in Solidity? Tried ...
0
votes
0answers
8 views

Fetching an inputted contract address's token price

I'm looking to fetch the inputted tokenAddress's token price, from say a uniswap eth pair, and return it. Any idea how to do this? contract Initialise { using SafeMath for uint; mapping(...
2
votes
1answer
96 views

Reentrancy attack not working on mainnet, but working on ropsten and remix VM

I was fullfilling a reentrancy attack on a contract. I tested it in remix VM first and later on with deployed contract on ropsten testnet. Both worked well without any errors. On the mainnet it turned ...
1
vote
1answer
13 views

Declaring function with the same name but different arguments in a derived contract

What happens if one declares a function with the same name as a function in a base contract, but with different arguments in a derived contract? How does it behave with different combinations of ...
1
vote
2answers
85 views

Supply gas from contract to execution of function

let's say I have something like this function usuallyCheapFunction() external { ... do something cheap... if(rareCondition == true) { expensiveCleanupFunction(); } } function ...
2
votes
1answer
145 views

Token Swap From Ethereum Host Network To Different Blockchain

What is a good way to swap tokens from the Ethereum host network to a different network (i.e. the Tron blockchain)? Would the best way to do this be to have a smart contract where ERC20 token holders ...
0
votes
1answer
23 views

Smart Contracts for the Blind Auctions

In blind auctions from solidity documentation what value should I insert under the bid function?Even I inserted string value,integer value under the bid function but it is showing the error as invalid ...
1
vote
1answer
30 views

ERC20 optimization

I am studying popular Ethereum smartcontract's source code and there is something i do not understand on ERC20 standard. Let's took this example: https://github.com/OpenZeppelin/openzeppelin-contracts/...
0
votes
0answers
9 views

Why does my web3 not execute this smart contract function?

Good day, I am busy with a small project trying to call a buy() function on an Ethereum Smart Contract. This Contract is found on the Ropsten Test Network here:https://ropsten.etherscan.io/address/...
2
votes
2answers
451 views

How do I use filter EVM log events by an indexed field in web3j?

I've looked through the documentation, but there doesn't seem to be this scenario listed. What I want to do is filter the Ethereum event log of a specific contract by an indexed field with Web3j. ...
1
vote
1answer
165 views

Want to Access remote dai smart contract in another smart contract

I want to transfer Dai tokens from account1 to account2. My account1 has 50 DAI tokens. Kovan Dai contract address given by makerdao is: 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa. What I am doing ...
1
vote
1answer
221 views

Can't call function from contract using web3.js due to gas issue

I'm building a smart contract and dapp using ganache and web3.js. In my smart contract I have a function (named "add_pilot") which gets 4 parameters and add them to a mapping. It looks like this: ...
0
votes
2answers
23 views

Uniswap V2 Router, Factory on Rinkeby testnet

Is it possible to use Uniswap V2 router on rinkeby? What is the contract address of a router? i found only factory contract address ?
3
votes
1answer
850 views

ERC223 Token Fallback Function Usage

I'm currently writing the "Trade" smart contract which is similar to "Crowdsale" smart contract. The only function that I want to add is "sell" function. In general Crowdsale smart contract is used ...
0
votes
1answer
909 views

Can not verify contract on etherscan.io “Error! Unable to generate Contract ByteCode and ABI”

I am getting the error "Error! Unable to generate Contract ByteCode and ABI" When I try to verify this code. I have split it into two pieces as I import it but not sure how to include it all in ...
2
votes
2answers
543 views

Deploying a contract that calls a contract

What is best practice on deploying a contract called within another contract with web3.js? I have previously gone under the assumption that the contracts must be mined separately, and the caller must ...
1
vote
1answer
678 views

Invalid number of arguments error for getter function with no passed arguments

I am receiving this error when trying to call the getUsers getter function from the contract below: Invalid number of arguments to Solidity function. Running on Truffle in develop mode. mapping (...
0
votes
0answers
20 views

Solidity contract: How to deal with return parameters in solidity

i am having an issue with an function I would like to call. Following case: The function looks like this: Params Type token0 IERC20 token1 IERC20 amount uint256 parts uint256 flags uint256 and ...
0
votes
1answer
17 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: ...
1
vote
1answer
11 views

registerInterface and parent constructors in Solidity

The openzeppelin ERC721.sol file contains the following code: constructor (string memory name, string memory symbol) public { _name = name; _symbol = symbol; _registerInterface(...
0
votes
0answers
24 views

Ethers.js testing: Giving hardhat generated accounts ETH

Deployment √ Should set the contract's address as owner (44ms) √ Should assign the totalSupply of credits to the creditsContract (114ms) Transactions 1) Should fail if sender ...
1
vote
2answers
921 views

MyAdvancedToken Automating Selling and Buying function not working

I attempt to create a token with the "automatic and selling" function as describe here. After having copy/paste the code (footpage)and deployed the contract no error message appears. But when I ...
3
votes
1answer
417 views

Loop with optimal gas usage

I currently have the following loop (some stuff left out) mapping (address => uint) pendingWithdrawals; function example () private{ address[] tempList = List; for(uint k = 0; k < ...
0
votes
1answer
13 views

What happens if there is no fallback function in solidity?

Here is the short definition about fallback function in solidity: Solidity fallback function does not have any arguments, has external visibility and does not return anything. What happens if there ...
0
votes
0answers
9 views

“Revert: VM Exception while processing transaction” while trying to swap with 1Inch

since a while I am trying to program a swap contract for 1Inch. The problem is that I always get a Revert message when trying to call the function. I made sure that the contract has enough funds from ...
0
votes
0answers
3 views

Truffle testing:How to convert from Mocha to Solidity

I am following the tutorial at: truffle- Mocha It shows a mocha code for testing. I want to do the testing in Solidity. const SimpleContract = artifacts.require("SimpleContract"); contract(...
0
votes
1answer
25 views

Contract pays for gas

Is there anything solidity in line that would let a contract with ETH assigned to, to pay gas. Say I want something simple. contract whatever { uint256 one; uint256 two; function execute() public { ...
0
votes
1answer
587 views

Time Specified calls in Solidity using Oraclize

I have started learning coding in Solidity and I have written the below contract using the official Oraclize guidelines. My aim is to: Make the update() function be called on its own on the ...
0
votes
0answers
8 views

Uniswap: error IDENTICAL_ADDRESSES in function swapExactTokensForETH when swapping WETH to ETH

I am using Uniswap's interface Router02 and have been able to execute all swap functions correctly with one specific exception: swap WETH to ETH. In the contract below, function swapExactTokensForETH()...
0
votes
1answer
9 views

Why chainid is done in assembly in UniswapV2ERC20

I am studying uniswap solidity source code and there is something i do not understand in UniswapV2ERC20 constructor: uint chainId; assembly { chainId := chainid } (pasted from https://github.com/...
1
vote
1answer
440 views

could not be able to change my setmessage because (Transaction has been reverted by the EVM:

I am working on react. As I have deployed my contract onto a specific address which have a following code: pragma solidity ^0.4.17; contract Lottery{ address public manager; address[] ...
0
votes
0answers
14 views

Web3 1.3 Contract method call returns empty string

I am new to solidity and I am facing a strange issue. I have created the following Contract: pragma solidity >=0.7.0 <=0.8.0; //SPDX-License-Identifier: UNLICENSED contract Lottery{ ...
1
vote
1answer
773 views

Problem with truffle console : Cannot read property 'call' of undefined

I have a problem when executing the code HelloWorld.deployed().balance.call().then(console.log) This error introduced: Cannot read property 'call' of undefined This problem is similar to this ...
0
votes
1answer
147 views

I have written a javascript code for compiling the solidity code but it's showing error

I was trying to compile my contract using solc compiler but it returning me some errors. I will place my solidity code along with the error that I am getting here. Please help me out to sort this ...
0
votes
2answers
31 views

Can you ! a modifier?

I have a modifier for a few functions that check if a mapping exists, for one function I need the modifier to verify the mapping doesn't exists, is there any way to !modifier as you would a function ...
0
votes
2answers
1k views

signing a transaction on web3js with private key and broadcasting to nodes

I am having an issue with ethereum based project. I made web3 API to communicate to the blockchain. I did this two ways. both call the same function on same address: METHOD 1 (Using Unlocked ...
0
votes
1answer
317 views

Factory Contract Function is not creating New Contract using testrpc and web3

I am new to DApp development. I have deployed a TokenFactory contract and that Factory contract has a function "Create New Token" that generates a new token contract. The function "Create New Token" ...
0
votes
3answers
897 views

How can I Airdrop tokens to multiple address

I want to distribute tokens to a few thousand addresses at once. I want to know, how can I do this? My token contract is already deployed so I want to make a new contract in solidity that can interact ...
4
votes
6answers
3k views

Doing a bulk transaction with my ERC20 token (How to do it)

I was wondering if someone has more information on how to do a bulk transaction on the Ethereum network for ERC20 tokens. Let's say I need to send 1 ethereum to 10 users or 10 ERC20 Tokens for that ...

1
2 3 4 5
188