Use the Upvest API from the command line!
To install the Upvest CLI, using Python 3.6+:
pip install upvest-cli
or alternatively directly from the repository:
pip install https://github.com/toknapp/upvest-cli
There are three 'layers' of the upvest CLI commands.
upvestthe starting point for commands to configure which endpoint to talk to
userto decide between using the application (tenant) API or the user (clientele) API and include the necessary credentials
- commands : such as 'createuser' or 'listassets' or 'createwallet'
Create a user:
upvest -e https://api.playground.upvest.co/ app -K keyid -S keysecret -P keypassphrase createuser username password
A configuration file will help to fill in most command line arguments, thus avoiding having to repeat several credentials and ensuring secrets and passwords do not linger in your bash history.
--help on each subcommand will show which environment variables to set in place of commandline arguments, however a configuration file can also be used.
This will be loaded by default from
.upvest.yaml however this can be configured using the
-c flag to pass in the path to the configuration file.
The configuration file should take the following form:
endpoints: my_example_name: base_url: https://api.playground.upvest.co/ api_key: ... api_key_secret: ... api_key_passphrase: ... oauth_client_id: ... oauth_client_secret: ...
This can then be referenced from the command line to switch between environments or applications as you define them:
upvest -e my_example_name user -l username -w password listwallets
Here is a quick guide on how to create a user, create a wallet for that user, then receive and send to and from it. Once you have created an API key at https://login.upvest.co, and created a configuration file as above, take the following steps.
Create a single user with the given username and password:
upvest -e my_example_name app createuser test_username test_password
First list the assets available for your application to use:
upvest -e my_example_name app listassets Symbol | Name | ID -------| ------------------------------------------- | ------------------------------------ ETH | Ether (Ropsten) | deaaa6bf-d944-57fa-8ec4-2dd45d1f5d3f UP | Upvest Testing ERC20 Faucet (Ropsten) | cf08564b-8fa3-5c88-a29b-029915471249
Then create a wallet for the test user using one or more asset IDs from that list. In this example, creating an Ether Ropsten wallet:
upvest -e my_example_name user --login test_username --password test_password createwallet deaaa6bf-d944-57fa-8ec4-2dd45d1f5d3f 2bd5f676-e86c-4cb4-bdaf-4afefffed3f4 0x16edb0e94d0baa4d0a528b501e9dcffbd7752d5d
This returns firstly the unique ID of the wallet, as well as the public address.
Go to a public faucet - for example, the public ropsten faucet - and send to the address of the user's wallet.
Now, once the transfer has been confirmed, you can see the balances of the user's wallet:
upvest -e my_example_name user --login test_username --password test_password listwallets 2bd5f676-e86c-4cb4-bdaf-4afefffed3f4 0x16edb0e94d0baa4d0a528b501e9dcffbd7752d5d deaaa6bf-d944-57fa-8ec4-2dd45d1f5d3f Ether (Ropsten) 1000000000000000000 10^18
This returns the unique wallet ID followed by the public address, then a balance of each of the tokens the wallet can hold. In this case, the balance is 1*10^18.
Now that you have a wallet containing some tokens, you can send them to another wallet. For example, to send the tokens back to the faucet wallet:
# example: upvest -e my_example_name user -l test_username -w test_password send <walletid> <assetid> <quantity> <fee> <recipient> # real transaction: upvest -e my_example_name user -l test_username -w test_password send 2bd5f676-e86c-4cb4-bdaf-4afefffed3f4 deaaa6bf-d944-57fa-8ec4-2dd45d1f5d3f 900000000000000000 5000000000 0x687422eea2cb73b5d3e242ba5456b782919afc85 Transaction successfully created: 0xa536ffdfcee7d6cf49bd68eb8186089dd7588797daf8b9e8db88a84a732e8cf2
This will return the transaction ID.
The Upvest CLI is meant as a simple tool to test and inspect how the Upvest API works and responds.
This CLI tool uses the Upvest Python SDK however there are tools for other languages too. Happy hacking!
Updated 4 months ago