-
Notifications
You must be signed in to change notification settings - Fork 18
/
example.php
49 lines (34 loc) · 1.06 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use \Arweave\SDK\Arweave;
use \Arweave\SDK\Support\Wallet;
include __DIR__ . '/vendor/autoload.php';
$arweave = new Arweave('https', 'arweave.net', '443');
$jwk = json_decode(file_get_contents('key.json'), true);
$wallet = new Wallet($jwk);
$tx = $arweave->createTransaction($wallet, [
'target' => 'nQoflnhlpZwYuSHVQGYGTo41WR8MxBFfF9DNNbApoIp',
'data' => 'Some data to send, along with 10 winston',
'quantity' => '10',
'tags' => [
'test-key' => 'test-value'
]
]);
// Dump the encoded transaction
var_dump($tx);
// Verify the signature
var_dump($tx->verify());
// Commit the transaction to the network - once sent this can't be undone.
$arweave->api()->commit($tx);
// Wait a few seconds for the tx to propagate
sleep(10);
$status = $arweave->api()->getTransaction($tx->getAttribute('id'));
// Now print the status
var_dump($status);
// Get transaction ids
$transactionIds = $arweave->api()->arql([
'op' => 'equals',
'expr1' => 'App-Name',
'expr2' => 'arweaveapps'
]);
// Dump the transaction ids
var_dump($transactionIds);