Skip to content

A template for a Synthetix project using the Python SDK

License

Notifications You must be signed in to change notification settings

Synthetixio/project-template-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample Project

This is a template to help you start a Synthetix project using the Python SDK.

Getting Started

  1. Before you begin, ensure you have:
  • A RPC endpoint like Infura or Alchemy
  • A wallet address and the private key for that address
  • Installed Python 3.8 or greater
    • Run python --version in your terminal to check
  1. Download this repository to a preferred location on your computer. Here's how:
git clone https://github.com/Synthetixio/project-template-python.git
cd project-template-python
  1. Set up the required packages in a virtual environment:
python3 -m venv env
source env/bin/activate

pip install --upgrade pip
pip install -r requirements.txt
  1. Make a copy of the .env.example file, name it .env, and then enter the details for your RPC and wallet.
PROVIDER_RPC=<An RPC endpoint>
PRIVATE_KEY=<Your private key (optional)>

The private key is optional. If one is not provided, the SDK can simulate a specified address, but transaction signing will be disabled.

  1. Run the status script:
python status.py

You should see results displaying your balances and market information, as shown below:

$ python status.py

Address: 0xD199157bB8a47bEF78e539908dEE5A41e7d5FE9f
ETH balance: 1.287
WETH balance: 0.0
sUSD balance: 10238.922

Perps accounts: 100, 101, 102
Perps default account: 100
Perps markets: BTC, ETH, LINK, OP, SNX

Congratulations! If you've made it this far you can start to build your own project using the Python SDK. More scripts are available in the scripts directory.

Running Scripts

If you've completed the steps above, you can run any of the scripts in the scripts directory. For example:

python scripts/create_account.py

By default, these scripts won't submit transactions. To enable this, you must edit the script and set submit=True. This precaution helps avoid unintended transactions on the blockchain. Always use caution and carefully review the code before submitting transactions.

Documentation

For a full list of available methods, see the Python SDK documentation.

About

A template for a Synthetix project using the Python SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages