Rust Bot SDK
Bot traders interact with the CrypDefi backend via API calls. To simplify authentication and transaction signing, the Bot SDK can be used instead of manually managing individual API requests.
Create keys for the Bot login.
Generate Bot's private key
Generate Bot's public key
Examples
Instantiating a Bot
use Bot;
use fs;
// --------------------------- CONFIG ---------------------------
// Replace with your bot's user_id.
let user_id = "us-0000000000-94518ea57547afd340c3";
// Replace with the wallet_id of the wallet you want to trade with.
let wallet_id = "wa-0000000000-9f3542a65690ff697b85";
// This is the bot's private key used to authenticate with CrypDefi (not the wallet's private key).
let private_key_pem = read_to_string.expect;
let bot = new.unwrap;
println!;
// --------------------------- LOGIN WITH BOT ---------------------------
// if you turn off auto_refresh the bot will not automatically re-authenticate itself when its login-token is about to expire
bot.login.await.unwrap;
Getting values from the Bot
// **Note:** Bot should already be instantiated and logged in.
// --------------------------- Check for expiration time of AUTH ---------------------------
let expiration = bot.auth_expiration_unix_time.await;
println!;
// --------------------------- FETCH ASSOCIATED WALLETS ---------------------------
let wallets = bot.get_wallets.await.unwrap;
println!;
Bot Actions
// **Note:** Bot should already be instantiated and logged in.
// --------------------------- CREATE & SIGN TRANSACTION ---------------------------
println!;
// Include steps to create transaction here. Replace hex below with the actual hex string of the transaction to sign.
let example_evm_hex = "02f8af01018390f560850461933067828cb394a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4880b844095ea7b300000000000000000000000097802f38a37e1d789eba194513e3eb7e918d34df000000000000000000000000000000000000000000000000000000001dcd6500c001a0ad0b4a87309ef94b96d38f145d676d971ca1f1e4702c9cace99fdec8df4a8814a008651a171f31629bcf3a686ca26b9d3cece44c6dfec39fb2c1848e3b290ba121";
println!;
// Sign the transaction using the wallet that was configured. Make sure the bot has access to this wallet in the Management UI.
let signature = bot.sign_transaction.await.unwrap;
println!;
// --------------------------- REFRESH SESSION ---------------------------
println!;
let refresh_result = bot.refresh.await.unwrap;
println!;
// --------------------------- LOGOUT ---------------------------
let logout_result = bot.logout.await.unwrap;
println!;
Contributors
This are commands and tools for developers of the SDK.
You will need to have the static library somewhere in the file system.
Building library locally
Run:
run example bot
This runs a very simple main function with the basic functionality of the SDK