Questions tagged [contract-development]
Questions regarding the development of smart contracts
4,661
questions
0
votes
0
answers
4
views
Not able to fetch correct APY in aave mumbai
I am following this doc - APY and APR - Developers to fetch lending and borrowing rates in mumbai for usdc but they doesn’t seem to be correct and are different from aave staging UI, how can I solve ...
0
votes
1
answer
9
views
Calling Uniswap Multihop Function returns Error
Deployed on Polygon Mumbai. Code compiles fine on REMIX and is meant to perform multihop swaps on Polygon Mumbai, but it returns error after function is called.
Deployed Contract always funded with ...
0
votes
1
answer
12
views
What will happened to my WETH TOKEN if the receiver or the network didn't support WETH TOKEN
I send WRAPPED ETH to a wallet/network which is COINS PH WALLET that has supported ETH ADDRESS, i thought WETH and ETH are the same? Now my problem is how can i possible retrieve my TOKEN?
0
votes
0
answers
6
views
The function runs external, but not internal
mapping(string => mapping(uint256 => Order[])) buyOrders;
mapping(string => mapping(uint256 => Order[])) sellOrders;
function placeBuyOrder(string memory stockName, uint256 price, uint32 ...
0
votes
1
answer
23
views
Methods not appearing when printing contract but do appear on Etherscan
I have a goerli testnet contract you can check out here. I'm trying to call executeFlashLoan using a javascript function using web3js, but the code acts as if the function doesn't exist. However, it'...
0
votes
1
answer
14
views
How can I get a defi site source code?
I'm trying to expose a defi scam website which copycats a famous platform on TRX blockchain. I have their transaction address, but no source code or website's contract address. I was wondering if ...
0
votes
0
answers
45
views
Anti Sniper / anti Snipe Bot for newly listed token on pancakeswap
Can Somebody explain how to have Bot Protection enabled against sniper bot for a token contract which is going to launch on pancakeswap or on any other decentralised exchange.
do we have to create ...
-1
votes
0
answers
30
views
Need help writing up a smart contract [closed]
As part of a larger project, I need help implementing Shamir's Secret Sharing algorithm in Ethereum and IPFS. I am an UG engineering student and have just got out of a month long stay in the ICU due ...
0
votes
1
answer
32
views
Is nonce necessary to prevent signature replay on smart contracts if the method is idempotent?
I have a smart contract in which only I can submit transactions through onlyOwner modifier. If users want to interact with the contract, I make the users sign the parameters of the method and verify ...
0
votes
1
answer
14
views
How to build a 3 contract structure with delegatecall
I'm looking for help to build an intermediate contract using delegatecall. My challenge would be with 3 contracts.
I need contract A to be the owner of Contract B, and contract B to have a ...
0
votes
1
answer
37
views
How can this contract buy and sell a token multiple times in one transaction?
I have discovered a contract that can buy and sell multiple times within the same transaction. How does that contract work, and where can I find this contract? Thank you.
https://etherscan.io/tx/...
0
votes
0
answers
3
views
The WETH / 4 2.0 pair already has liqudity on Uniswap V2. You cannot create a presale for this pair as the price is already set
The WETH / 4 2.0 pair already has liqudity on Uniswap V2.
You cannot create a presale for this pair as the price is already set. So how do I get my tax token to market, And if my token or contract ...
0
votes
1
answer
9
views
provider.broadcastTransaction is not a function
I'm trying to call a contract function on the avalanche network. However I'm running into this error. Interestingly, the transaction goes through on hardhat network however fails on a evm testnest (...
0
votes
0
answers
21
views
How to find the data sent to create a new Smart Contract
I am currently learning Solidity & Blockchain development. Came across an instance, where a new ERC20 Token contract was created from a front end App. While checking the Contract, I found a bunch ...
1
vote
1
answer
44
views
How to call smart contracts in Web3j
I wrote this code in TS using web3 library:
// ABI = my deployed SmartContract as json ABI
const daiToken = new web3.eth.Contract(Abi as AbiItem[], smartContractAdress)
const smartContractFunction = ...
0
votes
1
answer
9
views
new release of ERC1155SupplyUpgradeale has compilation issues
The new contracts lib from OZ, specifically ERC1155UspplyUpgradeable
has compilation issues before even inheriting it in any child contract (check screenshot below) any idea why? or how to fix it?
...
1
vote
1
answer
75
views
Is there any way to get historical pool data by interacting with the pool smart contract?
I am wondering if there is a function in smart contract pools to get historical data (just last 100 bars for example).
thanks guys!
0
votes
0
answers
3
views
Requirement for running node on etherum
i'm planning to run a node to do some works for learning such as snipping token, decode transaction from mempool in real-time which low latency?
I just wonder which configuration that i need to do ...
0
votes
4
answers
54
views
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Returned error: {"jsonrpc":"2.0","...
0
votes
2
answers
45
views
Call a function from another contract, entirely determined by initial contract's function arguments
I would like to have a contract MainContract that can call any other contract functions depending on arguments given a MainContract function. It would look like this:
pragma solidity 0.8.16;
contract ...
1
vote
0
answers
24
views
How to fix `Invalid callback object specfied` error when deploying a smart contract?
My smart contract:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
contract Inbox {
string public message;
constructor (string memory initiialMessage) {
message = ...
0
votes
1
answer
51
views
NFT transfer to a contract in ERC1155 standard
NFTS transfer from minter to contract isn't working, below is the detailed problem.
NFT.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.19;
import {ERC1155} from "@openzeppelin/...
1
vote
0
answers
39
views
Issue creating pair on IUniswapV2Factory (sepolia)
I have the following interfaces in my contract file:
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface ...
0
votes
2
answers
41
views
Transaction gets reverted when using send web3 function
I have a basic smart contract that sets the hash of a string and retrieves it along with verification. The contract works perfectly fine, but the issue is with the .send method of web3 that reverts ...
0
votes
1
answer
13
views
how to chech the address that buys the highest amount on a contract
What is the process for identifying the address that has made the largest purchase amount within a specific contract?"
0
votes
0
answers
14
views
Asking too much gas fee for transaction, Returned error: theta RPC returns an error
I have deployed my contract on theta mainnet. It was working fine for few days but now it is asking too much gas fee for transaction.
I am using web3 "v1.3.1" on server side nodejs
0
votes
0
answers
11
views
Is it possible to pay gas fee for transaction from contract? [duplicate]
I have created function for consumer to deposited balance into contract, My goal is to deduct gas fee for purchasing subscription from his/her deposited balance as same as subscription is deducting ...
0
votes
1
answer
41
views
I want to pay gas fee from contract, Is it possible? [duplicate]
// here is my contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
...
0
votes
1
answer
129
views
error: "Transaction has been reverted by EVM"
I'm fairly new to Solidity and coding overall. I'm going through a Udemy course and I ran into an error which I can't find the solution for.
I deployed a contract on the Sepolia test network from ...
2
votes
1
answer
194
views
Failed to parse as type `uint256`: a character is not in the range 0-9
I am following Patrick Collins Smart Contract Lottery development and trying to run the deploy script test net ( sepolia ) but I am getting this error
Error:
Failed to parse as type `uint256`: a ...
1
vote
1
answer
32
views
NFT smart contract review
I wrote an NFT smart contract based on OpenZeppelin documentation, I request you to review this smart contract and tell me if it is safe, complete and in terms of writing is clean and professional.
...
3
votes
2
answers
51
views
Are storage variables tightly packed like struct fields?
Tight variable packing is a known coding pattern in Solidity for saving gas by placing struct fields that are lower than 256 bits closer to one another.
Does this logic apply to storage variables? ...
0
votes
2
answers
37
views
How to call public view functions from Contract in a local hardhat node forking a public network?
I have a Hardhat project with a sample storage contract.
There are 2 functions:
Public view function
Public write function (creates a transaction)
My Hardhat project forks an Ethereum mainnet public ...
0
votes
2
answers
29
views
How do you calculate the number of tokens that are worth 1 eth before swapping in Uniswap pool?
I want to make a function for my token contract that allows me to swap a dynamic amount of tokens in exchange for 1 eth.
Is it possible to calculate how many tokens are worth 1 eth and then swap with ...
1
vote
0
answers
27
views
How is the derivation of the Constant Product AMM formula of Uniswap?
I was researching about Uniswap v1 and I found that the code is using the following formula to get the amount out of a swap:
Formula:
Reference to code
Everyone says that this formula is derived of ...
1
vote
2
answers
170
views
Remove the element from array where order matters?
I am presenting my use case here. Let's think of a dating app where each candidate enters their preferences and we store their data and add them to an array. when someone enters that matches with any ...
0
votes
1
answer
26
views
How do you use the Diamond Pattern for escrow upgrades?
I am creating a contract with the diamond pattern so I can evolve and add new features to my contract.
Contract facets:
Contract A: an ERC721 that takes care of minting its own NFTs
Contract B: ...
1
vote
0
answers
16
views
Is there any way to read block attestation from inside a solidity smart contract?
Are there any precompiles, or any other native ways to get block attestation data from ETH2 POS inside a solidity contract?
1
vote
1
answer
104
views
Where to place special functions receive() & fallback()?
receive() external payable {
fund();
}
fallback() external payable {
fund();
I want to find out where exactly should these special functions be wrriten; should they come before the contract ...
0
votes
1
answer
39
views
Can I edit in the msg.sender value for the called contract?
let's assume following solidity contracts:
contract EntryPointContract {
address one = '0x...';
address two = '0x...';
address delegateContract;
constructor(address ...
1
vote
1
answer
22
views
How to call a function from a separate contract
I have a already deployed contract and it has a withdraw() function.
And i want to create another contract that first send some ETH to the target contract and then call the withdraw() to withdraw ...
0
votes
1
answer
55
views
Is there any way to mint an NFT with metadata without passing URI in mint?
I want to create an application that receives a contract address and create a frontend for other users to mint the NFTs from that contract. But I don't have any metadata for that contract, could this ...
1
vote
1
answer
93
views
Optimizing Gas Costs in Solidity Smart Contracts: Best Practices?
I'm working on a Solidity smart contract and I'm concerned about the gas costs associated with its execution. I want to optimize my contract for gas efficiency to save on transaction fees and improve ...
2
votes
1
answer
103
views
Error encountered during contract execution [execution reverted]
I am trying to execute the method "withdrawICOFunds" but I am getting an error in Mainnet. In Goerli works ok
Any idea what's wrong?
Transaction failed: https://etherscan.io/tx/...
0
votes
1
answer
37
views
Auto generating a solidity based smart contracts
I have recently built a Custom UI and integrated it into a jupyterlab notebook environment. This UI helps the data owners define the sharing policies on the basis of the carefully chosen constraints, ...
1
vote
1
answer
36
views
Is using a mapping as argument scalable?
Is a function with an argument that is a mapping scalable in terms of gas?
If too many elements are added in this mapping, would it become problematic for the protocol?
Example:
mapping(uint256 ...
0
votes
2
answers
187
views
Error: gas required exceeds allowance or always failing transaction in Remix
Im trying to deploy my NFT contract and works fine but only if i mint less then 1000 nfts. When i tried to raise up to 2000, 5000, 8000 and even 10000 i got the gas exceeds allowance error. Can some ...
1
vote
1
answer
45
views
where does the problem of this transaction come from?
So i've been working on a smart contract and im trying to perform a swap on uniswap using polygon mainnet but im struggling to get it to work, This is the solidity code im using:
// SPDX-License-...
1
vote
1
answer
47
views
mint NFT for contract address. it is possible to mint nft by passing contract address?
we have 2 contracts which is deployed on Bsc network. the first contract is NFT Contract and the second one is Gataway contract were we accept payment and currency swaps Please find below code
Nft ...
1
vote
1
answer
42
views
How to calculate make precision calculations with very small ETH amounts?
In the given scenario that I have the following code, in which a user sets a token amount and an ETH amount, I want to determine a price of token using the following code:
pricePerToken = (ethAmount * ...