Skip to content

wuddertech/wudder-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-sdk

Installation

pip install wudder

Usage

from wudder import Wudder, Fragment, Event

Create account

Wudder.signup('email@example.org', 'p4ssw0rd', private_key_password='k3y_p4ssw0rd')

You can specify a custom GraphQL endpoint with the argument endpoint

Wudder.signup('email@example.org', 'p4ssw0rd', private_key_password='k3y_p4ssw0rd', endpoint='https://api.pre.wudder.tech/graphql/')

Login

wudder = Wudder('email@example.org', 'p4ssw0rd', private_key_password='k3y_p4ssw0rd')

Again, you can specify a custom GraphQL endpoint with the argument endpoint

wudder = Wudder('email@example.org', 'p4ssw0rd', private_key_password='k3y_p4ssw0rd', endpoint='https://api.pre.wudder.tech/graphql/')

You can sign the transactions with a custom local private key (e.g., FNMT private key in the PKCS#12 format). Check the supported protocols and file formats at labteral/digsig-python:

wudder = Wudder('email@example.org', 'p4ssw0rd', private_key_path='private_key.p12', private_key_password='k3y_p4ssw0rd')

Create trace

trace_evhash = wudder.send('Title', [{'field': 'key', 'value': 'value'}])

Add event to trace

evhash = wudder.send('Title', [{'field': 'key', 'value': 'value'}], trace=trace_evhash)

Get event

event = wudder.get_event(evhash)

Get trace

trace = wudder.get_trace(evhash)

Get proof

proof = wudder.get_proof(evhash)

Check Ethereum proof

wudder.check_ethereum_proof(proof['proof'], proof['l1_suffixes']['ethereum']['tx_hash']))

Create a local backup of the private key

import json

with open('private_key.json', 'w') as output_file:
    json.dump(wudder.private_key, output_file)

Restore a local backup of the private key

import json

with open('private_key.json', 'r') as input_file:
    private_key = json.load(input_file)

wudder.update_private_key(private_key, 'k3y_p4ssw0rd')

Replace the private key

from wudder import utils

new_private_key = utils.generate_private_key('k3y_p4ssw0rd')
wudder.update_private_key(new_private_key, 'k3y_p4ssw0rd')