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

How to check if swap was successful?

This is a part of my payable function that is causing a problem. What happens is we receive Eth and swap it to a specific token. It works great in testnet. But on mainnet the "require" check ...
0
votes
0answers
11 views

Getting the same hashes on the web3 and Solidity side

How can I repeat this operation on web3.js and get the same hash function test(uint a, uint b) pure public returns (bytes32) { bytes32 hash = keccak256(abi.encodePacked(uint40(a), b); return ...
1
vote
2answers
24 views

Brownie - Constructor Sequence has incorrect length, expected 1 but got 0

I am trying to deploy a contract on Rinkeby by running brownie run scripts/deploy.py --network rinkeby but I get following error: Constructor Sequence has incorrect length, expected 1 but got 0 I ...
0
votes
0answers
12 views

How To Call The Smart Contract Function Automatically on specific time? [duplicate]

I am working for a client to create a lottery contract. But my problem is that I am new to solidity. I have successfully created the lottery contract and it's working as expected. here is the contract....
0
votes
1answer
19 views

How would you prevent someone calling a public mint function?

Sorry if this question is silly, I'm still learning. My smart contract has a function which mints a token and is owned by the caller. I set it as public so it can be called externally through web3js. ...
0
votes
0answers
15 views

ProviderError: The execution failed due to an exception while deploying ChainlinkPriceFeed

Iam re-deploying Enzyme-Protocal smart contract in kovan testnet Git repo link It has a ChainlinkPriceFeed smart contract and it takes [ fundDeployer.address, weth, ethusd, primitives, aggregators, ...
0
votes
1answer
17 views

Referencing common array in multiple mappings

Trying to understand memory in blockchain for sharing reference of array as common storage for multiple mappings. Let's say there is a need for following relationships. So there will be products keep ...
0
votes
0answers
13 views

Possible to have variable value for ERC721 instead storing on IPFS? And how to retrieve all mapping value?

contract GalaxyExplorer is ERC721Enumerable{ struct Land { string name; address tenant; uint256 x; uint256 y; } struct Planet { string name; ...
0
votes
0answers
8 views

Only use ASCII strings in solidity?

So I know that strings are UTF8 by default. However, that comes with its set of problems, like taking more storage. Is there a way to only allow ASCII in my contract?
0
votes
0answers
9 views

transferFrom error

Am I completely losing it here? function transferFrom(address from, address to, uint256 value) public returns (bool) { require(value <= _balances[from]); require(value <= _allowed[from]...
0
votes
0answers
9 views

ERC20 approve attack: may its success be dependent on mainer decision about transaction order?

My question is related to the possible attack vector on ERC20 contracts described here. This attack effectively boils down to these steps: First transaction (mined): Alice calls approve(addressOfBob, ...
0
votes
0answers
24 views

send token from current smart contract in solidity

I am writing a smart contract, but there is an issue, the scenario is: my smart contract should send the specified amount of a token(which is already deposited into the current smart contract) when it'...
0
votes
0answers
7 views

Why was memory keyword used in this example

I am doing the cryptozombies.io course on Solidity. In Chapter 7 of Making the Zombie Factory, it introduces function declarations. The instructions on this chapter are: Create a public function ...
0
votes
0answers
9 views

What purpose of merkleProof in contract?

I found a ABI list of this contract in bscscan: 0x16fb38712d355833647f4adfb1f6ff80f289c203. I dont know what is the purpose of _merkleProof parameter as below and what value that I can pass for it? { ...
0
votes
1answer
15 views

how can i invoke function each 5 minutes using react?

how can i invoke pickVoters() each 5 minutes using react? import React, { Component } from "react"; class Pick extends Component { static async getInitialProps(props) { const { address } = ...
1
vote
0answers
20 views

What happens when you pass more gas than what is available?

When making a contract call in Solidity, the gas stipend can be altered with the following special options: {value: WEI_VALUE, gas: GAS_VALUE} What happens when the GAS_VALUE is bigger than what is ...
0
votes
1answer
22 views

web3.js:3 Uncaught ReferenceError: require is not defined

I've been confused by the web3.js all day. I created the web.js for setting and initialize Web3, and it appears the following message: And I install web3 by npm install web3, the version of web3 is 1....
0
votes
0answers
5 views

Bonding Curve Contract with an intended formula

It's been weeks that i am trying to find a up to date bonding curve contract and modify its formula to my intended one ===> Price = A + B * ( total Supply^2 ) ====> or in other words ===> y = ...
1
vote
0answers
17 views

Does a proxy contract need to declare state variables?

There is no variable declaration in the proxy contract. Does the returned data from the delegate call auto-generate the variables for the proxy contract? contract Logic { uint256 varA; ...
0
votes
0answers
15 views

Apply stock logic for ERC20 tokenomic

For my ERC20 tokenomic, i have an idea that it can apply shares split like stock, because when user hold some token and when they are splitting, it make them feel that this token can growing up more ...
0
votes
0answers
15 views

creation of NewToken errored: Internal JSON-RPC error. { "code": -32000, "message": "execution reverted" }

I am trying to deploy a new token contract to BSC testnet and hitting this error message. creation of NewToken errored: Internal JSON-RPC error. { "code": -32000, "message": "...
0
votes
1answer
10 views

Why does it not return the value?

// SPDX-License-Identifier: GPL-3.0 pragma solidity >0.4.22 <0.7.0; contract WhileLoop { uint8 number=1; function retrieve() public returns (uint8){ while(number !...
0
votes
1answer
9 views

Setting Correct Liquidty Lock Value

I am looking to deploy a test contract and want to know what values i should enter to set the liquidity lock to either 7 days and 30 days. I need to input a numerical value in uint256 format. Can ...
0
votes
1answer
30 views

How to test if contract is receiving ETH

I'm desperately trying to find an answer as to how I can accurately test my smart contract balances, as not only can I not get the test to return the correct balance number, but I also am not seeing ...
0
votes
1answer
28 views

How to convert in-memory static array to calldata static array?

I have a contract called Erc20Recover in which I have the following function: pragma solidity >=0.8.0; contract Erc20Recover { function _setNonRecoverableTokens(IErc20[] calldata tokens) ...
1
vote
1answer
18 views

How can I create a smart contract using another smart contract?

I want to create a smart contract which I can link to my website using web3.js and create input fields for creating a contract using the main contract and I can set the fees also which should go ...
0
votes
0answers
8 views

How to test in local, a contract if call an AMM contract?

I'm trying to test a smart contract but i have inside of my contract a call to PancakeSwap and i would like to test it, but i dont find what is the good way to do it: i have to mock router´s contract?...
0
votes
1answer
18 views

How to get Hardhat to log a returned variable rather than the entire transaction receipt? (Test written in TypeScript)

I have a function, fn(), in a contract that returns a variable. I am then testing said function's returned variable value in a Hardhat unit test written in TypeScript. However, when I console.log the ...
0
votes
1answer
13 views

transaction and logs order

I'm building a blockchain game and in order to speed things up, I am also building a web application so users will read data from there. so at first, I was thinking to listen to events and save their ...
0
votes
0answers
16 views

How to create Proxy from a smart contract

I would like to create a smart contract which serves as based to issue proxy, basically I would like to do the following: https://github.com/OpenZeppelin/workshops/blob/master/02-contracts-clone/...
0
votes
1answer
33 views

Solidity contract - Best way to airdrop a single time a user

I've got this very simple Airdrop contract below: contract ERC20 { function transfer(address _to, uint256 _value)public returns(bool); function balanceOf(address tokenOwner)public view ...
0
votes
0answers
10 views

Using react how to invoke a function each 5 minutes? [closed]

I'm writing app using react and web3 for solidity contract and in one of my functions I need to invoke itself each 5 minutes .. plz any help ..
0
votes
1answer
9 views

Difference between token transactions number and same token smart contract transactions number

On Etherscan the token analytics of the contract (https://etherscan.io/token/0x799a4202c12ca952cb311598a024c80ed371a41e) shows the total 1991 transactions while the same token contract (https://...
0
votes
1answer
10 views

What's mean from expression InterfaceName(0xABCD.....) , oxABCD is an contract address?

Here is an example i see in cource code off bunny finance https://github.com/PancakeBunny-finance/Bunny/blob/main/contracts/vaults/venus/VaultVenusBridgeOwner.sol#L52
0
votes
0answers
8 views

CompilerError: Stack too deep, try removing local variables on remix

i have add another wallet( marketing)... after adding i am getting this error " CompilerError: Stack too deep, try removing local variables. (uint256 rAmount, uint256 rTransferAmount, ...
0
votes
0answers
6 views

What are difference between inheritance,polymorphism,encapsulation,abstract and interface in solidity

I studied solidity ,I understand the remaining parts of solidity except inheritance , polymorphism , encapsulation , abstract and interface very confusing always see usage of A a = new A(); access by ...
0
votes
0answers
4 views

does reorg change a order of state update?

if some of my calls to contract update state in order and reorg happen at blockchain does that alters state update order? ex: value = 0; addone() -> value = 1 // reorg happen and this update to ...
0
votes
1answer
12 views

No contract at given address

I deployed a contract on a private network and it worked but all of a sudden it stopped working for reads only writes still succeed. I get no contract at given address. Below is my call of the ...
0
votes
0answers
16 views

is transaction can be cancelled after event raise on binance smart chain or Ethereum?

I am creating backend which monitor events on BSC and make cross chain tx. but I heard that transaction can be replace or cancelled before confirmed. so in my case does anyone make tx -> event get ...
0
votes
0answers
4 views

remix parse error: function, variable, struct or modifier declaration expected

I am getting a parse-error from the remix compiler: function, variable, struct or modifier declaration expected. I need help in figuring out how to fix this error. pragma solidity 0.6.0; pragma ...
0
votes
0answers
7 views

How to test library functions that work on storage string[]

I have a library for string array handling functions that has functions like: function deleteAt(string[] storage, uint pos) {...} It's meant to be run inside a contract which has a state var of string[...
0
votes
0answers
10 views

Transfer functionality is not working, execution reverted

the transfer functionality of my token is not working. i can not transfer token to another address. it give me this error:"code": 3, "message": "execution reverted", ...
0
votes
0answers
9 views

MetaMask not showing ERC-20 amount in Transaction - Only showing ETH gas fee

Im experimenting with sending my custom ERC-20 token with MetaMask to my contract. Im using react.js for a simple front end. I press a button which creates a transaction from my metamask account for a ...
0
votes
0answers
11 views

Failed tx/swap, 5 UNI in limbo, no Transfer Event Emitted. How to get UNI unstuck?

I attempted to swap 5 UNI for 40something SHI3lD. Tx failed, execution reverted but UNI wasnt sent back. 2nd Tx: 5 UNI for 41SHI3LD was successful. But I thought the 2nd would use the missing 5 UNI ...
0
votes
2answers
32 views

Cant pass large uint in react.js (2**256-1) into solidity approve function

I am trying to call a simple approve() to allow my contract to spend my tokens. Trying to make the amount argument = (2**256 - 1) however I am getting the below error message every time. Unhandled ...
0
votes
0answers
14 views

Hardhat ethers fail to deserialise enum output of a function

I think @nomiclabs/hardhat-ethers fails to manage Enum type of output of a contract when testing it locally. solidity version 0.8.7 hardhat version 2.6.4 Contract.sol contract Contract { enum E { ...
0
votes
0answers
23 views

How to decode input for tx sent to zero address (contract creation tx)

Decoding transaction input data requires providing ABI. How can I decode transaction input from a transaction issued to "zero" address? This special address is used for creating new ...
0
votes
1answer
16 views

Importing Existing tokens on blockchain!

I'm trying to create a Farming smart-contract. I'm completely new to solidity so i want to know if there's a way i can import an existing token from the blockchain, then call methods on that token's ...
0
votes
1answer
23 views

Allowance in a smart contract

I have a smart contract that takes in tokens. I was curious if those tokens owned could be added to the allowance of another owner? When they submit the tokens, I verify allowance and transferFrom. ...
0
votes
1answer
13 views

ERC721Burnable TypeError: Definition of base has to precede definition of derived contract

I'm getting an error due to Burnable but it's not even in my contract. @openzeppelin/contracts/token/ERC721/ERC721Burnable.sol:12:46: abstract contract ERC721Burnable is Context, ERC721 ...