Skip to content

Instantly share code, notes, and snippets.

@abramsymons
Created November 27, 2021 20:20
Show Gist options
  • Save abramsymons/790bd330011e6adf7ec00c5b0981a1be to your computer and use it in GitHub Desktop.
Save abramsymons/790bd330011e6adf7ec00c5b0981a1be to your computer and use it in GitHub Desktop.
import brightid
from eth_account import Account
import secrets
import time
import requests
context = 'RabbitHole'
node = brightid.Node('http://node.brightid.org/brightid/v5')
def newAddress():
priv = secrets.token_hex(32)
privateKey = "0x" + priv
acct = Account.from_key(privateKey)
return acct.address, privateKey
def dummyConnect(user):
id = 'kwQyKj5RS5DzPq9bvaNTKv0E6JxYIorylnF0ACUFbH0'
op = {
'name': 'Connect',
'id1': user['id'],
'id2': id,
'level': 'just met',
'timestamp': int(time.time() * 1000),
'v': 5
}
op['sig1'] = brightid.tools.sign(op, user['private'])
node.operations.post(op)
def link(contextId, user):
op = {
'name': 'Link ContextId',
'id': user['id'],
'context': context,
'contextId': contextId,
'timestamp': int(time.time() * 1000),
'v': 5
}
op['sig'] = brightid.tools.sign(op, user['private'])
res = node.operations.post(op)
def create():
user = brightid.tools.create_bright_id()
address, privateKey = newAddress()
# get contextId that is created online based on the address
url = 'https://iqs5wfdv79.execute-api.us-east-1.amazonaws.com/prod//address/{}'.format(address)
contextId = requests.get(url).json()['id']
print(contextId, address, user['id'])
# create the brightid by making a dummy connection
dummyConnect(user)
# linking brightid to the contextId
link(contextId, user)
print('wait for 60 seconds ...')
time.sleep(60)
print('sponsoring ...')
url = 'https://iqs5wfdv79.execute-api.us-east-1.amazonaws.com/prod//task_progress?address={}'.format(address)
r = requests.get(url).json()
if __name__ == '__main__':
create()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment