Skip to content

PHP library for interacting with the Waves blockchain.

License

Notifications You must be signed in to change notification settings

wavesplatform/waves-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Waves-PHP

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

About

PHP library for interacting with the Waves blockchain.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages