Skip to content

Commit e83ba43

Browse files
author
Matthias Zimmermann
committed
update readme
1 parent 973b0bb commit e83ba43

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

README.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,28 @@ It clearly communicates that arkiv is a module extension just like eth, net, etc
2424
Here's a "Hello World!" example showing how to use the Python Arkiv SDK:
2525

2626
```python
27-
from web3 import HTTPProvider
2827
from arkiv import Arkiv
2928
from arkiv.account import NamedAccount
30-
from arkiv.provider import ProviderBuilder
31-
32-
with open ('wallet_alice.json', 'r') as f:
33-
wallet = f.read()
34-
35-
# Initialize Arkiv client (extends Web3)
36-
provider = ProviderBuilder().kaolin().build()
37-
account = NamedAccount.from_wallet('Alice', wallet, 's3cret')
38-
client = Arkiv(provider, account = account)
3929

40-
# Check connection and balance
30+
# Create account and client that implicitly starts a local Arkiv node
31+
alice = NamedAccount.create('Alice')
32+
client = Arkiv(account=alice)
4133
print(f"Connected: {client.is_connected()}")
42-
print(f"Account balance: {client.eth.get_balance(account.address)}")
34+
35+
# Fund the account
36+
client.node.fund_account(alice)
37+
print(f"Balance: {client.eth.get_balance(alice.address)}")
4338

4439
# Create entity with data and annotations
4540
entity_key, tx_hash = client.arkiv.create_entity(
4641
payload=b"Hello World!",
4742
annotations={"type": "greeting", "version": 1},
4843
btl = 1000
4944
)
50-
print(f"Created entity: {entity_key}")
45+
46+
# Check and print entity key
47+
exists = client.arkiv.entity_exists(entity_key)
48+
print(f"Created entity: {entity_key}, exists={exists}")
5149

5250
# Get individual entity and print its details
5351
entity = client.arkiv.get_entity(entity_key)
@@ -57,10 +55,31 @@ print(f"Entity: {entity}")
5755
# Clean up - delete entities
5856
client.arkiv.delete_entity(entity_key)
5957
print("Entities deleted")
58+
```
6059

61-
# Verify deletion
62-
exists = client.arkiv.exists(entity_key)
63-
print(f"Entity 1 exists? {exists}")
60+
### Provider Builder
61+
62+
The snippet below demonstrates the creation of various nodes to connect to using the `ProviderBuilder`.
63+
64+
```python
65+
from arkiv import Arkiv
66+
from arkiv.account import NamedAccount
67+
from arkiv.provider import ProviderBuilder
68+
69+
# Create account from wallet json
70+
with open ('wallet_bob.json', 'r') as f:
71+
wallet = f.read()
72+
73+
bob = NamedAccount.from_wallet('Bob', wallet, 's3cret')
74+
75+
# Initialize Arkiv client connected to Kaolin (Akriv testnet)
76+
provider = ProviderBuilder().kaolin().build()
77+
client = Arkiv(provider, account=bob)
78+
79+
# Additional builder examples
80+
provider_container = ProviderBuilder().node().build()
81+
provider_kaolin_ws = ProviderBuilder().kaolin().ws().build()
82+
provider_custom = ProviderBuilder().custom("https://my-rpc.io").build()
6483
```
6584

6685
### Web3 Standard Support

0 commit comments

Comments
 (0)