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
2 answers
11 views

How IncreaseAllowance and DecreaseAllowance function solve mitgation problem?

I was going through openzeppline code for ERC20 Token and found that While working with approve function in IERC20 interface they describe mitigation problem : Link I don't understand how ...
user avatar
  • 21
0 votes
0 answers
6 views

How to deploy Ethreum Smart Contract on Kava Testnet using kavatools?

suppose I have a contract and want to deploy it on Kava testnet pragma solidity ^0.8.0; contract MessageContract { string message = "Hello World"; function getMessage() public constant ...
user avatar
0 votes
1 answer
17 views

Calling mint function from UI causes Error minting character Error: cannot estimate gas

im testing a contract but cant seem to get it to work from the ui. the hardhat task works after adding the value property, but not sure how to implement it when minting from the ui. hardhat task: task(...
user avatar
  • 1
0 votes
0 answers
8 views

Can't Receive Payments in Remix

I am trying to run SimplePaymentChannel as shown on the solidity docs in remix. I have made some modifications to the code so that it is essentially just a transfer or money. I deploy the contract ...
user avatar
  • 1
0 votes
0 answers
19 views

ProviderError: execution reverted using hardhat deploy plugin

I am working on a mini-version of a DEX and I am using the hardhat-deploy plugin. I was trying to test my createNewPairing method and ran into this error: AssertionError: Expected transaction to be ...
user avatar
0 votes
0 answers
13 views

What is keccak256 in Solidity? [duplicate]

I’ve been having a rough time trying to understand how to use it. I know that this function takes in any amount of inputs and converts it to a unique 32 byte hash. I just don’t understand when when ...
user avatar
0 votes
1 answer
16 views

Verify that a method call is initiated from a specific Smart Contract

As my smart contract is >24k, I read that I need to break it into multiple (smaller) smart contracts. So, my current design is to have a Core contract that has all the data in arrays. This Core has ...
user avatar
1 vote
0 answers
9 views

NFT2.0 from coding point of view

Can anyone explain NFT2.0 from a coding(Solidity) point of view? or introduce a source.
user avatar
0 votes
1 answer
108 views

Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2)

I was doing the Patrick Collins tutorial and link got this error Error: invalid BigNumber value (argument="value", value=undefined, code=INVALID_ARGUMENT, version=bignumber/5.6.2) when I was ...
user avatar
  • 15
0 votes
1 answer
25 views

Why does Web3j listen to events every 15 seconds?

I use web3j in my Java application. In the smart contract, an event is defined. event sendEvent(string name); I subscribed to that event in my app. contract.sendEventEventFlowable(filter) ....
user avatar
1 vote
1 answer
19 views

How does Chainlink deal with faulty/malicious nodes?

I am trying to understand how chainlink, or any oracle solution for that matter, can deal with a node not providing accurate data. How would you detect that the data is faulty to begin with, and how ...
user avatar
  • 113
0 votes
1 answer
15 views

What is the difference between:= and : in Solidity?

I’ve been having a hard time trying to figure out the difference between “:=” and “=” in Solidity. I keep on thinking it is the same thing but I’m not sure about it. Can you please tell me the ...
user avatar
0 votes
0 answers
12 views

How would I access a variable defined in solidity from my `JS` script

I am trying to write test for a function addPerson() that takes stirng name and uint256 favNumber and creates a People object and add it to the people list, this addPerson() is defined in Solidity and ...
user avatar
0 votes
0 answers
9 views

storage to storage value type assignment

pragma solidity 0.8.15; contract DemoStoragetoStorageValueTypeAssignment{ uint stateVar1 = 20; uint stateVar2 = 40; function getUInt() public returns (uint) { stateVar1 = stateVar2; ...
user avatar
0 votes
1 answer
21 views

_disableInitializers() vs initializer vs reinitializer(uint8 version) in Openzeppelin/contracts-upgradeable?

Initializable.sol provides an initializer modifier and a _disableInitializers() internal function. I need help in understanding why a _disableInitializers() might be needed if we already have a ...
user avatar
0 votes
0 answers
10 views

Passing transaction origin address from one contract to another without use of tx.origin Solidity

I am currently working on a project that the user will buy/sell Contract A and receive another token from Contract B. Contract B is a crowdsale contract of a 0 value ERC20 token used as proof of ...
user avatar
0 votes
1 answer
8 views

Loading data from JSON files to a smart contract

I am new to solidity blockchain. I have transaction dataset in JSON files. I want to load it automatically to blockchain using ethereum solidity in https://github.com/itzmeanjan/merklize-sha. How can ...
user avatar
0 votes
1 answer
29 views

Call to contract doesn't work when sending a merkle proof (using ethers & JS)

I basically have a contract whose mint function looks like this: function mint(uint256 _mintAmount, bytes32[] calldata merkleProof) public payable isValidMerkleProof(merkleProof, ...
user avatar
  • 1
0 votes
0 answers
10 views

Reading return data from a Solidity `call`

Given a call to an external contract, (bool success, bytes memory returnData) = addr.call(abiEncoding); how do I read a single value of a given type from the return data, without using assembly? The ...
user avatar
0 votes
0 answers
18 views

contracts/FlashLoan DeclarationError: Identifier already declared

Error message contracts/FlashLoanReceiverBase.sol:9:1: DeclarationError: Identifier already declared. import "./Withdrawable.sol"; ^--------------------------^ github.com/OpenZeppelin/...
user avatar
  • 1
0 votes
0 answers
15 views

Can you pleaseexplain this smart contract? I understand what it does, but i do't understand the math behind it. How does paidPayouts gets incremented?

//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Deed { address payable public beneficiary; address public lawyer; uint public earliest; uint public amount; uint ...
user avatar
0 votes
0 answers
11 views

Not able to pass a value to function and add to an array value inside of a Struct

I am using Solidity with Hardhat and I am trying to loop through an array that I am receiving and adding it to an array that is inside of a struct. But I keep getting errors like: Error: invalid ...
user avatar
0 votes
1 answer
12 views

Use private in public function

We cannot use private function outside of the contract. If I define any private function then use it in the public function which is in the same contract with private function. Can I call this public ...
user avatar
  • 1
0 votes
0 answers
11 views

My test doesn't pass but expectation return correct value (truffle)

I have a voting Contract which contains 3 functions , 1 Struct, 1 mapping, 1 modifier and I use Ownable from openzeppelin : struct Voter { bool isRegistered; bool hasVoted; ...
user avatar
0 votes
0 answers
12 views

trying to devlop my custom mint contract but images not fetch after adding base uri then i got to know its not returning json parameter in token uri

pragma solidity ^0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/...
user avatar
  • 1
0 votes
1 answer
43 views

UNIT Test Error: No Contract deployed with name Raffle

This is the section of my unit testing... I've been working on this problem for the last few hours. I couldn't, however... I think the error is in const { deployer } = await getNamedAccounts() this ...
user avatar
0 votes
0 answers
16 views

Temporary Ether addressess for a single purpose usage or reverse proxy address type solution

We have a custodial wallet payment gateway product and we accept crypto payments. For now we are giving out a single address to all the merchants.. and that is okay for our MVP. We want to move to ...
user avatar
  • 1
0 votes
1 answer
32 views

execution reverted: "ERC20: insufficient allowance" on transfer method (not transferFrom)

I'm developing a Smart Contract that transfer tokens that are owned by the Smart Contract itself. The function to do that is pretty simple: pragma solidity 0.8.1; import "@openzeppelin/contracts/...
user avatar
  • 646
0 votes
1 answer
58 views

Error: chainId address mismatch

i'm trying to deploy a simple smart contract with node-js on a ganache-GUI but i keep getting this Error: chainId address mismatch; may chainId is the same as the networkId in the ganache app witch is ...
user avatar
0 votes
0 answers
15 views

solidity-coverage giving wrong report

The first time I ran npx hardhat coverage it hadn't removed the files that should be ignored and I got this result, which is correct. But after I added this to .solcover.js: module.exports = { ...
user avatar
  • 331
0 votes
0 answers
29 views

transfering rewards from website to crypto wallet

I want to transfer rewards that user had earn to his crypto wallet but problem is in our smart contract there is function with parameter value(amount) and address of reciever I need a secure way of ...
user avatar
0 votes
0 answers
20 views

ERROR processing when testing the contract - TypeError: Cannot read property 'length' of undefined

I am getting the following error while trying to test a FundMe contract. I am following: Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course by Patrick ...
user avatar
0 votes
1 answer
12 views

Using "call" method to send ether

I am receiving the error "Variable declarations can only be used inside blocks." on line 45 ( (bool sent, ) = guest.call{value: 1 ether}(""); ). when attempting to use the call ...
user avatar
  • 13
0 votes
1 answer
34 views

ERC721A - Strings for uint256 | ERROR REMIX IDE

I'm struggling with this error, the contract is from a famous Blockchain Dev Youtuber Hashlips and i've used it months ago without error, but now when i put it into REMIX Ide it gives me this error. ...
user avatar
0 votes
0 answers
22 views

Question about using events as smart contract storage

This question is a development of related questions from existing sources (https://media.consensys.net/technical-introduction-to-events-and-logs-in-ethereum-a074d65dd61e) and prior threads (Do logs/...
user avatar
  • 1
0 votes
0 answers
17 views

How to get reverted error name with ethers in javascript?

I write a solidty code and also a custom error like this: error TestObject__IndexNotFound(); function getProductChain(uint256 index) public view returns(SupplyChain memory){ if (index > (...
user avatar
0 votes
1 answer
13 views

How to use truffle-assertions to check if a constructor will revert?

Say I have a contract: contract Reverts{ constructor(param1){ require(param1); } } If param1 is false, the constructor should fail and revert state. truffle-assertions allows me to ...
user avatar
0 votes
1 answer
15 views

How do I compile a contract inheriting from SolidStateDiamond?

this is probably a newbie question, but I've been wanting to experiment with diamonds on solidity and I don't know where to start. I've been trying to deploy this contract //SPDX-License-Identifier: ...
user avatar
0 votes
0 answers
28 views

Block scoping in Solidity to avoid "Stack too deep error"

I have a quite big function with 16+ local variables which produces the infamous Stack too deep error. To handle this bad boy I have searched for the possible solutions and ended up using scopes. ...
user avatar
  • 186
0 votes
1 answer
14 views

Create contract with contract

I want to create a contract that can create contract itself I find something like this pragma solidity ^0.5.0; contract DaughterContract { string public name; uint public age; constructor( ...
user avatar
0 votes
0 answers
10 views

deploying contract with mainnet-fork then also ganache is running

Hey i m following patrick collins solidity course. I m currently on lesson 6 : Brownie fundMe In that course he taught us to use mainnet-fork but when i m deploying contract using mainnet-fork network ...
user avatar
  • 1
0 votes
0 answers
10 views

How does a stackable token benefit its maker?

I see some tokens are stackable, but how does a stackable token benefit its creators? I know how a PoS coin work, but token doesn't have an independent blockchain. So how token creators pay the stake ...
user avatar
0 votes
1 answer
28 views

How to get transaction history of ERC-721 token in Solidity

I'm trying to figure out how to get a history of values for a specific ERC721 token of known contract address. I want to do some maths in solidity and do not want to do all that in web2; therefore, I ...
user avatar
  • 3
0 votes
0 answers
9 views

In solidity if we use self destruct function , will the events emitted on blockchain will be deleted or only the data of blockchain will be erased?

What actually happens after self destruct function is called ? //SPDX-License-Identifier:MIT pragma solidity 0.8.7; contract PiggyBank{ event Deposit(uint amount); event Withdraw(uint amount); ...
user avatar
  • 21
0 votes
0 answers
15 views

push() Function not Working Solidity

//SPDX-License-Identifier:MIT pragma solidity ^0.7.0; import "./SimpleStorage.sol"; contract StroageFactory { address[] public SimpleStorageArray; function createSimpleStorage() ...
user avatar
0 votes
0 answers
22 views

it's possible to define global assembly function in solidity

We can define a function like this function A() external pure { assembly { function doSomthing() -> data { // We define this method in the A function }...
user avatar
0 votes
1 answer
17 views

Why doesn't address(this).balance work in a state variable?

If we put address(this).balance inside a function, like this: function getBalance() public view returns(uint) { return address(this).balance; } It works perfectly as it should. However, it ...
user avatar
0 votes
1 answer
27 views

Does Smart Contract pay gas fees in this case?

Lets say there are 2 smart contracts A and B. A contracts approves B contract for some allowance, as B has approval to withdraw from A contract. Lets say contract B withdraw some X coins from A ...
user avatar
0 votes
0 answers
29 views

Solidity Acces public varialbles ethers.js

I am trying to fetch data on public variables from the blockchain using ethers.js. but other declared functions will work properly. This is the way I am using it. My solidity: contract NLTNFT is ...
user avatar
  • 101
0 votes
0 answers
10 views

Best way to distribute (airdrop) tokens to holders of another token?

So I am looking for the best way to distribute dividends (airdrop) tokens of various ERC20 tokens based on the balance of holdings at a point in time of another token. So I have an ERC20 token already ...
user avatar