Skip to content

SyndicateProtocol/syndicate-node

Repository files navigation

Syndicate Node.js SDK

Documentation · Website

npm shield

Syndicate

Syndicate’s modular end-to-end infrastructure abstracts the complexity of sending onchain transactions and decreases development time — making it easier, cheaper and faster for developers to build, launch and grow onchain products at any scale.

At the core of Syndicate’s infrastructure is the Transaction Cloud. Syndicate’s Transaction Cloud offers a complete, end-to-end service that provides Transaction Broadcasting, Dynamic NFT Metadata, Signing & Attestations, Webhooks and Managed Gas - completely abstracting the complexity of managing transactions, wallets, permissioning, and more through simple REST APIs for developers. Our Transaction Cloud supports all EVM chains and can handle up to 5K+ RPS.

Learn more about our Transaction Cloud.

Documentation & Getting Started

Our Node.js library provides access to a selection of endpoints to the Syndicate API. For full functionality of our API please view docs.syndicate.io.

  1. Create an organization for free via our dashboard
  2. Create a project
  3. Add funds to your transaction wallet
  4. Use the SDK to send a transaction

For more detailed instructions, please follow our quickstart guide.

Installation

npm i @syndicateio/syndicate-node
# or
yarn add @syndicateio/syndicate-node

Usage

Open in StackBlitz

Send a transaction

import { SyndicateClient } from "@syndicateio/syndicate-node";

const syndicate = new SyndicateClient({ token: "YOUR_ACCESS_TOKEN" })

const tx = await syndicate.transact.sendTransaction({
  projectId: "YOUR_PROJECT_ID",
  contractAddress: "0x52962dd492dDDef76d4eFb2bB7E505aeAE4554A1",
  chainId: 84532,
  functionSignature: "mint(address account)",
  args: {
    account: "0x8A05fA58d533a6e40C4381E3247Cf4c68ca61cdc"
  }
})
console.log('Transaction ID Received:', tx.transactionId)

Get transaction hash from a transaction ID

import { SyndicateClient } from "@syndicateio/syndicate-node";

interface GetTxhashFromIdOptions {
  projectID: string
  txID: string
  maxAttempts?: number
  every?: number
}

export async function getTxHashFromTxId(client: SyndicateClient, {
  projectID,
  txID,
  maxAttempts = 20,
  every = 1000,
}: GetTxhashFromIdOptions) {
  let currAttempts = 0
  let transactionHash = null

  while (!transactionHash) {
    await new Promise((resolve) => setTimeout(resolve, every))

    if (currAttempts >= maxAttempts - 1) {
      throw new Error("Max attempts reached")
    }

    const txAttempts = (await client.wallet.getTransactionRequest(projectID, txID))?.transactionAttempts

    if (txAttempts && txAttempts.length > 0) {
      transactionHash = txAttempts[txAttempts.length - 1].hash
      break
    }

    currAttempts += 1
  }

  return transactionHash
}

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. To use the API directly, please view the API documentation.