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

'hex data is odd-length' error occured when using web3 & testrpc

Here's my code . var Web3 = require("C:\\Users\\Administrator\\node_modules\\web3") con_abi = [ { "inputs": [], "name": "sloc111", &...
0
votes
1answer
12 views

Identifier already declared

event transfer(address indexed from, address indexed to, uint value); event Approval (address indexed owner, address indexed spender, uint value); constructor(){ balances[msg....
1
vote
1answer
19 views

Data location specification and bytes32

Why is data location not required to be specified for bytes32?
0
votes
1answer
27 views

I want to deploy my IERC20 Contract and I need few questions

If the contract is using IERC20 can I deploy it on BSC? If yes, should I do something else or simply deploy it via Remix? When I want to deploy my contract I see those options here. What should I ...
0
votes
0answers
11 views

How to pass a blank bytes calldata into a solidity function call?

I have a function that looks like this: function foo(uint _someVar, bytes calldata _data) public { ... } Then I make a call to it from another function with "" as _data: foo(123, "&...
0
votes
0answers
2k views

Cannot estimate gas error on Uniswap / Sushiswap

I'm trying to swap at Ropsten network some tokens for testing purposes, but I'm getting the following error: Cannot estimate gas. It's curious because when I transfer from one wallet to another ...
0
votes
0answers
33 views

Airdrop contract not working [closed]

I deploy this airdrop contract https://testnet.bscscan.com/address/0x25148e8f49fb8614df47e9b0d4c25dcae6b1f44f#code to send a multi-transaction of token in a short airdrop I've deployed the airdrop ...
0
votes
0answers
20 views

No data consistency between ganache and my contract's view functions

I created a solidity contract like this: // SPDX-License-Identifier: MIT pragma solidity ^0.8.1; contract Users{ struct User{ string name; bool enabled; bool isAdmin; bool ...
0
votes
1answer
28 views

Problem with deploying contract on BSC Test net

I'm new here. I want to deploy a contract on the BSC test net thru remix. The code is below. I'm running into a problem "This contract may be abstract, not implement an abstract parent's methods ...
0
votes
0answers
19 views

Parse error, newbie here, what's going on? [closed]

Remix tells me the following code below has a parse error, but no matter how hard I look, not parenthesis or comma is missing! contracts/test.sol:88:62: ParserError: Expected ',' but got identifier ...
0
votes
1answer
12 views

Verify a signature generated with web3 in solidity

I am trying to verify a signature in solidity, which I generated in my truffle test. I followed this tutorial for implementing the smart contract, but made small adjustions: library Lib { /** ...
1
vote
1answer
17 views

Do not allow to register twice

Let's suppose I have this struct: struct Agent { uint idAgent; address direction; uint[] preferences; } Agent[] agents; And there's a function: /// @notice Registra a un nuevo agente a la ...
0
votes
0answers
10 views

Need to iterate a uint 4 times? No problem. 5 times? Nope! Called function suddenly needs to be payable…?

I have a public uint variable denoting 'which round' it is and a function that advances rounds and does processing alongside the round advancement: uint public round; function ...
5
votes
2answers
117 views

Best way to list all tokens of user in Solidity

I am using openzeppelin erc721 library to create an NFT and need to list all the tokens of a user. The most obvious way is to iterate through all the tokens in the contract and check if the owner of ...
0
votes
0answers
16 views

How many smart contracts one should have?

Suppose there are 4 entities, A, B, C and D. A provides its identifier to B and seeks its decision. B needs to call C providing it with the identifier of A and some other parameters so that it can ...
0
votes
1answer
10 views

DeclarationError: Identifier not found or not unique. --> MyContract.sol:9:27: | 9 | function get() public views returns(string) { | ^^^^^

i am new to solidity....i was following a tutorial but this error DeclarationError: Identifier not found or not unique. --> MyContract.sol:9:27: | 9 | function get() public views returns(string) { |...
0
votes
0answers
8 views

DeclarationError: Identifier not found or not unique. Two contracts in the same file

This is the Contract that I want to use a function of: contract Origin{ uint transfer_amount = 0.1 ether; address payable owner = xxx; function invest() external payable { owner....
1
vote
1answer
39 views

Ethereum Solidity (smart contract) blockchain implementation for selecting a node as a miner to add the block

If I use a proof-of-work (PoW) algorithm in the Ethereum blockchain, the node selects to mine a new block is totally random as per my local implementation using Go-Ethereum and inter-process ...
0
votes
0answers
18 views

Smart contract using uniswap and transaction fee [closed]

I'm thinking of a decentralized application like Metamask that takes 0.875% fee on its swaping feature. I'm wondering how is it possible to create a contract using uniswap's swaping feature and by the ...
0
votes
1answer
15 views

What is Solidity revert code “-32000” when interacting with contracts via Remix IDE?

I wonder if the error "VM Exception while processing transaction: revert", "code": -32000" thrown by the Remix IDE indicates the 0x32 Solidity panic exception happening when ...
0
votes
0answers
5 views

In the context of Ethereum contract creation, what does “cyclic creation dependencies are impossible” mean?

I'm reading the official solidity docs and came upon this passage on Ethereum contract creation: "cyclic creation dependencies are impossible", followed by the example code below (and also ...
0
votes
0answers
9 views

How to test contract interactions without pay fee

I have my contract which interacts with two different exchanges, can i test this interaction without pay fee? Before Deploy to the main net? I know it has Ropsten but it wouldn't work i think, i need ...
1
vote
0answers
9 views

Solidity - String Template Literal

Is it possible to write a multi line string in the solidity language on the same fashion as JavaScript allows us to do so by levering back-ticks? I'd like to now an optimal way to save a long string ...
0
votes
0answers
96 views

How to withdraw ETH/BNB stuck in a contract such as this? [closed]

Please is it possible? Saw this on one of the new tokens and I was wondering since the contract keeps BNB after selling a portion on market which is 'supposed' to be added to liquidity. pragma ...
0
votes
0answers
20 views

Paying for gas (when the SC is executed) with money stored in a SC

I am starting to program my first real contract and would like to ask if it is possible to do this (something like an auction): Someone deploys a contract. Participants pay for that auction to run (...
0
votes
0answers
22 views

worl1.sol:214:42: ParserError: Expected ';' but got '{' (bool success, ) = recipient.call{ value: amount }(“”);

when i deploy it gives me this error: worl1.sol:214:42: ParserError: Expected ';' but got '{' (bool success, ) = recipient.call{ value: amount }(""); pragma solidity ^0.6.0; library ...
0
votes
0answers
15 views

Etherscan contract verification: invalid constructor arguments

I have a Proxy contract on rinkeby 0xA7Bb0CF8c00F26d1E7CbaF4020dFc9FCA2759495 and I am trying to verify and publish its source code. Normally Etherscan provides the constructor argument automatically, ...
0
votes
0answers
67 views

Unable to verify contract source code on BSC MAIN NET. “Error Exception err_code_1 Occured: ERROR - Unable to connect to the remote server” [closed]

I deployed my smart contract on BSC Main net and try to verify and publish it. However, I received this error Error! Unable to verify source code Exception err_code_1 Occured: ERROR - Unable to ...
0
votes
0answers
14 views

passing left for uint256

I'm trying to use this method: function test(uint amount) public { address(0xf5eA38B6b9644224dA1aECbC1219e8543c0689b2).call(abi.encodeWithSignature("deposit(uint)",amount)); } ...
0
votes
0answers
25 views

How can I set the price of my cake token into bnb in pancakeswap

Where can we set the price of the cake tokens so that we can easily convert bnb to cake tokens and vice versa in the pancakeswap contracts? Any help?
0
votes
0answers
15 views

calculate gas cost for transaction

this is the method that I call: function depositAll() public { address(0xf5eA38B6b9644224dA1aECbC1219e8543c0689b2).call(abi.encodeWithSignature("depositAll()")); } and this is ...
1
vote
2answers
145 views

Safemoon fork LP stops working (BEP-20)

I forked SAFEMOON a few times but I’m having the same issue over and over. FYI I have the PancakeSwap Router v2 hardcoded into the contract the the problem should not stem from that. Essentially, when ...
0
votes
1answer
14 views

Getting contract address

I saw an example about this, while was searching it on the internet. I want to deploy a new contract which is ProjectContract. However, I could not get contract address as below. I think this is for ...
0
votes
0answers
5 views

Truffle Test Error for Hello World method

I am trying a very simple test in truffle using javascript. This is the solidity method I have function helloWorld() public view returns (string memory){ return "hello world"; } And I ...
1
vote
1answer
15 views

Solidity Contract bytecode contains many 'f'

my contract bytecode which is generated by go-ethereum abigen has something like ...
0
votes
1answer
23 views

Adding a struct to mapping not working on ganache, but works in unit tests?

I have this code struct User { string name; string state; uint age; string[] recommendations; address[] following; } mapping(address => User) public users; mapping(address =>...
0
votes
0answers
23 views

Uniswap JS SDK returns invalid pair address for two ERC20 tokens in hardhat network

I create two ERC20 tokens, deploy them with hardhat on hardhat network, then create Uniswap pair, then retrieve its address with SDK's Fetcher and with my contract. Fetcher returns different address ...
0
votes
0answers
28 views

Upon deploying this token, name and symbol are not visible. Any ideas why? BSC [closed]

I have deployed a token on the binance smart chain, the token name and symbol are not visible on bscscan. I have verified the contract and linked the code to look at below. https://bscscan.com/address/...
1
vote
0answers
55 views

How to add a 2% burn and 2% redistribution to holders?

I've been compiling a project on remix.ethereum.org and would like to launch a crypto that has a burn on each transaction. Is it possible to add in just a few lines of code into the token contract ...
0
votes
1answer
22 views

How is the output of a contract call encoded?

Hi I have a proxy contract A which delegates function execution to implementation contract B using the standard OpenZeppelin code: assembly { calldatacopy(0, 0, calldatasize()) ...
0
votes
0answers
11 views

Implementing the template method pattern w/ Solidity's static types

I'm building an interface, let's call it HandlerInterface. The interface would have two implementations for starters: Erc20Handler: with a handle(uint256 tokenAmount) function. Erc721Handler: with a ...
0
votes
1answer
12 views

Transaction reverts because of this line. Why?

Inside my contract Lipsum, I have a function doStuff(uint foo_) which has the following line: result = (a * (foo_ / 100) / b); result, a and b are all uint. If I call the function, it errors out in ...
2
votes
0answers
11 views

can i use events as persisnt storage? [duplicate]

I'm building an application that is a mix of the blockchain and a centralized app. I need some way for the systems to communicate with each other, for example. Let's say you can buy some digital asset ...
1
vote
1answer
37 views

Error when migrating contracts using truffle

When using traffle deploying contracts it gives these errors: "Migrations" -- Unable to decode sender address from transaction: Incompatible EIP155-based V 38 and chain id 3. See the ...
0
votes
0answers
41 views

Contract uniswap check liquidity is added

How can i check in contract a liquidity is added to some pair and then exchange it?
0
votes
0answers
12 views

How to avoid price dump inside the code of a token

I'm planning to create my own token (Binance Smart Chaine C.) my first attempt was succesfull. But I'm trying to figure out how to avoid price dumping by whales. A Solution would be if i could adjust ...
0
votes
1answer
15 views

How to change blockreward to 100 cake tokens in pancakeswap

Does anyone know how we can set the block reward to 100 cake tokens in pancakeswap. I don't understand which variable will be changed. These are the variables in the migrations file const INITIAL_MINT ...
1
vote
1answer
15 views

Max number of tokens possible in Solidity? [duplicate]

So me and one of my friends are trying create our own token using Solidity for fun. It is supposed to have a total supply of the amount of atoms in the universe. I wanted to know if it is possible to ...
0
votes
0answers
12 views

How to use openzeppelin contracts for a specific version

Consider me a beginner to writing smart contracts. My question is, openzeppelin's contracts are using latest versions of solidity (by their repo). How do I use say 0.6 version, do they have it ...
0
votes
1answer
17 views

solidity changing 7% fee to 7.2% + decimal value

we used to set fee percent of 7% uint256 percent = 7; uint256 fee = msg.value.mul(percent).div(100); if we want to change to 7.2, how can we do this?