# Create Transactions Signing programmatic transactions requires running your own API Signer. [Learn more](/developers/program-overview) about the feature before you get started with creating transactions. To programmatically create a transaction, call the [Create Transaction](/api/openapi/transactions/create_transaction_api_v1_transactions_post) API by sending a `POST` request to the `/api/v1/transactions` endpoint. In the request, specify the **origin vault** of the transaction, the designated **signer** (`api_signer` for programmatic transactions), the **type** of the transaction, and the **details** of the transaction. ## Request signing Since creating a transacton is a sensitive operation, it requires signing the request. The following examples demonstrate how to create and sign a basic bitcoin transfer in different programming languages. [Learn more](/developers/authentication) about request signing. Shell ```shell #!bash ACCESS_TOKEN='' PRIVATE_KEY_FILE='' ENDPOINT='' BODY='' TIMESTAMP="$(($(date +%s) * 1000))" SIGNATURE="$(echo -n "${ENDPOINT}|${TIMESTAMP}|${BODY}" | openssl dgst -sha256 -sign ${PRIVATE_KEY_FILE} | base64 | tr -d \\n)" echo -n "${ENDPOINT}|${TIMESTAMP}|${BODY}" curl -v "https://api.fordefi.com${ENDPOINT}" \ -H "Authorization: Bearer ${ACCESS_TOKEN}" \ -H "Content-Type: application/json" \ -H "x-signature: ${SIGNATURE}" \ -H "x-timestamp: ${TIMESTAMP}" \ -d "${BODY}" ``` Python ```py import requests import base64 import json import datetime import ecdsa import hashlib access_token = "" private_key_file = "" path = "" request_json = timestamp = datetime.datetime.now().strftime("%s") request_body = json.dumps(request_json) payload = f"{path}|{timestamp}|{request_body}" with open(private_key_file, "r") as f: signing_key = ecdsa.SigningKey.from_pem(f.read()) signature = signing_key.sign( data=payload.encode(), hashfunc=hashlib.sha256, sigencode=ecdsa.util.sigencode_der ) resp_tx = requests.post( f"https://api.fordefi.com{path}", headers={ "Authorization": f"Bearer {access_token}", "x-signature": base64.b64encode(signature), "x-timestamp": timestamp.encode(), }, data=request_body, ) ``` Javascript ```js const crypto = require("crypto"); const fs = require('fs'); const accessToken = "" const privateKeyFile = "" const path = "" const requestJson = const gatewayHost = "api.fordefi.com" const requestBody = JSON.stringify(requestJson) const timestamp = new Date().getTime(); const payload = `${path}|${timestamp}|${requestBody}`; const secretPem = fs.readFileSync(privateKeyFile, 'utf8'); const privateKey = crypto.createPrivateKey(secretPem); const sign = crypto.createSign('SHA256').update(payload, 'utf8').end(); const signature = sign.sign(privateKey, 'base64'); fetch(`https://${gatewayHost}${path}`, { method: 'POST', headers: { 'Content-Type': 'application/json', "Authorization": `Bearer ${accessToken}`, 'X-Timestamp': timestamp, 'X-Signature': signature, }, body: requestBody, }).then((response) => response.text()) .then((json) => console.log(json)); ``` Rust ```rust // Using crate p256 = { version = "0.12.0", features = ["pem"] } use base64::{engine::general_purpose, Engine as _}; use p256::ecdsa::{signature::Signer, Signature, SigningKey}; use std::fs; use std::time::{SystemTime, UNIX_EPOCH}; // This is the main function fn main() -> Result<(), Box> { let access_token = ""; let private_key_file = ""; let path = ""; let request_body = r#" "#; let gateway_host = "api.fordefi.com"; let timestamp = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_millis() .to_string(); let payload = format!("{path}|{timestamp}|{request_body}"); let priv_pem = fs::read_to_string(private_key_file).expect("Failed to read pem file"); let private_key = p256::SecretKey::from_sec1_pem(&priv_pem).expect("Failed to decode pem key"); let signing_key: SigningKey = private_key.into(); let signature: Signature = signing_key.sign(payload.as_bytes()); let formatted_signature = general_purpose::STANDARD.encode(signature.to_der().to_bytes()); let client = reqwest::blocking::Client::new(); let res = client .post(format!("https://{gateway_host}{path}")) .body(request_body) .bearer_auth(access_token) .header("Content-Type", "application/json") .header("X-Timestamp", timestamp) .header("X-Signature", formatted_signature) .send()? .text()?; println!("Result: {res}"); Ok(()) } ``` ## Transaction Types Fordefi supports several main categories of transactions across its supported blockchains: ### Transfers Simple transfers between addresses. All chains support basic transfers: [EVM](/developers/transaction-types/evm-transfers), [Solana](/developers/transaction-types/solana-transfers), [Bitcoin](/developers/transaction-types/bitcoin-transfers), Cosmos, [Sui](/developers/transaction-types/sui-transfers), Aptos, [TON](/developers/transaction-types/ton-transfers), Starknet, [Stacks](/developers/transaction-types/stacks-transfers), [TRON](/developers/transaction-types/tron-transfers). [Learn more](/developers/transaction-types/transfers). ### Exchange deposits and withdrawals Fordefi supports easily moving funds between your connected exchange accounts and your Fordefi vaults. [Learn more](/developers/transaction-types/exchanges). ### Raw transactions Smart contract calls and arbitrary raw transactions: [EVM](/developers/transaction-types/evm-smart-contract-calls), [Solana](/developers/transaction-types/solana-raw-transactions), [Bitcoin](/developers/transaction-types/bitcoin-psbt), [Cosmos](/developers/transaction-types/cosmos-raw-transaction), [Sui](/developers/transaction-types/sui-programmable-transaction-block), [Aptos](/developers/transaction-types/aptos-payload-transaction), [TON](/developers/transaction-types/ton-transactions), [Starknet](/developers/transaction-types/starknet-raw-transaction), [Stacks](/developers/transaction-types/stacks-transactions), TRON (coming soon!) ### Messages Message signing and verification: [EVM chains](/developers/transaction-types/evm-message-signature), Solana, Cosmos, Aptos, Sui, TON, Starknet, Bitcoin ### Blackbox signatures Fordefi enables users to leverage Fordefi's MPC technology to sign arbitrary blobs. [Learn more](/developers/transaction-types/black-box-signing).