GuidesAPI Reference
Log In

API Client (TypeScript)

You can interact with the Blowfish API using the provided API client, which includes typings and methods generated from the OpenAPI schema for your convenience. This enables you to fully benefit from the Blowfish API's capabilities.

Install the package

npm

npm install @blowfishxyz/api-client

yarn

yarn add @blowfishxyz/api-client

pnpm

pnpm add @blowfishxyz/api-client

Create an API Client

We currently support two main chain families: EVM (including Ethereum, Polygon, BNB, Arbitrum, Optimism, and Base) and Solana. Depending on your needs, you can instantiate a client specifically for one of these chain families or opt for a multi-chain client that supports both.

import { 
  createMultiChainClient, 
  createSolanaClient,
  createEvmClient,
  Languages,
} from "@blowfishxyz/api-client/v20230605";

const mulitChainClient = createMultiChainClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  // Optional
  language: Languages.En,
});

const solanaClient = createSolanaClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  chainNetwork: "mainnet",
  // Optional
  language: Languages.En,
});

const evmClient = createEvmClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  chainFamily: "ethereum",
  chainNetwork: "mainnet",
  // Optional
  language: Languages.En
});

Transactions and Messages

Scan EVM and Solana transactions and messages in order to receive recommended actions, tailored warnings and human-readable simulation results explaining what the transaction will do. The API will return a list of warnings and a list of human-readable simulation results.

Solana

import {
  createSolanaClient,
  Languages,
} from "@blowfishxyz/api-client/v20230605";

const client = createSolanaClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  chainNetwork: "mainnet",
  // Optional
  language: Languages.En,
});

const transactionsScan = await client.scanTransactions(
  [
    "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAED1/GM77uLGslrQf0lxej6sBRDW3dUMBw4Mxo1zRrpZGZafbJORJb+gzh+vcMdhnn8px1N+NcuQ1Lj1KvhFRwAywbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpBn9A83Xu7uaFQt8+0152j5cclxp+kZToz5JJnbLwpxQBAgIBACMGAgF0db0rJ/DnR+R6kWV6kj4FchRRhx9TXx7HEF7/uDTADQ==",
  ],
  "FXxHSp14Yfmwn5c3ynpxx3AMHU3JVmdXJu1MgEwz3bAu",
  {
    origin: "https://unkown-domain.dev",
  }
);

EVM

import { createEvmClient, Languages } from "@blowfishxyz/api-client/v20230605";

const client = createEvmClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  chainFamily: "ethereum",
  chainNetwork: "mainnet",
  // Optional
  language: Languages.En,
});

// Scan multiple transactions
const transactionsScan = await client.scanTransactions(
  [
    {
      data: "0xa9059cbb000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000002386f26fc10000",
      from: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
      to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    },
    {
      data: "0xa9059cbb000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000002386f26fc10000",
      from: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
      to: "0xc03bbb39b223fe8d0a0e5c4f27ead9083c756ac2",
    },
  ],
  "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  { origin: "https://unkown-domain.dev" }
);

// Scan a raw message
const messageScan = await client.scanMessage(
  "0x40ac14ef28d35fb4540e0cd0950123b378224d3585ec887c26f7a510da544552",
  "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  { origin: "https://unkown-domain.dev" }
);

// Scan typed data
const typedDataScan = await client.scanSignTypedData(
  {
    domain: {
      name: "Permit2",
      chainId: "1",
      verifyingContract: "0xf0ffb02791362602acf0edce574e74dd9bd3120e",
    },
    types: {
      PermitBatch: [
        {
          name: "details",
          type: "PermitDetails[]",
        },
        {
          name: "spender",
          type: "address",
        },
        {
          name: "sigDeadline",
          type: "uint256",
        },
      ],
      PermitDetails: [
        {
          name: "token",
          type: "address",
        },
        {
          name: "amount",
          type: "uint160",
        },
        {
          name: "expiration",
          type: "uint48",
        },
        {
          name: "nonce",
          type: "uint48",
        },
      ],
    },
    primaryType: "PermitBatch",
    message: {
      details: [
        {
          token: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
          amount: "1461501637330902918203684832716283019655932542975",
          expiration: "281474976710655",
          nonce: "281474976710655",
        },
        {
          token: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          amount: "1461501637330902918203684832716283019655932542975",
          expiration: "281474976710655",
          nonce: "281474976710655",
        },
        {
          token: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          amount: "1461501637330902918203684832716283019655932542975",
          expiration: "281474976710655",
          nonce: "281474976710655",
        },
      ],
      spender: "0x0000000000000000000000000000000000000001",
      sigDeadline:
        "115792089237316195423570985008687907853269984665640564039457584007913129639935",
    },
  },
  "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  { origin: "https://unkown-domain.dev" }
);

// Scan domains
const domainsScan = await client.scanDomains(["https://app.uniswap.org"]);

Multi Chain

import {
  createMultiChainClient,
  Languages,
} from "@blowfishxyz/api-client/v20230605";

const client = createMultiChainClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  // Optional
  language: Languages.En,
});

const evmTransactionsScan = await client.scanTransactionsEvm(
  [
    {
      data: "0xa9059cbb000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000002386f26fc10000",
      from: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
      to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    },
  ],
  "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  { origin: "https://unkown-domain.dev" },
  "ethereum",
  "mainnet"
);
const solanaTransactionsScan = await client.scanTransactionsSolana(
  [
    "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAED1/GM77uLGslrQf0lxej6sBRDW3dUMBw4Mxo1zRrpZGZafbJORJb+gzh+vcMdhnn8px1N+NcuQ1Lj1KvhFRwAywbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCpBn9A83Xu7uaFQt8+0152j5cclxp+kZToz5JJnbLwpxQBAgIBACMGAgF0db0rJ/DnR+R6kWV6kj4FchRRhx9TXx7HEF7/uDTADQ==",
  ],
  "FXxHSp14Yfmwn5c3ynpxx3AMHU3JVmdXJu1MgEwz3bAu",
  {
    origin: "https://unkown-domain.dev",
  },
  "mainnet"
);

https://docs.blowfish.xyz/reference/scan-transactions-solana

https://docs.blowfish.xyz/reference/scan-transactions-evm

https://docs.blowfish.xyz/reference/scan-message-evm

Domains

Analyze dApp domains to determine if they are safe for users to interact with.

import { createMultiChainClient } from "@blowfishxyz/api-client/v20230605";

const client = createMultiChainClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  // Optional
  language: Languages.En,
});
const domainsScan = await client.scanDomains([
  "https://raydium.io",
  "https://app.uniswap.org",
]);

https://docs.blowfish.xyz/reference/scan-domain-1

Report Transaction

For each scan, you can send events like PROCEEDED (when user decided to sign the transaction), REJECTED (when user decided to abort the transaction flow) and REPORTED_MALICIOUS (when user explicitly marked the submitted transaction as malicious).

import { createMultiChainClient, ReportRequestEventEnum } from "@blowfishxyz/api-client/v20230605";

const client = createMultiChainClient({
  basePath: "https://api.blowfish.xyz",
  // Optional: It's highly encouraged to use a proxy server to not expose your API key on the client (see: https://docs.blowfish.xyz/docs/wallet-integration-guide#optional-proxy-server)
  apiKey: "4daa1e3b-87e6-40b2-8883-758feb6a8e46",
  // Optional
  language: Languages.En,
});

client.reportTransaction(
  "eafdae18039f531b5a586310cfbd654e", // request ID – returned by every Blowfish API response 
  ReportRequestEventEnum.ReportedMalicious
);

https://docs.blowfish.xyz/reference/report

Versioning

We provide typings and clients for every version of the Blowfish API, facilitating easy migration which can be segmented into multiple steps if necessary. To ensure optimization for bundle size, each version is built separately. To access a specific API version, simply import the API client along with the types corresponding to that version.

We strongly recommend staying updated with the latest version of our API to take advantage of new features and enjoy an enhanced developer experience.

import * as BlowfishV20230605 from "@blowfishxyz/api-client/v20230605";
import * as BlowfishV20230517 from "@blowfishxyz/api-client/v20230517";
import * as BlowfishV20230308 from "@blowfishxyz/api-client/v20230308";
import * as BlowfishV20220601 from "@blowfishxyz/api-client/v20220601";