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
2
votes
0answers
15 views

1) “before all” hook: prepare suite for “ ”

I am trying to create an Integrated test (to test multiple smartContracts working together). I re-initialize them inside beforeEach() function. So I get the clean test for each test case. I have done ...
1
vote
0answers
12 views

Inline assembly function parameter has same name with local variable

contract Test { function f() public returns(uint r) { uint x = 100; assembly { function f(x) -> y { y := add(x, 1) } r := f(100) } } } Use ...
0
votes
1answer
18 views

How can I use the payable function to transfer fixed ether in a transaction?

contract MyContract { address payable[] recipients; function sendEther(address payable recipient) external payable { recipient.transfer(1 ether); } } Error- transact to ...
1
vote
1answer
22 views

Visibility for constructor is ignored. If you want the contract to be non-deployable, making it “abstract” is sufficient

What does this warning actually mean and how to resolve this ?
1
vote
1answer
16 views

ParserError: while parsing a block mapping

This is the code in my brownie.config.yaml file: # exclude SafeMath when calculating test coverage # https://eth-brownie.readthedocs.io/en/v1.10.3/config.html#exclude_paths reports: ...
0
votes
0answers
20 views

How should I reset a user's password?

So I'm making a dapp. This portion uses smart contract for login. I need to add the ability to reset the user's password if they forget it. contract Auth { struct Credentials { string fullName; ...
0
votes
1answer
14 views

How Can I Add Functionality to my ERC 1155 Token? (If needed) [closed]

I'd like to create my ERC1155 token to start my crowdsale, but I also want the token to be utilized on my music web app. Allowing for artists to craft their own nfts or buy/sell from each other with ...
0
votes
0answers
10 views

Prediction Market (result publishing issue)

I am trying to create e prediction market where people can contribute in predicting (which side is going to win?) by spending Ether, but unfortunately i am getting error ("Error: invalid ...
0
votes
1answer
8 views

Storing constants in Storage vs Creating a view function? (Solidity 0.5.17)

So, which would be gas efficient? Reading a storage variable in a state-changing function? OR Reading from a pure function in a state-changing function? Example: contract Test { uint256 public a = ...
1
vote
0answers
10 views

Accessing a public mapping from a deployed Ethereum Contract

I'm trying to get my Contract to interface with the already-deployed CryptoPunksMarket Contract, seen here: https://etherscan.io/address/0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb#code Specifically, I ...
0
votes
0answers
14 views

How to realise function on Solidity? [closed]

Task: Write 1 function that takes two arrays (addresses and number tokens) and give mint for each address in the array, such number tokens, which is specified in another array. Example: _mint (...
0
votes
0answers
5 views

How are view/pure functions handled in upgradeable contracts?

I have read through some standards regarding upgradeable contracts like EIP-1538, EIP-1822 and EIP-2535, and it seems most of them rely on the proxy pattern where a proxy/storage contract with a ...
0
votes
0answers
48 views

Transactions on BscScan don't add up

I'm creating a web application for which I want to log transactions specific to a single wallet and a single token on the BSC network. I would like to do this programmatically by using the bscScan API....
1
vote
1answer
24 views

Incorrect Product of BigDecimals

My solidity function emits an event with a uint256 of: 5060584000000000000000000 The problem is on the truffle side in my javascript test. Here is the code: const { BN, expectEvent, constants } = ...
0
votes
1answer
12 views

declaration error identifier not found or not unique

pragma solidity 0.7.4; contract MyToken { address public minter; mapping (address => uint) public balances; constructor(){ minter = msg.sender; } function ...
0
votes
0answers
18 views

Faster send to address than using metamask in BSC

Is there a way to send faster transaction (some BNB) than with metamask for example using: Quiknode Ankr
0
votes
0answers
9 views

Connect MetaMask with Ganache

unable to connect MetaMask with local blockchain(Ganache) Chrome Console Error truffle-contract.js:425 Uncaught (in promise) Error: Contract has not been deployed to detected network (network/...
1
vote
0answers
14 views

Getting a Parser error for one of my contracts

I'm getting the error: "ParserError: Function, variable, struct or modifier declaration expected. --> CurrentERC721.sol:1393:1: | 1393 | contract ERC721Pausable is ERC721, Pausable { | ^^^^^^^...
1
vote
0answers
17 views

Decoding signature for verification not working

I'm trying to verify a signature, but when I decode it, the function reverts. This is the function I'm using function source(bytes memory signature) public returns (bytes32 r, bytes32 s, uint8 v) { ...
1
vote
0answers
11 views

how to write a Withdraw function from my contract contract

So I am new to solidity and I want to add a withdraw function to the attached smart contract so that when i call the withdraw function it will give me Eth / token in the contract. Link to smart ...
0
votes
0answers
20 views

Is ERC1155 an overkill if all NFTs are going to be unique?

Within the use-case I'm trying to define an ERC1155 for, I do not foresee to use duplicates for the same token. However, I would like to be able to have this option if such a necessity arises. Is ...
1
vote
0answers
13 views

How to give an array in storage value from an array from a function's input parameters

Below is the code that I have: struct Cow{ uint age; uint name; } Cow[] cows; // this is the code I am trying below. function createCows(Cow[] memory _cows) public { cows =_cows; } When ...
0
votes
0answers
11 views

How to use OpenZepplin hooks to cancel transfer if condition is not met?

I am experimenting with OpenZepplin Hooks to modify ERC20 transfer functions in this way contract IToken is ERC20 { .... function _beforeTokenTransfer(address from, address to, uint256 amount) ...
1
vote
1answer
18 views

ProviderError: max code size exceeded

I am trying to deploy an upgradeable smart contract on bsc testnet using hardhat. But after running npx hardhat run --network testnet scripts/deploy.js it gives me the following error. ProviderError: ...
0
votes
0answers
10 views

definition of base has to precede definition of derived contract

I have two different files which are Project1.sol and Project2.sol Project2.sol is like: import "./Project1.sol"; contract Project2{ address newProject1Address =address(new ...
0
votes
1answer
11 views

Is it possible to have nested proxy call in solidity?

I want have a design that allows me to change the implementation contract by only call upgradeTo() on 2nd layer proxy once. However, when I call real implementation function on 1st layer proxy, It ...
0
votes
1answer
16 views

How to allow each voter to vote only once? [Very Simple Voting Contract]

first, I apologize for this very very very simple question. I'm starting my studies on smart contracts, and after many attempts, I have not been able to solve this problem. Objectively, this is a ...
0
votes
1answer
18 views

Why a user can't just call the token contract for transfer and not the marketplace?

I have maybe a weird question. But let's say there is contract of T (token ERC721) and contract of M (marketplace). The marketplace has a method .buy which does a transfer of a token to the buyer, ...
0
votes
1answer
17 views

How to loop over soft deleted items on contract?

I have a smart contract that contains posts. Let's say that it's a twitter-like dapp. Contract Blog { struct Post { string content; bool isDeleted; } mapping (uint256 => ...
0
votes
2answers
34 views

Truffle Deployment Error: has no network configuration for its current network id (97)

I'm having an issue deploying a contract with Truffle. The contract constructor takes 7 parameters which are all within the 2_deploy_xxx.js file. However, every time I do, I get an error when I get to ...
0
votes
1answer
9 views

memory declaration in solidity returns

I have a simple question about solidity memory declaration: It both return bytes data in following two cases, but one needs to have memory keyword and another does not. I am a bit confused about the ...
0
votes
1answer
14 views

need help with erro code in smart contract

ParserError: Expected a state variable declaration. If you intended this as a fallback function or a function to handle plain ether transactions, use the "fallback" keyword or the "...
0
votes
0answers
54 views

Deploying Smart Contracts to Binance Smart Chain (Test) [closed]

I was wondering how I can deploy a smart contract like Safemoon to Binance Smart Chain over Remix or from local computer. What are the steps and what I need for it? Thanks in advance
1
vote
0answers
17 views

Alternative to EIP1167

I have an EIP1167 factory contract on Polygon that I'm going to use to trigger the deployment of custom ERC20 tokens. Once deployed via the factory I want to map the tokens on Polygon's bridge in ...
0
votes
0answers
27 views

Gas estimation failed on BSC Testnet

I've got the following error when I'm trying to deploy my token on BSC Testnet. Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want ...
1
vote
0answers
17 views

NFTs with fractionalized ownership and royalties in perpetuity

Is it possible to code an NFT-compliant smart contract which has the following properties? There are multiple owners instead of just one Royalties are paid out to all owners in perpetuity, across all ...
1
vote
2answers
14 views

What is the problem in sellToken function? Transaction reverts whenever i call that function

This is my solidity // SPDX-License-Identifier: none pragma solidity ^0.8.0; interface ERC20 { function totalSupply() external view returns (uint256); function balanceOf(address account) ...
1
vote
0answers
216 views

Fail with error 'Min return not reached'

I am trying to make trades on 1inch and frequently get an error that reads Fail with error 'Min return not reached'. My gas prices are set very high because I need these trades to be as fast as ...
0
votes
1answer
12 views

BSC token , time delay tax

I’m trying to have a rolling tax on a coin based on the amount of time since the last buy I’m realizing that bots are buying and selling and scalping market cap due to low defi tax. So what I’m trying ...
0
votes
0answers
12 views

Get the value of the mapping and array from solidity to javascript

I have this dummy contract. How can I get the value of the whole Positions array and mapping positionIdsOf in plain javascript? contract DummyContract{ mapping(address => uint256[]) public ...
0
votes
0answers
37 views

How To Copy And Paste Token Code

i want to copy and paste this code and use it for my token just want to change symbol and everything . https://bscscan.com/address/0xf38acb6cea8f6701b06ec759f6cbc3fe23f377d3#code i try to post code ...
0
votes
0answers
13 views

Calling the fuction GetEthToTokenInputPrice

Please help since I'm getting furious over this problem. I deployed a contract to the ropsten network, and am trying to call a function getEthToTokenInputPrice to see if it worked through solidity. I ...
0
votes
0answers
41 views

{ code: -32000, message: 'invalid sender' } - Truffle deployment with Infura endpoint to Rinkeby

I am having trouble with deployment of a project contract to the Rinkeby network using @truffle/hdwallet-provider and an Infura endpoint. Here is the code for deploy.js: const HDWalletProvider = ...
0
votes
0answers
14 views

How do you deploy a smart contract to GoQuorum?

I have a set of smart contracts that I have compiled and deployed to rinkeby test network. I now need to deploy the to a private goquorum blockchain that runs on the IBFT consensus. The blockchain was ...
1
vote
0answers
15 views

What is best practice for adding a fee to charge for a function call?

I am trying to create a function that charges a user for calling the function. I came across an old example here and I am wondering what the currenct best practice is? Add a transaction fee for each ...
0
votes
1answer
19 views

Why the sender is not approved? (v0.8)

I have the following code: import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract Collectioning is ERC721 { ... address ownerAddress = ownerOf(_tokenId); address payable pSender ...
0
votes
0answers
7 views

Who pay gas for multi-sig tx? Is this customizable?

This is clear that msg.sender is gas payer for general transactions. But, in case of transaction having multi signatures, who is the actual gas payer? Please let me know if the following options are ...
0
votes
0answers
6 views

GSN relay transaction call not being allowed to happen

Rejected relayTransaction call - should not happen. Reason: {"code":-32000,"message":"gas required exceeds allowance (0) Getting this error, wondering if I'm missing ...
0
votes
0answers
18 views

How to interact with a contract from another computer [closed]

I had deployed a contract (BSC), however the computer I deployed it on is no longer accessible to me. I have my wallet backed up and setup on the new computer, however I cant seem to interact with the ...
0
votes
1answer
17 views

How to use this code? [closed]

How to use this code as mine. I tryed its compile well but unable to deploy its have many contacts cant understand which one will be deploy. https://bscscan.com/address/...