Composer package for direct communication with A-Block's API
- PHP >= 8.2
- composer
- Create wallets
- Create addresses/keypairs for wallets
- Create item assets (A-Block's equivalent to NFTs) related to keypairs
- Transfer assets (Items or Tokens) to another address
- Initiate and complete Dual Double Entry (DDE) using a DRUID to trade assets between addresses
- Simply run
composer require io-digital/a-block-php
- Include
IODigital\ABlockPHP\ABlockClient
in your PHP code and you're ready to go - Instantiate the above client with `
This package makes use of PHP's typing of function definitions to increase robustness. Many of the client's functions require a Data Transfer Object (DTO) to be passed as input and some return a DTO. Some usage examples below will illustrate this.
It may seem cumbersome at first but it helps ensure that the data we send to the A-Block API is formatted correctly.
These are listed in an order that you could follow to do most of the things this package allows you, as one may in the real world.
$client = new ABlockClient(
computeHost: 'http://your-compute-host',
intercomHost: 'http://your-intercom-host'
);
$client->setPassPhrase('my very intricate passphrase');
A pass phrase (text string) is used to encrypt and decrypt data in any typical cryptography implementation and this setup is no different.
Please ensure that you run $client->setPassPhrase('my very intricate passphrase');
before attempting any interaction with the client.
Creates and returns a new wallet. It is up to the developer to store this.
$encryptedWalletDTO = $client->createWallet();
$walletIsOpen = $client->openWallet(
wallet: $encryptedWalletDTO
);
$encryptedKeypairDTO = $client->createKeypair();
$balance = $client->fetchBalance(
addressList: [$encryptedKeypairDTO->getAddress()]
);
$itemAssetArr = $client->createAsset(
name: 'Some friendly identifier',
encryptedKey: $encryptedKeypairDTO->getAddress(),
nonce: $encryptedKeypairDTO->getNonce(),
amount: 100,
defaultDrsTxHash: false, // make true to create generic items
metaData: [
'foo' => 'bar'
]
);
Please note that this newly created asset will only reflect in a fetchBalance
enquiry once it has been verified by A-Block's compute node.