Introduction
Welcome to the Triangle API documentation.
https://api.triangleplatform.com
npm install triangle
Authentication
The Triangle API uses API keys to authenticate requests. You can view and manage your API keys in the Triangle Dashboard.
Authentication to the API can be performed via HTTP Basic or Bearer authentication scheme. For Basic auth, provide your API key as the basic auth username value (you do not need to provide a password). For Bearer auth, provide your API key as the bearer token in the Authorization header.
import Triangle from "triangle";
const triangle = new Triangle("secret_abc123");
Errors
This is an object representing an error.
interface Error {
object: string;
message: string;
}
{
"object": "error",
"message": "Something went wrong."
}
Idempotency
The API supports idempotency so that requests can be safely retried without accidentally performing the same operation twice.
To perform an idemponent request, provide the Idempotency-Key
header with a unique string (such as v4 UUIDs). If the request is valid, the request and response will be saved under the given idempotency key. Subsequent request with the same key will return the same response. Keys are scheduled to be removed automatically after they're at least 24 hours old.
All POST
requests accept idempotency keys. Sending idempotency keys in all other HTTP methods are ignored.
Pagination
This is an object representing a page of objects.
interface List<T> {
object: string;
items: T[];
total: number;
}
{
"object": "list",
"items": [
...
],
"total": 3
}
Versioning
Triangle maintains backwards-compatibility in our API. When backwards-incompatible changes are made to the API, we will document our changelog here.
Rate Limiting
Sending too many requests might result in receiving error responses with status code 429
.
Webhooks
You can create a webhook on the Triangle Dashboard and we'll push the event data to your endpoint.
const event = triangle.utils.webhooks.construct(
req.body,
req.headers["triangle-signature"],
"whsec_abc123"
);
const isVerified = triangle.utils.webhooks.verify(
req.body,
req.headers["triangle-signature"],
"whsec_abc123"
);
import { buffer } from "micro";
import Triangle from "triangle";
const triangle = new Triangle("secret_abc123");
export default async (req, res) => {
const body = await buffer(req);
const event = triangle.utils.webhooks.construct(body, req.headers["triangle-signature"], "whsec_abc123");
switch (event.type) {
case "account.tx.to":
// Do something
break;
case "transaction.tx.hash":
// Do something
break;
case "wallet.tx.from":
// Do something
break;
default:
console.log("Unhandled event type:", event.type);
}
return res.status(200).json({ message: "Success." });
};
Chains
This is an object representing a chain.
- AlgorandalgorandThe Algorand blockchain.
- AptosaptosThe Aptos blockchain.
- ArbitrumarbitrumThe Arbitrum blockchain.
- AstarastarThe Astar blockchain.
- AuroraauroraThe Aurora blockchain.
- Avalanche C-ChainavalancheThe Avalanche C-Chain blockchain.
- BasebaseThe Base blockchain.
- BitcoinbitcoinThe Bitcoin blockchain.
- BNB Smart ChainbnbsmartchainThe BNB Smart Chain blockchain.
- BobabobaThe Boba blockchain.
- CantocantoThe Canto blockchain.
- CardanocardanoThe Cardano blockchain.
- CeloceloThe Celo blockchain.
- CronoscronosThe Cronos blockchain.
- DogecoindogecoinThe Dogecoin blockchain.
- EthereumethereumThe Ethereum blockchain.
- EvmosevmosThe Evmos blockchain.
- FantomfantomThe Fantom blockchain.
- FilecoinfilecoinThe Filecoin blockchain.
- FlowflowThe Flow blockchain.
- FrameframeThe Frame blockchain.
- FuelfuelThe Fuel blockchain.
- Gnosis ChaingnosisThe Gnosis Chain blockchain.
- HarmonyharmonyThe Harmony blockchain.
- KlaytnklaytnThe Klaytn blockchain.
- KusamakusamaThe Kusama blockchain.
- MoonbeammoonbeamThe Moonbeam blockchain.
- MoonrivermoonriverThe Moonriver blockchain.
- NEARnearThe NEAR blockchain.
- OptimismoptimismThe Optimism blockchain.
- PolkadotpolkadotThe Polkadot blockchain.
- PolygonpolygonThe Polygon blockchain.
- Polygon zkEVMpolygonzkevmThe Polygon zkEVM blockchain.
- ScrollscrollThe Scroll blockchain.
- SeiseiThe Sei blockchain.
- SkaleskaleThe Skale blockchain.
- SolanasolanaThe Solana blockchain.
- StacksstacksThe Stacks blockchain.
- StellarstellarThe Stellar blockchain.
- SuisuiThe Sui blockchain.
- TerraterraThe Terra blockchain.
- XRPxrpThe XRP blockchain.
- ZetaChainzetachainThe ZetaChain blockchain.
- zkSynczksyncThe zkSync blockchain.
The chain object
- idstringThe unique identifier for the object.
- namestringThe name of the chain.
- symbolstringThe symbol of the native token.
interface Chain {
id: string;
object: string;
name: string;
symbol: string;
}
{
"id": "ethereum",
"object": "chain",
"name": "Ethereum",
"symbol": "ETH"
}
Retrieve a chain
Retrieves the chain with the given ID.
const chain = await triangle.chains.retrieve(
"ethereum"
);
{
"id": "ethereum",
"object": "chain",
"name": "Ethereum",
"symbol": "ETH"
}
List all chains
Returns a list of all the chains supported on Triangle.
const chains = await triangle.chains.list();
{
"object": "list",
"items": [
{
"id": "ethereum",
"object": "chain",
"name": "Ethereum",
"symbol": "ETH"
}
]
}
Networks
This is an object representing a network on a chain.
- Algorand Betanetalgorand_betanetThe Betanet network on the Algorand blockchain.
- Algorand Mainnetalgorand_mainnetThe Mainnet network on the Algorand blockchain.
- Algorand Testnetalgorand_testnetThe Testnet network on the Algorand blockchain.
- Aptos Devnetaptos_devnetThe Devnet network on the Aptos blockchain.
- Aptos Mainnetaptos_mainnetThe Mainnet network on the Aptos blockchain.
- Aptos Testnetaptos_testnetThe Testnet network on the Aptos blockchain.
- Arbitrum Goerliarbitrum_goerliThe Goerli network on the Arbitrum blockchain.
- Arbitrum Mainnetarbitrum_mainnetThe Mainnet network on the Arbitrum blockchain.
- Arbitrum Rinkebyarbitrum_rinkebyThe Rinkeby network on the Arbitrum blockchain. This network has been deprecated on October 5, 2022.
- Astar Mainnetastar_mainnetThe Mainnet network on the Astar blockchain.
- Astar Shibuyaastar_shibuyaThe Shibuya network on the Astar blockchain.
- Aurora Mainnetaurora_mainnetThe Mainnet network on the Aurora blockchain.
- Aurora Testnetaurora_testnetThe Testnet network on the Aurora blockchain.
- Avalanche C-Chain Fujiavalanche_fujiThe Fuji network on the Avalanche C-Chain blockchain.
- Avalanche C-Chain Mainnetavalanche_mainnetThe Mainnet network on the Avalanche C-Chain blockchain.
- Base Goerlibase_goerliThe Goerli network on the Base blockchain.
- Base Mainnetbase_mainnetThe Mainnet network on the Base blockchain.
- Bitcoin Mainnetbitcoin_mainnetThe Mainnet network on the Bitcoin blockchain.
- Bitcoin Testnetbitcoin_testnetThe Testnet network on the Bitcoin blockchain.
- BNB Smart Chain Mainnetbnbsmartchain_mainnetThe Mainnet network on the BNB Smart Chain blockchain.
- BNB Smart Chain Testnetbnbsmartchain_testnetThe Testnet network on the BNB Smart Chain blockchain.
- Boba Mainnetboba_mainnetThe Mainnet network on the Boba blockchain.
- Boba Testnetboba_testnetThe Testnet network on the Boba blockchain.
- Canto Mainnetcanto_mainnetThe Mainnet network on the Canto blockchain.
- Canto Testnetcanto_testnetThe Testnet network on the Canto blockchain.
- Cardano Mainnetcardano_mainnetThe Mainnet network on the Cardano blockchain.
- Cardano Pre-Prodcardano_preprodThe Pre-Prod network on the Cardano blockchain.
- Cardano Previewcardano_previewThe Preview network on the Cardano blockchain.
- Celo Alfajorescelo_alfajoresThe Alfajores network on the Celo blockchain.
- Celo Baklavacelo_baklavaThe Baklava network on the Celo blockchain.
- Celo Mainnetcelo_mainnetThe Mainnet network on the Celo blockchain.
- Cronos Mainnetcronos_mainnetThe Mainnet network on the Cronos blockchain.
- Cronos Testnetcronos_testnetThe Testnet network on the Cronos blockchain.
- Dogecoin Mainnetdogecoin_mainnetThe Mainnet network on the Dogecoin blockchain.
- Dogecoin Testnetdogecoin_testnetThe Testnet network on the Dogecoin blockchain.
- Ethereum Goerliethereum_goerliThe Goerli network on the Ethereum blockchain.
- Ethereum Holeskyethereum_holeskyThe Holesky network on the Ethereum blockchain.
- Ethereum Kovanethereum_kovanThe Kovan network on the Ethereum blockchain. This network has been deprecated on October 5, 2022.
- Ethereum Mainnetethereum_mainnetThe Mainnet network on the Ethereum blockchain.
- Ethereum Rinkebyethereum_rinkebyThe Rinkeby network on the Ethereum blockchain. This network has been deprecated on October 5, 2022.
- Ethereum Ropstenethereum_ropstenThe Ropsten network on the Ethereum blockchain. This network has been deprecated on October 5, 2022.
- Ethereum Sepoliaethereum_sepoliaThe Sepolia network on the Ethereum blockchain.
- Evmos Mainnetevmos_mainnetThe Mainnet network on the Evmos blockchain.
- Evmos Testnetevmos_testnetThe Testnet network on the Evmos blockchain.
- Fantom Mainnetfantom_mainnetThe Mainnet network on the Fantom blockchain.
- Fantom Testnetfantom_testnetThe Testnet network on the Fantom blockchain.
- Filecoin Calibrationfilecoin_calibrationThe Calibration network on the Filecoin blockchain.
- Filecoin Hyperspacefilecoin_hyperspaceThe Hyperspace network on the Filecoin blockchain.
- Filecoin Mainnetfilecoin_mainnetThe Mainnet network on the Filecoin blockchain.
- Filecoin Wallabyfilecoin_wallabyThe Wallaby network on the Filecoin blockchain.
- Flow Mainnetflow_mainnetThe Mainnet network on the Flow blockchain.
- Flow Testnetflow_testnetThe Testnet network on the Flow blockchain.
- Frame Testnetframe_testnetThe Testnet network on the Frame blockchain.
- Fuel Beta-1fuel_beta1The Beta-1 network on the Fuel blockchain.
- Fuel Beta-2fuel_beta2The Beta-2 network on the Fuel blockchain.
- Fuel Beta-3fuel_beta3The Beta-3 network on the Fuel blockchain.
- Fuel Beta-4fuel_beta4The Beta-4 network on the Fuel blockchain.
- Gnosis Chain Chiadoharmony_chiadoThe Chiado network on the Gnosis Chain blockchain.
- Gnosis Chain Mainnetharmony_mainnetThe Mainnet network on the Gnosis Chain blockchain.
- Harmony Mainnetharmony_mainnetThe Mainnet network on the Harmony blockchain.
- Harmony Testnetharmony_testnetThe Testnet network on the Harmony blockchain.
- Klaytn Baobabklaytn_baobabThe Baobab network on the Klaytn blockchain.
- Klaytn Mainnetklaytn_mainnetThe Mainnet network on the Klaytn blockchain.
- Kusama Mainnetkusama_mainnetThe Mainnet network on the Kusama blockchain.
- Moonbeam Mainnetmoonbeam_mainnetThe Mainnet network on the Moonbeam blockchain.
- Moonbeam Testnetmoonbeam_testnetThe Testnet network on the Moonbeam blockchain.
- Moonriver Mainnetmoonriver_mainnetThe Mainnet network on the Moonriver blockchain.
- Optimism Goerlioptimism_goerliThe Goerli network on the Optimism blockchain.
- Optimism Kovanoptimism_kovanThe Kovan network on the Optimism blockchain. This network has been deprecated on October 5, 2022.
- Optimism Mainnetoptimism_mainnetThe Mainnet network on the Optimism blockchain.
- Polkadot Mainnetpolkadot_mainnetThe Mainnet network on the Polkadot blockchain.
- Polkadot Rococopolkadot_rococoThe Rococo network on the Polkadot blockchain.
- Polkadot Westendpolkadot_westendThe Westend network on the Polkadot blockchain.
- Polygon Amoypolygon_amoyThe Amoy network on the Polygon blockchain.
- Polygon Mainnetpolygon_mainnetThe Mainnet network on the Polygon blockchain.
- Polygon Mumbaipolygon_mumbaiThe Mumbai network on the Polygon blockchain.
- Polygon zkEVM Mainnetpolygonzkevm_mainnetThe Mainnet network on the Polygon zkEVM blockchain.
- Polygon zkEVM Testnetpolygonzkevm_testnetThe Testnet network on the Polygon zkEVM blockchain.
- Scroll Alphascroll_alphaThe Alpha network on the Scroll blockchain.
- Scroll Sepoliascroll_sepoliaThe Sepolia network on the Scroll blockchain.
- Sei Testnetsei_testnetThe Testnet network on the Sei blockchain.
- Solana Devnetsolana_devnetThe Devnet network on the Solana blockchain.
- Solana Mainnet Betasolana_mainnet_betaThe Mainnet Beta network on the Solana blockchain.
- Solana Testnetsolana_testnetThe Testnet network on the Solana blockchain.
- Stacks Mainnetstacks_mainnetThe Mainnet network on the Stacks blockchain.
- Stacks Testnetstacks_testnetThe Testnet network on the Stacks blockchain.
- Stellar Mainnetstellar_mainnetThe Mainnet network on the Stellar blockchain.
- Stellar Testnetstellar_testnetThe Testnet network on the Stellar blockchain.
- Sui Devnetsui_devnetThe Devnet network on the Sui blockchain.
- Sui Testnetsui_testnetThe Testnet network on the Sui blockchain.
- Terra Classicterra_classicThe Classic network on the Terra blockchain.
- Terra Mainnetterra_mainnetThe Mainnet network on the Terra blockchain.
- Terra Testnetterra_testnetThe Testnet network on the Terra blockchain.
- XRP Mainnetxrp_mainnetThe Mainnet network on the XRP blockchain.
- XRP Testnetxrp_testnetThe Testnet network on the XRP blockchain.
- ZetaChain Athens-2zetachain_athens2The Athens-2 network on the ZetaChain blockchain.
- ZetaChain Athens-3zetachain_athens3The Athens-3 network on the ZetaChain blockchain.
- zkSync Mainnetzksync_mainnetThe Mainnet network on the zkSync blockchain.
- zkSync Testnetzksync_testnetThe Testnet network on the zkSync blockchain.
The network object
- idstringThe unique identifier for the object.
- chainChainThe chain this network is on.
- mainnetbooleanWhether the network is the mainnet.
- namestringThe name of the network.
interface Network {
id: string;
object: string;
chain: Chain;
mainnet: boolean;
name: string;
}
{
"id": "ethereum_goerli",
"object": "network",
"chain": {
"id": "ethereum"
},
"mainnet": false,
"name": "Ethereum Goerli"
}
Retrieve a network
Retrieves the network with the given ID.
const network = await triangle.networks.retrieve(
"ethereum_goerli"
);
{
"id": "ethereum_goerli",
"object": "network",
"chain": {
"id": "ethereum"
},
"mainnet": false,
"name": "Ethereum Goerli"
}
List all networks
Returns a list of all the networks supported on Triangle.
const networks = await triangle.networks.list();
{
"object": "list",
"items": [
{
"id": "ethereum_goerli",
"object": "network",
"chain": {
"id": "ethereum"
},
"mainnet": false,
"name": "Ethereum Goerli"
}
]
}
Vaults
This is an object representing a vault.
A vault is used to generate keys to create a group of wallets. You can think of this just like how Ledger or any other consumer wallet generates a single key that is used to create many wallets.
The vault object
- idstringThe unique identifier for the object.
- namestringThe name of the vault.
interface Vault {
id: string;
object: string;
name: string;
}
{
"id": "vlt_abc123",
"object": "vault",
"name": "My Vault"
}
Create a vault
Creates a new vault.
- namestringThe name of the vault.
- Returns the vault object.
const vault = await triangle.vaults.create({
name: "My Vault",
});
{
"id": "vlt_abc123",
"object": "vault",
"name": "My Vault"
}
Retrieve a vault
Retrieves the vault with the given ID.
const vault = await triangle.vaults.retrieve(
"vlt_abc123"
);
{
"id": "vlt_abc123",
"object": "vault",
"name": "My Vault"
}
List all vaults
Returns a list of your vaults.
const vaults = await triangle.vaults.list();
{
"object": "list",
"items": [
{
"id": "vlt_abc123",
"object": "vault",
"name": "My Vault"
}
]
}
Export a vault
Exports the vault with the given ID.
const data = await triangle.vaults.export(
"vlt_abc123"
);
{
"mnemonic": "..."
}
Wallets
This is an object representing a wallet in a vault.
A wallet is an just like an externally-owned account (EOA). You can use it just like any other wallet to sign and send any transaction to the network.
The wallet object
- idstringThe unique identifier for the object.
- addressstringThe address of the wallet.
- namestringThe name of the wallet.
- networkNetworkThe network the wallet is on.
- vaultVaultThe vault this wallet is in.
interface Wallet {
id: string;
object: string;
address: string;
name: string;
network: Network;
vault: Vault;
}
{
"id": "wlt_abc123",
"object": "wallet",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Wallet",
"network": {
"id": "ethereum_goerli"
},
"vault": {
"id": "vlt_abc123"
}
}
Create a wallet
Creates a new wallet in the given vault.
- namestringThe name of the wallet.
- networkstringThe ID of the network to create this wallet is on.
- vaultstringThe ID of the vault to create this wallet is in.
- Returns the wallet object.
const wallet = await triangle.wallets.create({
name: "My Wallet",
network: "ethereum_goerli",
vault: "vlt_abc123",
});
{
"id": "wlt_abc123",
"object": "wallet",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Wallet",
"network": {
"id": "ethereum_goerli"
},
"vault": {
"id": "vlt_abc123"
}
}
Retrieve a wallet
Retrieves the wallet with the given ID.
const wallet = await triangle.wallets.retrieve(
"wlt_abc123"
);
{
"id": "wlt_abc123",
"object": "wallet",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Wallet",
"network": {
"id": "ethereum_goerli"
},
"vault": {
"id": "vlt_abc123"
}
}
List all wallets
Returns a list of your wallets.
- vaultstring, optionalOnly return wallets for the vault specified by this vault ID.
const wallets = await triangle.wallets.list();
{
"object": "list",
"items": [
{
"id": "wlt_abc123",
"object": "wallet",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Wallet",
"network": {
"id": "ethereum_goerli"
},
"vault": {
"id": "vlt_abc123"
}
}
]
}
Retrieve a wallet's balance
Retrieves the balance of the native currency in the wallet.
const balance = await triangle.wallets.balance(
"wlt_abc123"
);
{
"balance": "1.23",
"logo_url": "https://...",
"name": "Ethereum",
"symbol": "ETH"
}
List a wallet's NFTs
Returns a list of the NFTs in the wallet.
const nfts = await triangle.wallets.nfts(
"wlt_abc123"
);
{
"object": "list",
"items": [
{
"contract": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
"image_url": "https://...",
"name": "Bored Ape Yacht Club #123",
"symbol": "BAYC",
"token_id": "123",
"type": "erc721"
}
]
}
List a wallet's tokens
Returns a list of the tokens in the wallet.
const tokens = await triangle.wallets.tokens(
"wlt_abc123"
);
{
"object": "list",
"items": [
{
"contract": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"balance": "1.23",
"logo_url": "https://...",
"name": "Dai",
"symbol": "DAI"
}
]
}
Send native currency
Sends the native currency.
- amountstringThe amount of the native currency.
- tostringThe address to send the native currency to.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.send(
"wlt_abc123",
{
amount: "0.123",
to: "0x...",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Send an NFT
Sends an NFT.
- amountstring, optional, default "1"The amount of the NFT. This is only applicable to ERC-1155 NFTs as described in the EIP-1155 specification.
- contractstringThe contract address of the NFT.
- tostringThe address to send the NFT to.
- token_idstringThe token ID of the NFT.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.sendNft(
"wlt_abc123",
{
contract: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
to: "0x...",
token_id: "123",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Send a token
Sends a token.
- amountstringThe amount of the token.
- contractstringThe contract address of the token.
- tostringThe address to send the token to.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.sendToken(
"wlt_abc123",
{
amount: "0.123",
contract: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
to: "0x...",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Check token approval
Check token approval.
- contract_addressstringThe contract address or symbol of the token.
- tostringThe address to check token approval for.
- Returns boolean.
const transaction = await triangle.wallets.is_token_approved(
"wlt_abc123",
{
contract_address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
to: "0x...",
}
);
true
Approve a token
Approves a token.
- contract_addressstringThe contract address or symbol of the token.
- tostringThe address to give token approval to.
- amountstringThe amount of the token.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.approve_token(
"wlt_abc123",
{
contract_address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
to: "0x...",
amount: "1",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Approves all a token
Approves all a token.
- contract_addressstringThe contract address or symbol of the token.
- tostringThe address to give token approval to.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.approve_token_all(
"wlt_abc123",
{
contract_address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
to: "0x...",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Swap a token
Swaps a token.
- from_tokenstringThe contract address or symbol of the token to swap from.
- to_tokenstringThe contract address or symbol of the token to swap to.
- amountstringThe amount of the token.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.swap(
"wlt_abc123",
{
from_token: "ETH",
to_token: "USDC",
amount: "1",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Bridge a token
Bridges a token.
- contract_addressstringThe contract address or symbol of the token.
- from_tokenstringThe contract address or symbol of the token to bridge from.
- to_tokenstringThe contract address or symbol of the token to bridge to.
- to_networkstringThe target network to bridge to.
- amountstringThe amount of the token.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.bridge(
"wlt_abc123",
{
contract_address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
from_token: "ETH",
to_token: "USDC",
to_network: "polygon_mainnet",
amount="1",
}
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Send a transaction
Signs a transaction using the wallet and broadcasts it to the blockchain.
- serializedstringThe serialized transaction to send using this wallet.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.sendTransaction(
"wlt_abc123",
{ serialized: "..." }
);
{
"id": "vlt_abc123",
"object": "vault",
"name": "My Vault"
}
Sign a transaction
Signs a transaction using the wallet.
- serializedstringThe serialized transaction to sign using this wallet.
- Returns an object containing the raw transaction.
const transaction = await triangle.wallets.signTransaction(
"wlt_abc123",
{ serialized: "..." }
);
{
"id": "txn_abc123",
"object": "transaction",
"raw": "...",
"serialized": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Send a raw transaction
Broadcasts a signed transaction to the blockchain.
- transactionstringThe ID of the signed transaction to send.
- Returns an object containing the transaction hash.
const transaction = await triangle.wallets.sendRawTransaction(
"wlt_abc123",
{ transaction: "txn_abc123" }
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"raw": "...",
"serialized": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Sign a message
Signs a message using the wallet.
Signing messages can be used for various methods of authentication and offchain operations (can be put onchain if necessary). It allows you to verify that a piece of data was signed by a specific wallet and is used as a way to prove that a wallet approved a message. Signing a message does not require interacting with the blockchain network.
- messagestringThe message to sign using this wallet.
- Returns an object containing the signature.
const message = await triangle.wallets.signMessage(
"wlt_abc123",
{ message: "hello world" }
);
{
"id": "msg_abc123",
"object": "message",
"message": "hello world",
"signature": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Sign typed data
Signs typed data using the wallet.
This follows the EIP-712 specification and is only supported on EVM-compatible chains.
- encodedstringThe encoded typed data to sign.
- Returns an object containing the signature.
const message = await triangle.wallets.signTypedData(
"wlt_abc123",
{ encoded: "0x..." }
);
{
"id": "msg_abc123",
"object": "message",
"encoded": "0x...",
"signature": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Export a wallet
Exports the wallet with the given ID.
const data = await triangle.wallets.export(
"wlt_abc123"
);
{
"format": "hex",
"private_key": "..."
}
Accounts
This is an object representing an account.
An account is a way to reference a wallet that was created outside of Triangle. This gives you read-only controls to make it easy for you to request and receive data about any address on any blockchain.
The account object
- idstringThe unique identifier for the object.
- addressstringThe address of the account.
- namestringThe name of the account.
- networkNetworkThe network the account is on.
interface Account {
id: string;
object: string;
address: string;
name: string;
network: Network;
}
{
"id": "acct_abc123",
"object": "account",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Account",
"network": {
"id": "ethereum_goerli"
}
}
Add an account
Adds a new account.
- addressstringThe address of the account.
- namestringThe name of the account.
- networkstringThe ID of the network the account is on.
- Returns the account object.
const account = await triangle.accounts.add({
address: "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
name: "My Account",
network: "ethereum_goerli",
});
{
"id": "acct_abc123",
"object": "account",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Account",
"network": {
"id": "ethereum_goerli"
}
}
Retrieve an account
Retrieves the account with the given ID.
const account = await triangle.accounts.retrieve(
"acct_abc123"
);
{
"id": "acct_abc123",
"object": "account",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Account",
"network": {
"id": "ethereum_goerli"
}
}
List all accounts
Returns a list of your accounts.
const accounts = await triangle.accounts.list();
{
"object": "list",
"items": [
{
"id": "acct_abc123",
"object": "account",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"name": "My Account",
"network": {
"id": "ethereum_goerli"
}
}
]
}
Retrieve an account's balance
Retrieves the balance of the native currency in the account.
const balance = await triangle.accounts.balance(
"acct_abc123"
);
{
"balance": "1.23",
"logo_url": "https://...",
"name": "Ethereum",
"symbol": "ETH"
}
List an account's NFTs
Returns a list of the NFTs in the account.
const nfts = await triangle.accounts.nfts(
"acct_abc123"
);
{
"object": "list",
"items": [
{
"contract": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
"image_url": "https://...",
"name": "Bored Ape Yacht Club #123",
"symbol": "BAYC",
"token_id": "123",
"type": "erc721"
}
]
}
List an account's tokens
Returns a list of the tokens in the account.
const tokens = await triangle.accounts.tokens(
"acct_abc123"
);
{
"object": "list",
"items": [
{
"contract": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"balance": "1.23",
"logo_url": "https://...",
"name": "Dai",
"symbol": "DAI"
}
]
}
List an account's txs
Returns a list of txs from and to the account.
const txs = await triangle.accounts.txs(
"acct_abc123"
);
{
"object": "list",
"items": [
{
"object": "tx",
"block": 123,
"hash": "0x..."
}
]
}
Transactions
This is an object representing a transaction from a wallet.
The transaction object
- idstringThe unique identifier for the object.
- hashstringThe transaction hash.
- serializedstringThe serialized transaction.
- walletWalletThe wallet this transaction was from.
interface Transaction {
id: string;
object: string;
hash: string;
serialized: string;
wallet: Wallet;
}
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"raw": "...",
"serialized": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Retrieve a transaction
Retrieves the transaction with the given ID.
const transaction = await triangle.transactions.retrieve(
"txn_abc123"
);
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"raw": "...",
"serialized": "...",
"wallet": {
"id": "wlt_abc123"
}
}
List all transactions
Returns a list of your transactions.
- walletstring, optionalOnly return transactions for the wallet specified by this wallet ID.
const transactions = await triangle.transactions.list();
{
"object": "list",
"items": [
{
"id": "txn_abc123",
"object": "transaction",
"hash": "...",
"raw": "...",
"serialized": "...",
"wallet": {
"id": "wlt_abc123"
}
}
]
}
Messages
This is an object representing a message from a wallet.
The message object
- idstringThe unique identifier for the object.
- messagestringThe message.
- signaturestringThe signature of the message.
- walletWalletThe wallet this transaction was from.
interface Message {
id: string;
object: string;
message: string;
signature: string;
wallet: Wallet;
}
{
"id": "msg_abc123",
"object": "message",
"message": "hello world",
"signature": "...",
"wallet": {
"id": "wlt_abc123"
}
}
Retrieve a message
Retrieves the message with the given ID.
const message = await triangle.messages.retrieve(
"msg_abc123"
);
{
"id": "msg_abc123",
"object": "message",
"message": "hello world",
"signature": "...",
"wallet": {
"id": "wlt_abc123"
}
}
List all messages
Returns a list of your messages.
- walletstring, optionalOnly return messages for the wallet specified by this wallet ID.
const messages = await triangle.messages.list();
{
"object": "list",
"items": [
{
"id": "msg_abc123",
"object": "message",
"message": "hello world",
"signature": "...",
"wallet": {
"id": "wlt_abc123"
}
}
]
}
Addresses
This is an object representing an address.
The address object
- addressstringThe address.
- networkNetworkThe network the address is on.
interface Address {
object: string;
address: string;
network: Network;
}
{
"object": "address",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"network": {
"id": "ethereum_goerli"
}
}
Retrieve an address
Retrieves the address with the given address.
- networkstringThe ID of the network the address is on.
const address = await triangle.addresses.retrieve(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "address",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"network": {
"id": "ethereum_goerli"
}
}
Retrieve an address's balance
Retrieves the balance of the native currency in the address.
- networkstringThe ID of the network the balance is on.
const balance = await triangle.addresses.balance(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "balance",
"balance": "1.23",
"logo_url": "https://...",
"name": "Ethereum",
"symbol": "ETH"
}
List an address's NFTs
Returns a list of the NFTs in the address.
- networkstringThe ID of the network the NFTs are on.
const nfts = await triangle.addresses.nfts(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
"object": "nft",
"contract": "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D",
"image_url": "https://...",
"name": "Bored Ape Yacht Club #123",
"symbol": "BAYC",
"token_id": "123",
"type": "erc721"
}
]
}
List an address's tokens
Returns a list of the tokens in the address.
- networkstringThe ID of the network the tokens are on.
const tokens = await triangle.addresses.tokens(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
"object": "token",
"contract": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"balance": "1.23",
"logo_url": "https://...",
"name": "Dai",
"symbol": "DAI"
}
]
}
List an address's txs
Returns a list of the txs from and to the address.
- networkstringThe ID of the network the txs are on.
const txs = await triangle.addresses.txs(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
"object": "tx",
"block": {
"number": 123
},
"hash": "..."
}
]
}
List an address's transfers
Returns a list of the transfers from and to the address.
- networkstringThe ID of the network the transfers are on.
const transfers = await triangle.addresses.transfers(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
"object": "transfer",
"amount": "...",
"from": "...",
"to": "...",
"tx": {
"hash": "..."
}
}
]
}
Contracts
This is an object representing a contract.
The contract object
- addressstringThe address of the contract.
- networkNetworkThe network the contract is on.
- typestringThe type of the contract.
interface Contract {
object: string;
address: string;
network: Network;
type: string;
}
{
"object": "contract",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"network": {
"id": "ethereum_goerli"
},
"type": "erc20"
}
Retrieve a contract
Retrieves the contract with the given address.
- networkstringThe ID of the network the contract is on.
const contract = await triangle.contracts.retrieve(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "contract",
"address": "0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
"network": {
"id": "ethereum_goerli"
},
"type": "erc20"
}
List a contract's holders
Returns a list of the holders of the contract.
- networkstringThe ID of the network the holders are on.
const holders = await triangle.contracts.holders(
"0xA1B2c3d4e5F6A7B8c9D0E1F2A3b4C5D6E7f8A9B0",
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
...
}
]
}
Blocks
This is an object representing a block.
The block object
- hashstringThe block hash.
- networkNetworkThe network the block is on.
- numbernumberThe block number.
- timestampstringThe timestamp of the block.
interface Block {
object: string;
hash: string;
network: Network;
number: number;
timestamp: string;
}
{
"object": "block",
"hash": "...",
"network": {
"id": "ethereum_goerli"
},
"number": 12345678,
"timestamp": "2021-05-01T02:46:17.000Z"
}
Retrieve a block
Retrieves the block with the given number on the given network.
- networkstringThe ID of the network the block is on.
const block = await triangle.blocks.retrieve(
12345678,
{ network: "ethereum_goerli" }
);
{
"object": "block",
"hash": "...",
"network": {
"id": "ethereum_goerli"
},
"number": 12345678,
"timestamp": "2021-05-01T02:46:17.000Z"
}
List all blocks
Returns a list of the latest blocks on the given network.
- networkstringThe ID of the network the blocks are on.
const blocks = await triangle.blocks.list({
network: "ethereum_goerli",
});
{
"object": "list",
"items": [
{
"object": "block",
"hash": "...",
"network": {
"id": "ethereum_goerli"
},
"number": 12345678,
"timestamp": "2021-05-01T02:46:17.000Z"
}
]
}
List a block's txs
Returns a list of the txs in the block.
- networkstringThe ID of the network the block is on.
const txs = await triangle.blocks.txs(
12345678,
{ network: "ethereum_goerli" }
);
{
"object": "list",
"items": [
{
"object": "tx",
"block": {
"number": 12345678
},
"hash": "..."
}
]
}
Txs
This is an object representing a tx.
The tx object
- blockBlockThe block the transaction is in.
- hashstringThe transaction hash.
interface Tx {
object: string;
block: Block;
hash: string;
}
{
"object": "tx",
"block": {
"number": 12345678
},
"hash": "..."
}
Retrieve a tx
Retrieves the tx with the given hash.
- networkstringThe ID of the network the tx is on.
const tx = await triangle.txs.retrieve(
"...",
{ network: "ethereum_goerli" }
);
{
"object": "tx",
"block": {
"number": 12345678
},
"hash": "..."
}
List all txs
Returns a list of the latest txs.
- addressstring, optionalOnly return txs for the address specified by this address.
- blockstring, optionalOnly return txs for the block specified by this block number.
- networkstringThe ID of the network the txs are on.
const txs = await triangle.txs.list({
network: "ethereum_goerli",
});
{
"object": "list",
"items": [
{
"object": "tx",
"block": {
"number": 12345678
},
"hash": "..."
}
]
}
Cryptocurrencies
This is an object representing a cryptocurrency.
The cryptocurrency object
- idstringThe unique identifier for the object.
- delta_1dstringThe change in price over the last day (24 hours).
- delta_1hstringThe change in price over the last hour (60 minutes).
- delta_1wstringThe change in price over the last week (7 days).
- laststringThe last price volume-weighted across all markets.
- logo_urlstringThe url to the logo of the cryptocurrency.
- market_capstringThe market capitalization based on circulating supply.
- namestringThe name of the cryptocurrency.
- symbolstringThe symbol of the cryptocurrency.
- volumestringThe volume traded over the last 24 hours.
interface Cryptocurrency {
id: string;
object: string;
delta_1d: string;
delta_1h: string;
delta_1w: string;
last: string;
logo_url: string;
market_cap: string;
name: string;
symbol: string;
volume: string;
}
{
"id": "bitcoin",
"object": "cryptocurrency",
"delta_1d": "0.01",
"delta_1h": "0.001",
"delta_1w": "0.1",
"last": "23456.78",
"logo_url": "https://cdn.triangleplatform.com/img/128/bitcoin.png",
"market_cap": "321654987210.12",
"name": "Bitcoin",
"symbol": "BTC",
"volume": "123456789012.34"
}
Retrieve a cryptocurrency
Retrieves the cryptocurrency with the given ID.
const cryptocurrency = await triangle.cryptocurrencies.retrieve(
"bitcoin"
);
{
"id": "bitcoin",
"object": "cryptocurrency",
"delta_1d": "0.01",
"delta_1h": "0.001",
"delta_1w": "0.1",
"last": "23456.78",
"logo_url": "https://cdn.triangleplatform.com/img/128/bitcoin.png",
"market_cap": "321654987210.12",
"name": "Bitcoin",
"symbol": "BTC",
"volume": "123456789012.34"
}
List all cryptocurrencies
Returns a list of all the cryptocurrencies.
const cryptocurrencies = await triangle.cryptocurrencies.list();
{
"object": "list",
"items": [
{
"id": "bitcoin",
"object": "cryptocurrency",
"delta_1d": "0.01",
"delta_1h": "0.001",
"delta_1w": "0.1",
"last": "23456.78",
"logo_url": "https://cdn.triangleplatform.com/img/128/bitcoin.png",
"market_cap": "321654987210.12",
"name": "Bitcoin",
"symbol": "BTC",
"volume": "123456789012.34"
}
]
}
Collections
This is an object representing a collection.
The collection object
- idstringThe unique identifier for the object.
- floorstringThe floor price across all listings.
- logo_urlstringThe url to the logo of the collection.
- market_capstringThe market capitalization based on total items.
- namestringThe name of the collection.
- volumestringThe volume traded over the last 24 hours.
interface Collection {
id: string;
object: string;
floor: string;
logo_url: string;
market_cap: string;
name: string;
volume: string;
}
{
"id": "cryptopunks",
"object": "collection",
"floor": "...",
"logo_url": "https://cdn.triangleplatform.com/img/128/cryptopunks.png",
"market_cap": "...",
"name": "CryptoPunks",
"volume": "..."
}
Retrieve a collection
Retrieves the collection with the given ID.
const collection = await triangle.collections.retrieve(
"cryptopunks"
);
{
"id": "cryptopunks",
"object": "collection",
"floor": "...",
"logo_url": "https://cdn.triangleplatform.com/img/128/cryptopunks.png",
"market_cap": "...",
"name": "CryptoPunks",
"volume": "..."
}
List all collections
Returns a list of all the collections.
const collections = await triangle.collections.list();
{
"object": "list",
"items": [
{
"id": "cryptopunks",
"object": "collection",
"floor": "...",
"logo_url": "https://cdn.triangleplatform.com/img/128/bitcoin.png",
"market_cap": "...",
"name": "CryptoPunks",
"volume": "..."
}
]
}
Exchanges
This is an object representing an exchange.
The exchange object
- idstringThe unique identifier for the object.
- logo_urlstringThe url to the logo of the exchange.
- namestringThe name of the exchange.
- volumestringThe volume traded over the last 24 hours.
interface Exchange {
id: string;
object: string;
logo_url: string;
name: string;
volume: string;
}
{
"id": "coinbase",
"object": "exchange",
"logo_url": "https://cdn.triangleplatform.com/img/128/coinbase.png",
"name": "Coinbase",
"volume": "..."
}
Retrieve an exchange
Retrieves the exchange with the given ID.
const exchange = await triangle.exchanges.retrieve(
"coinbase"
);
{
"id": "coinbase",
"object": "exchange",
"logo_url": "https://cdn.triangleplatform.com/img/128/coinbase.png",
"name": "Coinbase",
"volume": "..."
}
List all exchanges
Returns a list of all the exchanges.
const exchanges = await triangle.exchanges.list();
{
"object": "list",
"items": [
{
"id": "coinbase",
"object": "exchange",
"logo_url": "https://cdn.triangleplatform.com/img/128/coinbase.png",
"name": "Coinbase",
"volume": "..."
}
]
}
Marketplaces
This is an object representing a marketplace.
The marketplace object
- idstringThe unique identifier for the object.
- logo_urlstringThe url to the logo of the marketplace.
- namestringThe name of the marketplace.
- volumestringThe volume traded over the last 24 hours.
interface Marketplace {
id: string;
object: string;
logo_url: string;
name: string;
volume: string;
}
{
"id": "opensea",
"object": "marketplace",
"logo_url": "https://cdn.triangleplatform.com/img/128/opensea.png",
"name": "OpenSea",
"volume": "..."
}
Retrieve a marketplace
Retrieves the marketplace with the given ID.
const marketplace = await triangle.marketplaces.retrieve(
"opensea"
);
{
"id": "opensea",
"object": "marketplace",
"logo_url": "https://cdn.triangleplatform.com/img/128/opensea.png",
"name": "OpenSea",
"volume": "..."
}
List all marketplaces
Returns a list of all the marketplaces.
const marketplaces = await triangle.marketplaces.list();
{
"object": "list",
"items": [
{
"id": "opensea",
"object": "marketplace",
"logo_url": "https://cdn.triangleplatform.com/img/128/opensea.png",
"name": "OpenSea",
"volume": "..."
}
]
}
Markets
This is an object representing a market.
The market object
- idstringThe unique identifier for the object.
- baseCryptocurrencyThe base asset of the market.
- exchangeExchangeThe exchange the market is on.
- laststringThe last price of the market.
- quoteCryptocurrency | FiatThe quote asset of the market.
- volumestringThe volume traded over the last 24 hours.
interface Market {
id: string;
object: string;
base: Cryptocurrency;
exchange: Exchange;
last: string;
quote: Cryptocurrency | Fiat;
volume: string;
}
{
"id": "coinbase_bitcoin_usdc",
"object": "market",
"base": {
"id": "bitcoin"
},
"exchange": {
"id": "coinbase"
},
"last": "23456.78",
"quote": {
"id": "usdc"
},
"volume": "..."
}
Retrieve a market
Retrieves the market with the given ID.
const market = await triangle.markets.retrieve(
"coinbase_bitcoin_usdc"
);
{
"id": "coinbase_bitcoin_usdc",
"object": "market",
"base": {
"id": "bitcoin"
},
"exchange": {
"id": "coinbase"
},
"last": "23456.78",
"quote": {
"id": "usdc"
},
"volume": "..."
}
List all markets
Returns a list of all the markets.
const markets = await triangle.markets.list();
{
"object": "list",
"items": [
{
"id": "coinbase_bitcoin_usdc",
"object": "market",
"base": {
"id": "bitcoin"
},
"exchange": {
"id": "coinbase"
},
"last": "23456.78",
"quote": {
"id": "usdc"
},
"volume": "..."
}
]
}
Listings
This is an object representing a listing.
The listing object
- idstringThe unique identifier for the object.
- collectionCollectionThe collection of the listing.
- floorstringThe floor price of the listing.
- marketplaceMarketplaceThe marketplace the listing is on.
- volumestringThe volume traded over the last 24 hours.
interface Listing {
id: string;
object: string;
collection: Collection;
floor: string;
marketplace: Marketplace;
volume: string;
}
{
"id": "opensea_cryptopunks",
"object": "listing",
"collection": {
"id": "cryptopunks"
},
"floor": "...",
"marketplace": {
"id": "opensea"
},
"volume": "..."
}
Retrieve a listing
Retrieves the listing with the given ID.
const listing = await triangle.listings.retrieve(
"opensea_cryptopunks"
);
{
"id": "opensea_cryptopunks",
"object": "listing",
"collection": {
"id": "cryptopunks"
},
"floor": "...",
"marketplace": {
"id": "opensea"
},
"volume": "..."
}
List all listings
Returns a list of all the listings.
const listings = await triangle.listings.list();
{
"object": "list",
"items": [
{
"id": "opensea_cryptopunks",
"object": "listing",
"collection": {
"id": "cryptopunks"
},
"floor": "...",
"marketplace": {
"id": "opensea"
},
"volume": "..."
}
]
}