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

How can I store structure items in a variable

I am learning to code in solidity and stuck with view functions. I am trying to return values taken dynamically in a structure using view function. Is there a way to do it is solidity? I tried it but ...
0
votes
0answers
4 views

clone pancakeswap but it's show error Unhandled Rejection (Error)

I clone pancakeswap-frontend. when run I got above error. But I can't solve this problem. Unhandled Rejection (Error): invalid address (argument="address", value=undefined, code=...
0
votes
0answers
8 views

How to instantiate a memory-struct and assign it to a storage

I'm trying to understand the following code from the Solidity documentation: struct Funder { address addr; uint amount; } contract Crowdfunding { struct Campaign { address payable ...
1
vote
0answers
23 views

Why is storage cheaper than a memory?

Let's consider the following completely useless code (tested in Remix): // solium-disable linebreak-style pragma solidity ^0.8.0; contract MyContract { struct TestVars { uint8 a; ...
0
votes
0answers
8 views

VM Exception while processing transaction - Solved but don't know how

EDIT: I restarted truffle and migrated the contracts once again, and it worked without any errors. But, I don't know how and would love to understand this. Explanation - Owner creates an item, which ...
1
vote
0answers
15 views

Event Ordering in Ethereum

I am developing an application using solidity, web3js and eventeum. I am testing it locally using ganache-cli. I use Kafka to store all the events to process them at convenience instead of processing ...
0
votes
0answers
26 views

Transfer Failing in Solidity Smart Contract

I am calling the following function from a front-end on a Solidity smart contract, but it is not transferring the price and commission amounts properly with the call functions, although the ownership ...
0
votes
0answers
10 views

Received DeclarationError when calling other contracts file name and its function

So I created 2 contracts where the first one will be the app logic contract and the other one is the database contract. So I tried to "truffle compile" my contract but receive ...
-2
votes
0answers
21 views

What's the best place to hire Eth dev? [closed]

What's the best place to hire Eth dev?
1
vote
1answer
27 views

Get total supply of any ERC20 token in Solidity

I'm a new developper on Solidity and maybe this is a trivial question but it is a crucial point for my project. Is there any way to get the total supply of any ERC20 token (WBTC, and others) on ...
0
votes
0answers
23 views

How do I pick up Ether after Crowdsale? And other questions

Testnet: Rinkeby Address token: 0xeAD7ACF95b260E4C866a036F9E792759Ba0Ad4ce Address Crowdsale:0xf2D4B282CE60A0abBE7fb74C694A9A04087E5519 Ethers credited at the end of Crowdsale: ...
0
votes
1answer
14 views

How to use Oraclize (Provable Things) in smart contractin Remix ide ? i have a program of exchanging Ethereum to USD [closed]

`pragma solidity > 0.7.0; import "github.com/oraclize/ethereum-api/provableAPI.sol"; contract USDPrice is usingProvable { uint public price; event Log(string text); function USDPrice(...
0
votes
0answers
17 views

Division and floor rounding with 18 decimals

I am recreating a UNISWAP-like AMM and have encountered problems anytime I want to divide the balances of tokens in my pool. For example: I want to require() that tokens are deposited in the correct ...
0
votes
0answers
12 views

How to add Lock Function on solidity?

I have code for the ERC20 token which has freeze, unfreeze, lockUser & unlockUser functions. I want: When I lock someone he will be automatically unlocked after x days or, Scheduled release of ...
0
votes
1answer
17 views

The called function should be payable if you send value and the value you send should be less than your current balance. WITH NON-Payable functions

I have the following functions function balance() public view returns(uint152) { return uint152(IERC20(token).balanceOf(address(this))); } function balance1() public view returns(...
0
votes
1answer
25 views

Does revert() send received ether back to sender?

When revert() undoes all state changes, does that include sending any received ether back to the sender? For example, would both sendBackOne() and sendBackTwo() send ether back to the sender? function ...
0
votes
0answers
17 views

GSN Contract but only for one function

I'm blindly trying to implement OpenGSN in my contracts. I'm still not sure how it works. Do I need a special application running and scanning for signed messages on my computer to make it working? I ...
0
votes
1answer
13 views

Can't use Uniswap contract function 'swapExactTokensForETH'

When using Uniswap function swapExactTokensForETH() I get the following error: 'TransferHelper: ETH_TRANSFER_FAILED' Contract code: pragma solidity 0.8.0; import "https://github.com/Uniswap/...
1
vote
0answers
13 views

My contract shows a zero balance on Metamask

I just need some help on a contract I'm doing an experimental project token for. My setup as follows: Using Remix for solidity Metamask account linked Contract is using pragma ^0.4.4 (original code ...
0
votes
1answer
26 views

How to write a simple token contract which token can only be transferred within the specific geographical region?

In my use case, I want to build a local currency system with solidity. The core concept of local currency is that the currency can only be used in the specific region. It aims to encourage spending ...
0
votes
1answer
30 views

Testing Contract: Transaction has been reverted by the EVM

I am writing a testing file for my coin flip project here is the beginning of the coin flip project: contract CoinFlip { address payable player; address payable casino; uint256 public casinoDeposit; ...
0
votes
1answer
21 views

ERC20 Token Batch Send Security

I've written a function to send tokens in a batch, just wondering if this is secure, and if this is the best way to go about it (instead of using something like Token Multisender). Here is the ...
0
votes
0answers
17 views

Storing 100 million transactions in private ethereum blockchain

I want to store 100 million transactions in a private ethrereum blockchain where each transaction may be 100 kilobytes of data for verification purpose. I am considering proof of authority (POA) of ...
0
votes
0answers
34 views

Make transaction feeless solidity 0.8.0

I am trying to reward a user for typing a review: function addReview(..., address payable _to) external payable { ... // code for adding a review including check for reentrency attacks payable(...
0
votes
1answer
15 views

`.at()` function no longer available for web3.eth.Contract?

I'm following a guide that uses some web3 code written 3 years ago. I am trying to use the TimeLockedWallet.info() call to get information about a wallet. Below are my two smart contracts. ...
0
votes
0answers
22 views

NFT Token Ownership Transfer Initiation

I am developing a dapp/smart contract, where users will be able to sell/buy NFTs from each other (market). Users grant authority to the smart contract to sell any of their items on their behalf using ...
1
vote
0answers
21 views

Solidity. Pushing a struct to an array. But that struct contains an array. Copying of type struct memory[] memory to storage not yet supported

Here is my code. I need to have a "checkpoint" object that stores some information including an array of "delegations" which is another object. struct delegation{ uint256 ...
0
votes
0answers
21 views

How to optimally use map of maps in solidity?

I have the code: struct A { mapping(uint256 => uint256) b; } mapping(uint256 => A) public a; and I want to have the following code as gas efficient as possible: a[key_a].b[key_b] = a[...
0
votes
1answer
27 views

What is .div() method in solidity?

I was looking through some code and tried to understand some of the lines of code. I notice it uses .div(integer). Here is the snippet passengers[passenger].insuranceAmountForFlight[flightKey] = ...
0
votes
2answers
29 views

Solidity: Unable to insert data into Struct

Trying to store a list of struct as a mapping but unable to insert data. pragma solidity ^0.7.6; contract PayTree { address payable owner; uint public expirationTime; uint public wordValue; bytes32 ...
0
votes
1answer
27 views

Authentication between smart contracts based their addresses - Is it safe?

thanks in advance for your time and intellectual contribution. I am working on a project in which we have contracts interacting which each other. More specifically, there is a "father contract&...
0
votes
2answers
20 views

Declaration Error: Identifier already declared

I'm having a problem declaring the enum Stage. The previous declaration is here: enum stage {Init, Reg, Vote, Done} Changing the Stage name doesn't help: enum stage {Init, Reg, Vote, Done} Stage ...
0
votes
0answers
34 views

What is bsc testnet node address?

i am making a swap system. I do it on binance smart chain network. What are test nets? I examined it on the binance official page, but I could not reach a clear conclusion. What I got in the comment ...
0
votes
1answer
24 views

Problem with implementing ERC-20 interface in Solidity contract

I'm trying to implement contract which interacts with ERC-20 via interface. Code of interface was taken from openzeppelin github. The problem is that it fails any transaction which triggers contract ...
2
votes
2answers
73 views

variables is brackets ()

What's the meaning of the code, wherein the return values of a function are stored in variables which are initialized inside brackets, like the following: (bool success, bytes memory data) = _contract....
2
votes
1answer
28 views

Issues with extreme large solidity mapping

Is there any scalability problem if the number of items of a solidity mapping increase too much? For example, any problem when adding, changing or removing some item in the dataset? Or any other ...
0
votes
0answers
21 views

test return value of transaction

contractA function test() internal { stateVariable = 20; uint num = 20; assembly { mstore(0x00, num) return(0x00, 0x20) } } How do I test the return ? I am using hardhat , but i don'...
0
votes
3answers
52 views

Function _setTokenURI() in ERC721 is gone in OpenZeppelin ^0.8.0 contracts

We had the following mapping to manage the URIs for ERC721 tokens in OpenZeppelin contracts until pragma ^0.7: // Optional mapping for token URIs mapping (uint256 => string) private _tokenURIs; ...
3
votes
0answers
41 views

Adding new custom opcode to solidity

I have a problem with adding new opcode to solidity. I'm using solc (on C++) and geth(ethereum on Go). I want to add new opcode, that takes address payable, uint256, uint256, bytes memory and returns ...
0
votes
1answer
25 views

SyntaxError: Unexpected token o in JSON at position 1

Hi I am trying to deploy a contract but keep getting this error. I am new to solidity. I am running the cmd node deploy.js error message const interface = JSON.parse(compile).contracts["lottery....
0
votes
1answer
23 views

How to migrate existing ERC721 to ERC1155?

I have existing ERC721 smart contract. Is there any way to migrate from my existing ERC721 to ERC1155? Or do I have to create ERC1152 separately and assign the ERC1152 token to the new account user ...
1
vote
1answer
24 views

Storing nested array (2D array)

So I am making an ERC1155 token (for the batch mint pretty much). It is only ever going to mint NFT's (as you will see now now). I am trying to batch mint tokens and store an array for each one. So ...
0
votes
2answers
36 views

Why did this txn not transfer balance, I passed the exact same string same hex as response set in question

I called /** *Submitted for verification at Etherscan.io on 2021-02-21 */ contract m_quiz { function Try(string memory _response) public payable { require(msg.sender == tx.origin); ...
1
vote
1answer
39 views

connecting to Metamask using React.js and Next.js without having to refresh the page each time

StackShare question Hello, I am having a problem with connecting to Metamask dynamically. I created a voting website using React.js and Next.js, and was using UseEffect() to connect to Metamask. ...
0
votes
1answer
14 views

After transfered the ownership to one contract, how to transfer it to others?

Here 2 contracts: contract A and contract B If I (deployer/owner) transferred the ownership of contract A to contract B, is there any solutions that can transfer the ownership of contract A from ...
0
votes
1answer
32 views

Adding element to mapping (solidity) is not working, even if the method is actually called in the transaction

I'm currently working (as a begineer) at a project involving ethereum blockchain and solidity. In my contract I have a mapping with addresses as key and the value of an array of a FileDetails ...
1
vote
1answer
53 views

Random distribution of large amount of NFT

I'm an beginner in solidity, and with a teamate we have a project for an NFT contract. I have a contract with 5000 NFT limite (cards, and 20 specific card form a familily, each family and cards are ...
0
votes
1answer
24 views

Uncaught (in promise) TypeError: work.methods.workCount is not a function

Describe the bug I am trying to call the public variable "workCount" from a smart contract using web3 Steps to reproduce: const work = new web3.eth.Contract(ABI,Address) const workCount = ...
1
vote
1answer
27 views

Uniswap: Fail with error ‘Dai/insufficient-allowance’

I am trying to deposit kovan DAI to my smart contract by using transferFrom of the ERC20 function, but I get an Dai/insufficient-allowance. So I tried approving it explicitly and then trying to ...
0
votes
0answers
19 views

Cant receive wETH to my contract after swap on uniswap

I write a simple contract to do a flash loan from aave and interact with uniswap in it. I found out that no wETH is sent to my contract after swaping on uniswap. Transcations are here: https://kovan....

1
2 3 4 5
192