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

NEED HELP: DelegateResource method add to the Library. #193

Open maksus opened 6 months ago

maksus commented 6 months ago

I have tried to add method from Tron FullNode HTTP API 'DelegateResource' to be able to send ENERGY and BANDWIDTH from Staking2.0 to another address (https://developers.tron.network/reference/delegateresource-1). But Library doesn't catch it up.

Can anyone please help me (ready to pay for the help)?

Code I am trying to add to 'TransactionBuilder.php' file in 'src' directory:

public function DelegateEnergy(float $amount, string $resource, string $address, string $toaddress) { return $this->tron->getManager()->request('wallet/delegateresource', [ 'owner_address' => $this->tron->address2HexString($address), 'receiver_address' => $this->tron->address2HexString($toaddress), 'balance' => $this->tron->toTron($amount), 'resource' => $resource, 'lock' => false, 'visible' => true ]); }

Code I am calling the method:

 $raw_tx = $tron->tron->DelegateEnergy('1000', 'ENERGY', 'from_address', 'destination_address');

ERROR I get - "Fatal error: Uncaught Error: Call to a member function DelegateEnergy() on null in".

My Method doesn't show when checking the TRON Class's method.

ufado commented 2 months ago

You can try to use this library https://github.com/ufado/tron-api.