Skip to main content
In this JavaScript quickstart we will learn how to:
  • Install the Gateway SDK
  • Creating a Gateway Client
  • Interacting with the Protocol for various operations
1

Install @gateway-dao/sdk

First begin by installing the @gateway-dao/sdk package.
npm install @gateway-dao/sdk
2

Setup the Gateway Client

You will need an API Key and Bearer token to authenticate with the Gateway Protocol. You can obtain these from the Gateway Dashboard.To setup the gateway client we will authenticate with a bearer-token and a Api key as follows:
Node.js
import { Gateway } from "@gateway-dao/sdk";

const gateway = new Gateway({
  apiKey: "your-api-key", // Replace with your API Key
  token: "your-token", // Replace with your Bearer Token
  url: "",
});
Make sure you add token without “Bearer” word as we add Bearer automatically when you make request. Else it will give you Unauthorized error even if your token is correct.
Do not share your authentication token with people you don’t trust. This gives the user control over your account and they will be able to manage PDAs (and more) with it. Use environment variables to keep it safe.
3

Interacting with the Gateway Protocol

Now that we have setup the Gateway Client, we can interact with the Gateway Protocol for various operations.

Create a PDA

Node.js
import { Gateway, UserIdentifierType } from "@gateway-dao/sdk";

const gateway = new Gateway({
  apiKey: "your-api-key",
  token: "your-token",
  url: "https://sandbox.protocol.mygateway.xyz/graphql",
});

async function main() {
  try {
    let obj = {
      dataModelId: "uuid-here",
      description: "test",
      title: "test",
      claim: {
        gatewayUse: "test",
      },
      owner: {
        type: UserIdentifierType.GATEWAY_ID,
        value: "test",
      },
    };
    const { createPDA } = await gateway.pda.createPDA(obj);
    console.log(createPDA);
  } catch (error) {
    console.log(error); // Can log it for debugging
  }
}

main();
4

Congratulations! You have successfully created your first PDA and Data Request Template using the Gateway Protocol SDK.
I