Hot answers tagged

2

Just for the others who might be facing the same issue (it took me quite a while to fix it). The problem I faced was that I was calling function addLiquidityETH() without sending the ethers to Uniswap smart contract, so {value: msg.value} has to be added to the call: uniswap.addLiquidityETH{ value: msg.value }( token, amountTokenDesired, ...


1

You have corrected it. The problem was you cannot access a non-existent element of an array. So, so given c = 0, and car.length = 0 you cannot access the first non-existent row of the array which is numbered 0. If row 0 existed, then the array length would be 1. When you try car[0] on an empty array, you get an error because you are out of bounds. So, your ...


1

Just add calldata to the parameter. So the signature should be: function performBonusCredit(string[][] calldata _toPayArgs) external payable { You can read more about these data location markers here: https://docs.soliditylang.org/en/v0.8.0/types.html#data-location


1

Solidity enables constructors which have code executed at contract creation. So you need to instantiate owner in the constructor to catch the contract deployer address : address payable owner; constructor() public { owner = msg.sender; } There are also standardized contracts to manage ownership. Exemple of implementation can be found here : https://github....


1

Your array is composed of Proposal but you are trying to push a 0 into a struct member. You can only push a Proposal on to an array of Proposal. Try this: pragma solidity 0.7.6; // SPDX-License-Identifier: UNLICENSED contract Vote { struct Proposal { uint votecount; } Proposal[] proposals; constructor(uint ...


1

The Proposal[] proposal declaration in your code is of a storage array. As such, you don't need to initialize it with proposal = new Proposal[](...);. You can simply push into it as many items as you'd like. The only thing actually missing there is an access-level (public/internal/private). As with regards to your push attempt, simply change this: proposal....


1

Just to add into Shane's answer, if you are testing with ganache-cli, you can also do this: const ganache = require('ganache-cli'); const Web3 = require('web3'); const options = { a: 100 }; // NO OF ACCOUNTS const provider = ganache.provider(options); const web3 = new Web3(provider); I hope that helps.


Only top voted, non community-wiki answers of a minimum length are eligible