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

Can you call a variable value with web3.js, without writing the function in solidity?

I have used remix and I can see that whenever I create a public variable, it also creates a function for the variable and when you press it, it shows the variable value but, when I want to call a ...
0
votes
1answer
7 views

Interacting with Deployed contract- Truffle develop

Hoping some of you may be able to help me. I have a very simple contract that i have deployed. I won't post the entire contract here, but i will post the one function i am having trouble calling from ...
0
votes
0answers
9 views

Truffle Pet Shop Parse Error

I keep getting an error when I try "truffle compile" on the truffle pet shop tutorial. Here is my code pragma solidity ^0.5.0; contract Adoption { address[16] public adopters; function ...
0
votes
0answers
11 views

How to fork Uniswap? [duplicate]

I want to fork uniswap and change front-end styles and re-brand the Uniswap and make my own uniswap. is there any tutorial or guide to help me?
0
votes
0answers
19 views

Error in installing Remix-ide: Missing script "build"?

I want to install remix-ide on ubuntu server v18.04. I use these commands: git clone https://github.com/ethereum/remix-ide.git cd remix-ide sudo apt install build-essential npm install npm rebuild npm ...
0
votes
0answers
18 views

msg.sender and msg.value - do they work only for sent Etherum or do they work for ERC20 tokens sent to the contract too?

I'm starting to learn Vyper and I wanted to ask a question regarding msg.sender and msg.value If I created a simple contract that simply returns msg.sender and msg.value I understand that if I sent ...
0
votes
0answers
5 views

Best Way to Estimate Gas, Flashbots [duplicate]

I am writing an arbitrage bot that leverages the Flashbots bundle. For those who don't know, if you submit transaction through flashbots if the transaction revert, then you don't pay any gas. My ...
0
votes
0answers
7 views

Parser Error in Solidity 0.5.1 while running in RemixIDE [closed]

I'm getting a parser error in Solidity 0.5.1. It says Parser error: Expected ';' but got '(' in Function there() What is needed to correct a parser error?
3
votes
2answers
73 views

Why do we grant access to our funds instead of just sending them to the smart contract?

In DeFi I have seen that users are prompted to give access to their funds. Why not just send those funds to the smart contract instead? What is the advantage of this design?
0
votes
0answers
15 views

How can I get tokens out of Escrow contract to Metamask wallet?

Problem: I'm creating a dapp where users are allocated an amount of tokens and will need to withdraw them. I have three contracts: Owner: pragma solidity ^0.8.6; import "@openzeppelin/contracts/...
0
votes
1answer
8 views

How To Decode Contract When only Know Address Contract, No ABI? [duplicate]

I know the contract address. Unknown ABI . So how do I Decode that contract.. I use bytecode-decompiler in EtherScan but It only decodes Function unknow. So how to Decode the full code Contract . ...
0
votes
1answer
7 views

Error: exceeds block gas limit / transaction underpriced

When I call the function .send({ from: accounts[0], gas: "5000000000" }); and attempt to deploy my contract, I get an :Error: exceeds block gas limit." When I switch to a much lower ...
0
votes
0answers
5 views

abi from ropsten.etherscan.io site vs Truffle abi

I have initially deployed an openzeppelin upgradeable Smart Contract (SC) on my local Ganache blockchain using Truffle, referring in my Dapp to the abi that is generated to a local file (everything ...
0
votes
1answer
14 views

Storing struct with mapping inside of mapping

I have the following structures defined in my smart contract: mapping(bytes4 => Question) private questions; struct Question { bytes8[] answers; mapping(bytes32 => bool) answerers; } ...
0
votes
1answer
13 views

Issue with Harvest function - UINT256 requires BigNumber

Looking for some assistance with a contract that our Dev has left us unable to use. We're attempting to return funds to the people that submitted them using a multi sig harvest function, however it is ...
0
votes
1answer
14 views

I made the front end first

I'm creating my first app with truffle but I made the front end first... I wanted to replace the client folder with my existing react app but I noticed the App.js file has numerous functions that I ...
0
votes
0answers
9 views

dapp university youtube tutorial for a defi example

I was following along this tutorial but at this point, I tried to run: truffle compile and get this error that I tried fixing by installing via npm babel-runtime and core/js but the problem is still ...
1
vote
1answer
19 views

Do I need to remove hardhat console.log from Solidity contract before deploying?

Hardhat supports an implementation of console.log in Solidity programs. Do I need to remove instances of console.log in my code before deploying the contract? Will it waste gas if actually deployed to ...
0
votes
0answers
16 views

Let users add data to smart contract anonymously: Possible?

To learn more about smart contracts, I thought I could start by building a super simple dApp, which only does two things: Allow users (addresses) to share some random info to the contract (In my case ...
0
votes
1answer
9 views

How to a write a subsidies contract?

I am new to solidity and Trying to wrapper my brain around it; I have being Writing this contact but, I am getting an error , cannot able to Store variable in contract. Function of contracts:- _dbs2....
2
votes
0answers
20 views
+50

Testing an event with a timestamp arg

I'm trying to write a test using waffle, but I'm not sure how to assert that a timestamp is correct in an emitted event. My event looks like this: event BeginJourney ( uint256 indexed departFrom, ...
0
votes
0answers
9 views

Saving migration to Binance smart chain testnet failed using truffle

I am trying to migrate my contracts to the BSC testnet but I constantly get an error message: Saving migration to chain.Error: PollingBlockTracker - encountered an error while attempting to update ...
0
votes
1answer
13 views

Pass array name as reference to function and use it

Having 10 arrays like string[] public array_1 string[] public array_2 .... what I want to do is have a seter method where I pass the name of array and input so I can push elements to it. So something ...
0
votes
0answers
19 views

I want to learn smart contract development, no coding experience, totally new to coding [closed]

I started learning solidity a week ago, I can understand the concepts but my mind goes blank when the coding part comes into sight. I read a few articles which said I should learn fundamentals of ...
0
votes
1answer
17 views

Transfer Ownership of a contract

Someone is making me a dex and a token, and i am not sure if TransferOwnership to my erc20 address it`s enough. Token will be mintable with a mint rate/block of 4 tokens, and initial supply of 1 mil. ...
0
votes
0answers
15 views

How to send ether to call fallback function

Im currently working on a project which can create a uniswap liquidity pool on the fallback function however the transaction is not even broadcasted to the blockchain when trying to send some ETH via ...
0
votes
0answers
9 views

"ERC165" is an abstract contract or an interface and cannot be deployed

I am trying to migrate a contract of mine, which imports ERC165.sol file /** * @title ERC165 * @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md */ interface ERC165 { /** * @notice ...
0
votes
0answers
7 views

Truffle migration, how to get the deploy file on the previous migrate?

I have encountered the problem when I use truffle migration, it works fine so I deploy the contracts on the mainnet for actual use. After a while, I decided to make some changes and try to upgrade the ...
0
votes
1answer
41 views

Solidity contract to handle multiple uniswap trades and refund to sender at the end

I'm looking for a simple solidity contract that I can send tx swap data to, wether in hex or an array. Ex: send funds to contract Swap a > b, Swap b > c, Swap c > a, return funds to address I ...
0
votes
0answers
12 views

Swap ETH to DAI using ISwapRouter from Uniswap

I am trying to get started with Uniswap V3. As an example, I took the most basic use case: Given X amount of ETH do a swap to DAI. Unfortunately, I am not being able to make it work. There is already ...
0
votes
1answer
31 views

Does a view function always have access to msg.sender?

Any transaction happening on the blockchain obviously has an associated sender address, which solidity stores in msg.sender. However, if I have a view function which can be used to read the state from ...
0
votes
1answer
10 views

Trouble sending correct amount of a token with web3

i'm trying to transfer a value of 1 of my erc20 token to my contract. In my front end I am using: tokenContract.methods.approve(contract_addr, 1).send({from: accounts[0]}); In my smart contract I am ...
0
votes
1answer
13 views

Reset array to initial state (delete all elements)

I was wondering which was the appropriate way to reset an array to initial state, and so delete all the elements that it contains. I found the following ways: delete paidPlayers; paidPlayers.length = ...
0
votes
1answer
21 views

Calculate Percentage

I want to calculate user reward per day. uint256 totalBalance = 111; uint256 rewardPerDay = 1000; function calculateReward(uint256 userBalance) public view returns (uint256) { uint256 ...
1
vote
2answers
45 views

Interacting with closed source contract

I am an experienced developer but relatively new to blockchain development. There is a close source contract that I can interact with via the provider's web interface. The screenshot below is the ...
0
votes
1answer
28 views

Returned values aren't valid, did it run Out of Gas? using call function with web3js

I'm new to blockchain development, I have done some simple projects before and I had no issue in calling the functions with web3js, but now I'm trying to run a call function on a smart contract using ...
0
votes
0answers
13 views

A proxy factory does not return the clone contract address

I have three smart contracts: An abstract one: pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/AccessControl.sol"; /** * @title Base contract for state machines */ ...
1
vote
1answer
11 views

Running chainlink node on google cloud and accessing the node server as an operator

I was able to access the localhost:6688 when I was running the node server, so whenever I closed the console the server will go down, so I decided to detach it by installing sleep now the server is up ...
0
votes
1answer
5 views

compare uint from datestamp always return true

function testDate(uint date1,uint date2) public returns (bool) { require(date1 == date2,'not same date') return date1 == date2; } let res = await TestSol.testDate.call(‘1630972800’,‘1631145600’)...
0
votes
0answers
4 views

Access data part in ERC 1155 Token

I'm new to the DEFI and blockchain concepts. So spare me if this is a lame question. I am working on a project that needs data to be encoded and fed into the ERC 1155 token. I made a dummy contract ...
0
votes
1answer
8 views

Can we achieve ATOMICITY in our smartcontract transactions?

The scenario is: I have 2 smartcontracts and contractA calls the method in contractB. Lets assume a transaction is signed in one of the method in contractA which does something and then also calls the ...
0
votes
0answers
23 views

Gas Limit Drops to Zero for Internal Transaction

I've deployed a contract to Rinkeby involving a few different interfaces I've written. This result in a fair number of transactions occurring behind the scenes with different contracts. There is a ...
0
votes
0answers
24 views

Stack Too Deep error with only 5 items on stack

So, there are a lot of these questions and I've read through a bunch of them and several blog posts, but I'm still stumped on why I'm getting the error here. My function (to reproduce, copy it to here)...
1
vote
1answer
23 views

Testing for emitted events in Hardhat

I have a Solidity contract that inherits from ERC721PresetMinterPauserAutoId I want to write a test that verifies that a Transfer event has been emitted by the contract after the public mint(to) ...
0
votes
0answers
18 views

Eternal storage smart contracts

I am trying to make smart contracts with an eternal storage design. So lets say I have contract A and B: Contract A is Ownable { struct Item { uint256 id; uint256 price; address ...
1
vote
1answer
39 views

Private keys & not buffer being passed to test file

I'm running a test on a very simple pool contract. I am using Mocha to write the tests, but Hardhat's network to run them. After firing up my Hardhat node I get the 10 test accounts per usual with ...
0
votes
1answer
46 views

How to determine if a pending transaction will revert?

Is there any way to understand if a specific transaction will revert while in pending status? If so, how can I code it exactly?
0
votes
0answers
16 views

Who is the msg.sender when a library makes a call()

I have a library that is making a call to an external address like this externalAddress.call(callData) This callData is calling a function of another contract that is utilizing the msg.sender value. ...
0
votes
0answers
14 views

In this guide: https://docs.uniswap.org/protocol/guides/providing-liquidity/the-full-contract

Testing it on a mainnet fork gives me: Error: missing argument: in Contract constructor (count=0, expectedCount=1, code=MISSING_ARGUMENT, version=contracts/5.4.0) Not really sure what the problem ...
0
votes
1answer
9 views

Type tuple(string memory,string memory) is not implicitly convertible to expected type string storage

i am trying to access multiple string values, but dont know why i am getting this error? error:Type tuple(string memory,string memory) is not implicitly convertible to expected type `string storage.` ...