digitaldonkey / ethereum-php

PHP interface to Ethereum JSON-RPC API. Fully typed Web3 for PHP 7.X
http://ethereum-php.org
MIT License
489 stars 174 forks source link

How can I call the contract method 'getAmountsOut' with 'address[]' params? #60

Open silsuer opened 3 years ago

silsuer commented 3 years ago

I wath get the price from pancakeswap router contract: https://bscscan.com/address/0x10ED43C718714eb63d5aA57B78B54704E256024E

abi:

{"internalType":"address[]","name":"path","type":"address[]"}],"name":"getAmountsOut","outputs":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"stateMutability":"view","type":"function"}

code:

$eth = new Ethereum($url);
$w = new SmartContract($abi, self::PANCAKE_SWAP_ROUTER_CONTRACT_ADDRESS, $eth);

$price = $w->getAmountsOut(
            new EthQ(1, ['abi' => 'uint256'])
            new EthD($path, ['abi' => 'address[]'])
        )->val();

I dont know how to new the address[] ABI type object then got the err:

substr() expects parameter 1 to be string, array given

How can I fix it?

devoided commented 2 years ago

Did you ever get this solved?