-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic.py
More file actions
38 lines (28 loc) · 1.46 KB
/
basic.py
File metadata and controls
38 lines (28 loc) · 1.46 KB
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
from irys_sdk import Builder, DataItem, sign, create_data, EthereumSigner
def demo():
# standard (optionally 0x prefixed) hex encoded private key (like you'd get from exporting from a wallet)
wallet = "0x..."
client = Builder("ethereum").wallet(wallet).network("devnet")
# optional RPC URL
# client.rpc_url("...")
client = client.build()
# get the balance for the address associated with `wallet` on the `network` bundler node
print("balance of ", client.address,
" in atomic units (wei) :", client.get_balance())
print("Price for 100 bytes in atomic units (wei): ", client.get_price(100))
# fund the bundler node
# fund_result = client.fund(2)
# upload some data
upload_result = client.upload(b"Hello, Irys!", tags=[
("test1", "test2"), ("asdfasdf", "wwwwwwwwwwwwwwwwwwwwwwwww")], anchor="28ea4edc02a04be07da77f11cb578b0a", target="ZjQ1Y2JhNDk3Y2Y3ZGU0YzRmMjRlZDM5NDExOTMyZTU=")
print(upload_result)
# manually create and sign a data item
# (not required if the above ^ upload API works for your usecase)
signer = EthereumSigner(wallet)
tx = create_data(bytearray(), signer, tags=[
("test1", "test2"), ("asdfasdf", "wwwwwwwwwwwwwwwwwwwwwwwww")], anchor="28ea4edc02a04be07da77f11cb578b0a", target="ZjQ1Y2JhNDk3Y2Y3ZGU0YzRmMjRlZDM5NDExOTMyZTU=")
id = sign(tx, signer)
is_valid = DataItem.verify(tx.get_raw())
print(tx.id)
# if __name__ == '__main__':
# demo()