Using the CLI
This quickstart will guide you through Turnkey’s onboarding, adding an API key, creating a wallet, and signing your first Ethereum transaction.
Create your Turnkey Organization
- Visit app.turnkey.com/dashboard/auth/initial and enter your email address
- Confirm your email by clicking on the link inside of the confirmation email
- Follow the prompts to add your first authenticator and create your organization
Find your Organization ID
All API requests require an organization ID. Yours can be located in the user dropdown menu at the top right corner of the dashboard.
For convenience, it's worth setting this as a permanent shell variable:
export ORGANIZATION_ID="<Your Org ID>"
Add an API key
Turnkey API Keys are generic public / private key pairs that allow you to make requests to our API. To generate a new key pair, we'll use the Turnkey CLI.
Installing turnkey
brew install tkhq/tap/turnkey
We are employing Homebrew in this guide as a quick and easy install path. For an installation path that requires no trust in external parties, refer to our CLI repo.
Generate an API key
turnkey generate api-key --organization $ORGANIZATION_ID --key-name quickstart
When you run this command, Turnkey’s CLI generates an API key pair and stores the API private key locally. Copy the publicKey
field in the output. In the next step, we'll add this to our User.
Add your public API key
Navigate to your user page by clicking on "User Details" in the user dropdown menu.
Click on "Create API keys" and follow the prompts to add the generated public API key. You'll be required to authenticate with the same authenticator used during onboarding. After this succeeds, you should be all set to interact with our API.
NOTE: if you would like to manually your locally stored public/private API key files (e.g. key.public
, key.private
), you will have to save the files without newlines (which occupy extra bytes). For example, for VIM, use :set binary noeol
or :set binary noendofline
before writing.
Create a Wallet
Wallets are collections of cryptographic key pairs typically used for sending and receiving digital assets. To create one, we need to provide a name:
turnkey wallets create --name default --key-name quickstart
Create an Ethereum account
To create a cryptographic key pair on our new Wallet, we need to pass our desired address format:
turnkey wallets accounts create --wallet default --address-format ADDRESS_FORMAT_ETHEREUM --key-name quickstart
This command will produce an Ethereum address (e.g. 0x08cb1216C95149DF66978b574E484869512CE2bF
) that we'll need to sign a transaction. You can see your new Wallet account with:
turnkey wallets accounts list --wallet default --key-name quickstart
Sign a Transaction
Now you can sign an Ethereum transaction with this new address with our sign_transaction
endpoint. Make sure to replace the unsignedTransaction
below with your own. You can use our simple transaction generator if you need a quick transaction for testing:
turnkey request --path /public/v1/submit/sign_transaction --body '{
"timestampMs": "'"$(date +%s)"'000",
"type": "ACTIVITY_TYPE_SIGN_TRANSACTION_V2",
"organizationId": "'"$ORGANIZATION_ID"'",
"parameters": {
"type": "TRANSACTION_TYPE_ETHEREUM",
"signWith": "<Your Ethereum address>",
"unsignedTransaction": "<Your Transaction>"
}
}' --key-name quickstart
If you'd like to broadcast your transaction, you can easily do so via Etherscan.
Next Steps
- Check out our examples to see what can be built
- Learn more about Organizations and Wallets
- See our API design or dive into our API reference