0

I am using this code:

// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

contract Wallet {
    address owner;
        
    struct Data {
        string userEmail;
        uint256 points;
        uint256 neutralizationPoints;
        uint256 lastTransactionAt;
        uint256 createdAt;
    }
   
    Data public data;
    event WalletCreated(Wallet wallet);
    address[] transactions;
   
    constructor(
        uint256 _points,
        uint256 _neutralizationPoints,
        string memory _userEmail,
        uint256 _createdAt
        
    ) {
       owner = msg.sender;
       data.points = _points;
       data.neutralizationPoints = _neutralizationPoints;
       data.createdAt = _createdAt;
       data.lastTransactionAt = _createdAt;
       data.userEmail = _userEmail;
       emit WalletCreated(this);
    }
   
    modifier onlyOwner() {
        require(
            msg.sender == owner,
            "This function is restricted to the contract's owner"
        );
        _;
    }
    
    function addCredits(uint256 _points, uint256 _neutralizationPoints, address _transactionAddress, uint256 _timestamp) onlyOwner public {
        data.points += _points;
        data.neutralizationPoints += _neutralizationPoints;
        transactions.push(_transactionAddress);
        data.lastTransactionAt = _timestamp;
    }
    
    function addDebits(uint256 _points, uint256 _neutralizationPoints, address _transactionAddress, uint256 _timestamp) onlyOwner public {
        data.points -= _points;
        data.neutralizationPoints -= _neutralizationPoints;
        transactions.push(_transactionAddress);
        data.lastTransactionAt = _timestamp;
    }
    
    function getPoints() public view returns (uint256) {
        return data.points;
    }
    
    function getNeutralizationPoints() public view returns (uint256) {
        return data.neutralizationPoints;
    }
    
    function getTransactions() public view returns (address[] memory) {
        return transactions;
    }

    function getData() public view returns (Data memory) {
        return data;
    }
}

but this error is coming: Error encoding arguments: Error: invalid BigNumber string

what is the problem?

2
  • When do you get this error? Because I deployed it on Remix using Ganache and tested all the functions and all work alright. Commented Aug 21, 2022 at 2:56
  • Seems you interact with your contract with javascript or some other languages? Please show more information about what you did with the contract and when the error raised. Commented Aug 21, 2022 at 8:13

1 Answer 1

0

Looks like you didn't parse response from blockchain. Usually something like BigNumber.from(YOURVARIABLERESPONSEFROMCONTRACT) helps(if u used js) BigNumber from ethers, so install ethers and import to your file.

import { BigNumber } from "ethers";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.