Skip to main content

Wallets based on SALT instead of Nonce.

Project description

Bifrost

important: Work-In-Progress. No production software.

TOC

Install

Install from PyPI

# Virtualenv
(pyenv)$ pip install bifrost

# Main Python shell
$ sudo -H pip install bifrost 

Install from sources

# Ubuntu 18.04+
# Required packages
sudo apt install -y python3-dev git virtualenv

# Create and activate virtualenv
$ virtualenv -p python3 pyenv
(pyenv) $ source pyenv/bin/activate

# clone Repo
(pyenv) $ git clone https://gitlab.com/dtecdeal/lab/bifrost /path/to/destination/folder
(pyenv) $ cd /path/to/destination/folder/Python
(pyenv) $ python setup.py install

Usage

Create wallet

import os
from web3 import Web3
from bifrost import Bifrost

SIGNER_PK = os.environ.get('SIGNER_PK', "{default-signer-pk}")
FACTORY_ADDRESS = os.environ.get('FACTORY_ADDRESS', "{default-factory-address}")
RPC_URL = os.environ.get('RPC_URL', "{default-RPC-URL}")
BIFROST_FACTORY = os.environ.get('BIFROST_FACTORY', "{bifrost-factory}")


w3Provider = Web3.HTTPProvider(RPC_URL)
w3 = Web3(w3Provider)
signer_account = w3.eth.account.privateKeyToAccount(SIGNER_PK)

bifrost = Bifrost(BIFROST_FACTORY, signer_account, w3Provider)

address_salt = 1
address = bifrost.getAddress(address_salt)
address_is_deployed = bifrost.isDeployed(address_salt)

print('''
    Signer: %s
    Salt: %s
    Address: %s
    IsDeployed: %s 
''' % (signer_account.address, address_salt, address, address_is_deployed))

Transfer ETH

import os
from web3 import Web3
from bifrost import Bifrost

SIGNER_PK = os.environ.get('SIGNER_PK', "{default-signer-pk}")
FACTORY_ADDRESS = os.environ.get('FACTORY_ADDRESS', "{default-factory-address}")
RPC_URL = os.environ.get('RPC_URL', "{default-RPC-URL}")
BIFROST_FACTORY = os.environ.get('BIFROST_FACTORY', "{bifrost-factory}")

w3Provider = Web3.HTTPProvider(RPC_URL)
w3 = Web3(w3Provider)
signer_account = w3.eth.account.privateKeyToAccount(SIGNER_PK)

bifrost = Bifrost(BIFROST_FACTORY, signer_account, w3Provider)

address_salt = 1

amount = int(.1 * 10 ** 18)

# Transfer ETH
# address should have more than .1 (amount) ETH
tx = bifrost.makeCall(address_salt, signer_account.address, amount)
print('ETH transfer: ', tx.hex())
w3.eth.waitForTransactionReceipt(tx)

Transfer ERC20

import os
import json
from web3 import Web3
from bifrost import Bifrost

SIGNER_PK = os.environ.get('SIGNER_PK', "{default-signer-pk}")
FACTORY_ADDRESS = os.environ.get('FACTORY_ADDRESS', "{default-factory-address}")
RPC_URL = os.environ.get('RPC_URL', "{default-RPC-URL}")
BIFROST_FACTORY = os.environ.get('BIFROST_FACTORY', "{bifrost-factory}")
ERC20_ADDRESS = os.environ.get('ERC20_ADDRESS', '{default-ERC20-address}')


w3Provider = Web3.HTTPProvider(RPC_URL)
w3 = Web3(w3Provider)
signer_account = w3.eth.account.privateKeyToAccount(SIGNER_PK)

bifrost = Bifrost(BIFROST_FACTORY, signer_account, w3Provider)

address_salt = 1

amount = int(.1 * 10 ** 18)
# Transfer ERC20
# address should have more than .1 (amount) ERC20
ERC20_abi = json.load(open('path/to/abi/IERC20.json', 'r'))
ERC20 = w3.eth.contract(abi=ERC20_abi)
call = ERC20.encodeABI('transfer', args=(signer_account.address, amount))
tx = bifrost.makeCall(address_salt, ERC20_ADDRESS, 0, call)
print('ERC20 transfer: ', tx.hex())

Note

Following error

{'code': -32000, 'message': 'gas required exceeds allowance (7447619) or always failing transaction'}

Mostly related with always failing transaction

Made it with ❤ by DTecDeal

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bifrost_py-0.0.5.tar.gz (4.3 kB view details)

Uploaded Source

File details

Details for the file bifrost_py-0.0.5.tar.gz.

File metadata

  • Download URL: bifrost_py-0.0.5.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.6

File hashes

Hashes for bifrost_py-0.0.5.tar.gz
Algorithm Hash digest
SHA256 63e992b167f9333844fba41b2b42ab7f2f5d7fefd0d799784fa3e126724e955d
MD5 5bd5abeb4c89053eea1ab3d7f04ccdbf
BLAKE2b-256 e81d0a1e7540b1328f050e9c92cb2761a4abc3c648bbc0a52a655684f8313845

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page