-
pip install alkahest-py
-
import the module and create an AlkahestClient instance
from alkahest_py import AlkahestClient
client = AlkahestClient(
"0xprivatekey",
"https://rpc_url.com"
)
async def main():
hash = await client.erc20.approve(
{"address": "0x036CbD53842c5426634e7929541eC2318f3dCF7e", "value": 100},
"escrow",
)
print(hash)
if __name__ == "__main__":
asyncio.run(main())
- for more extensive API docs,
git clone https://github.com/CoopHive/alkahest-py
and runcargo doc --open
. most functions are in the submodules Erc20Client, Erc721Client etc. the alkahest-rs docs might be more useful than the alkahest-py docs, since many rust types get wrangled into python strings. FixedBytes<32> and Address are strings starting with "0x" in python, but Bytes is python bytes (b"..."). structs (ArbiterData, Erc20Data) are dictionaries with item names matching the struct's fields. ApprovalPurpose can be "escrow" or "payment".
note that ArbiterData ({"arbiter": "0x...", "demand": b"..."}) expects demand as abi encoded bytes. for arbiters that aren't explicitly supported, you'll have to manually encode the Solidity struct, e.g. with eth_abi. passing a dictionary matching the solidity struct's format isn't supported.
see alkahest_py/test.py for a usage example.