Web3py – How to Get Public Array Values with Web3py

solidityweb3.pyweb3js

Is there a way to get poolInfo[0] public array element value (represented by Struct) via call request by Web3py library (without writing getter function)?

Contract snippet:

struct PoolInfo {
        uint256 id;
        address poolAddress;
        uint256 poolType;
        address lpToken;
        address Rewards;
        uint256 FeePercentage;
        bool pauseDeposit;
        address[] RewardTokens;
    }

PoolInfo[] public poolInfo;

Best Answer

Yes:

pool_info = contract.functions.poolInfo(0).call()
print(pool_info) # You will get a tuple representing your object

Contract is an object that was created from w3.eth.contract

Related Topic