iexbase / tron-api

A PHP API for interacting with Tron (TRX)
https://iexbase.github.io/tron-api/
MIT License
405 stars 287 forks source link

How to call function in contract #178

Open developeremi opened 1 year ago

developeremi commented 1 year ago

I have an error in the calling function of my contract.


    $fullNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.shasta.trongrid.io');
    $solidityNode = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.shasta.trongrid.io');
    $eventServer = new \IEXBase\TronAPI\Provider\HttpProvider('https://api.shasta.trongrid.io');

    try {
        $tron = new \IEXBase\TronAPI\Tron($fullNode, $solidityNode, $eventServer);
    } catch (\IEXBase\TronAPI\Exception\TronException $e) {
        exit($e->getMessage());
    }

    $contractAddress = 'TWEv92whv1kDW3JqgNn5HHVhbfbnfhmQxC';
    $contract = $tron->contract($contractAddress, '[{"entrys":[{"stateMutability":"Nonpayable","type":"Constructor"},{"inputs":[{"indexed":true,"name":"user","type":"address"},{"name":"amount","type":"uint256"}],"name":"Deposit","type":"Event"},{"inputs":[{"indexed":true,"name":"user","type":"address"},{"name":"amount","type":"uint256"}],"name":"Withdrawal","type":"Event"},{"inputs":[{"indexed":true,"name":"user","type":"address"},{"name":"amount","type":"uint256"}],"name":"WithdrawalApproval","type":"Event"},{"inputs":[{"indexed":true,"name":"user","type":"address"},{"name":"amount","type":"uint256"}],"name":"WithdrawalRejection","type":"Event"},{"inputs":[{"indexed":true,"name":"user","type":"address"},{"name":"amount","type":"uint256"}],"name":"WithdrawalRequest","type":"Event"},{"outputs":[{"type":"uint256"}],"name":"MAX_WITHDRAWAL_AMOUNT","stateMutability":"View","type":"Function"},{"outputs":[{"type":"uint256"}],"name":"WITHDRAWAL_COOLDOWN","stateMutability":"View","type":"Function"},{"inputs":[{"name":"user","type":"address"}],"name":"approveWithdrawal","stateMutability":"Nonpayable","type":"Function"},{"outputs":[{"type":"uint256"}],"inputs":[{"type":"address"}],"name":"balances","stateMutability":"View","type":"Function"},{"name":"deposit","stateMutability":"Payable","type":"Function"},{"outputs":[{"type":"uint256"}],"name":"fee","stateMutability":"View","type":"Function"},{"outputs":[{"type":"uint256"}],"inputs":[{"type":"address"}],"name":"lastWithdrawalTime","stateMutability":"View","type":"Function"},{"outputs":[{"type":"address"}],"name":"owner","stateMutability":"View","type":"Function"},{"name":"pause","stateMutability":"Nonpayable","type":"Function"},{"outputs":[{"type":"bool"}],"name":"paused","stateMutability":"View","type":"Function"},{"inputs":[{"name":"user","type":"address"}],"name":"rejectWithdrawal","stateMutability":"Nonpayable","type":"Function"},{"inputs":[{"name":"amount","type":"uint256"}],"name":"requestWithdrawal","stateMutability":"Nonpayable","type":"Function"},{"name":"unpause","stateMutability":"Nonpayable","type":"Function"},{"inputs":[{"name":"amount","type":"uint256"}],"name":"withdraw","stateMutability":"Nonpayable","type":"Function"},{"outputs":[{"type":"uint256"}],"inputs":[{"type":"address"}],"name":"withdrawalRequests","stateMutability":"View","type":"Function"}]}]');

    $contract = $contract->paused()->call();

Call to undefined method IEXBase\TronAPI\TRC20Contract::paused()