waves/client

PHP client library for interacting with Waves blockchain platform

v1.0.4 2024-08-15 14:30 UTC

This package is not auto-updated.

Last update: 2024-12-19 16:25:19 UTC


README

packagist php-version codecov phpstan codecov phpstan phpstan

PHP client library for interacting with Waves blockchain platform.

Installation

composer require waves/client

Usage

See example.php for full code examples.

  • New account:
$account = PrivateKey::fromSeed( 'your mnemonic seed phrase' );
$sender = $account->publicKey();
echo 'address = ' . $sender->address()->toString() . PHP_EOL;
  • Node basics:
$nodeChainId = $node->chainId();
echo 'node chainId = ' . $nodeChainId->asString() . PHP_EOL;
$nodeVersion = $node->getVersion();
echo 'node version = ' . $nodeVersion . PHP_EOL;
$nodeHeight = $node->getHeight();
echo 'node height = ' . $nodeHeight . PHP_EOL;
  • Transfer transaction:
$amount = Amount::of( 1 ); // 0.00000001 Waves
$recipient = Recipient::fromAddressOrAlias( 'test' ); // from alias
$recipient = Recipient::fromAddressOrAlias( '3N9WtaPoD1tMrDZRG26wA142Byd35tLhnLU' ); // from address

$transferTx = TransferTransaction::build( $sender, $recipient, $amount );
$transferTxSigned = $transferTx->addProof( $account );
$transferTxBroadcasted = $node->broadcast( $transferTxSigned );
$transferTxConfirmed = $node->waitForTransaction( $transferTxBroadcasted->id() );
  • DApp invocation transaction:
$dApp = Recipient::fromAddressOrAlias( '3N7uoMNjqNt1jf9q9f9BSr7ASk1QtzJABEY' );
$functionCall = FunctionCall::as( 'retransmit', [
    Arg::as( Arg::STRING, Value::as( $sender->address()->toString() ) ),
    Arg::as( Arg::INTEGER, Value::as( 1 ) ),
    Arg::as( Arg::BINARY, Value::as( hash( 'sha256', $sender->address()->toString(), true ) ) ),
    Arg::as( Arg::BOOLEAN, Value::as( true ) ),
] );
$payments = [
    Amount::of( 1000 ),
];

$invokeTx = InvokeScriptTransaction::build( $sender, $dApp, $functionCall, $payments );
$invokeTxSigned = $invokeTx->addProof( $account );
$invokeTxBroadcasted = $node->broadcast( $invokeTxSigned );
$invokeTxConfirmed = $node->waitForTransaction( $invokeTxBroadcasted->id() );

Requirements