Aftermath
  • Aftermath
    • About Aftermath Finance
      • What are we building?
  • Getting Started
    • Creating an account
      • zkLogin
        • Removing a zkLogin account
      • Sui Metamask Snap
      • Native Sui wallets
    • Dynamic Gas
    • Navigating Aftermath
      • Interacting with your Wallet
      • Viewing your Portfolio
      • Changing your Settings
      • Bridge
      • Referrals
  • Trade
    • Smart-Order Router
      • Agg of Aggs
      • Making a trade
      • Exact Out
      • Fees
    • DCA
      • Why should I use DCA
      • How does DCA work
      • Tutorials
        • Creating a DCA order
        • Monitoring DCA progress
        • Advanced Features
      • Fees
      • Contracts
  • Limit Orders
    • Contracts
    • Fees
  • Pools
    • Constant Function Market Maker
      • Tutorials
        • Depositing
        • Withdrawing
        • Creating a Pool
      • Fees
      • Contracts
      • Audit
  • Farms
    • Afterburner Vaults
      • Tutorials
        • Staking into a Farm
        • Claiming Rewards
        • Unstaking
        • Creating a Farm
      • Architecture
        • Vault
        • Stake Position
      • Fees
      • FAQs
  • Liquid Staking
    • afSUI
      • Tutorials
        • Staking
        • Unstaking
      • Architecture
        • Packages & Modules
        • Entry Points
      • Fees
      • FAQs
      • Contracts
      • Audit
  • Perpetuals
    • Aftermath Perpetuals
      • Tutorials
        • Creating an Account
        • Selecting a Market
        • Creating a Market Order
        • Creating a Limit Order
        • Maintaining your Positions
      • Architecture
        • Oracle Prices
        • Margin
        • Account
        • Trading
        • Funding
        • Liquidations
        • Fees
  • GameFi
    • NFT AMM
      • Architecture
        • Fission Vaults
        • AMM Pools
      • Tutorials
        • Buy
        • Sell
        • Deposit
        • Withdraw
      • Sui Overflow
  • Our validator
    • About us
  • Developers
    • Aftermath TS SDK
      • Utils
        • Coin
        • Users Data
        • Authorization
      • Products
        • Prices
        • Router
        • DCA
        • Limit Orders
        • Liquid Staking
        • Pools
        • Farms
    • Aftermath REST API
      • Authorization
  • Egg
    • About Egg
  • Legal
    • Terms of Service
    • Privacy Policy
  • Languages
    • 中文
    • 한국어
  • Links
    • X
    • Telegram
    • Discord
    • Github
    • Medium
    • Aftermath Validator
Powered by GitBook
On this page
  • Initialization
  • Rate Limits
  • Methods
  • Types
  • Example Usage
  1. Developers
  2. Aftermath TS SDK
  3. Utils

Authorization

Use increased rate limits with our SDK

PreviousUsers DataNextProducts

Last updated 1 day ago

A system for obtaining and managing increased API rate limits through request authorization.

Initialization

const afSdk = new Aftermath("MAINNET");
await afSdk.init(); // initialize provider

const auth = afSdk.Auth();

Rate Limits

Default rate limit: 1000 requests per 10 seconds.

To request increased limits:

  1. Visit

  2. Open a ticket with:

sui-address: <your-sui-address>
rate-limit-requests: [<sdk-call>: <desired-rate-limit>]

Methods

Initialize with Private Key

const keypair = Helpers.keypairFromPrivateKey("your-private-key");

const stopAuth = await auth.init({
	signMessageCallback: async ({ message }) => {
		const { signature } = await keypair.signPersonalMessage(message);
		return { signature };
	},
	walletAddress: keypair.toSuiAddress(),
});

// Make authorized requests
const pools = await afSdk.Pools().getAllPools();

// Stop authorization
stopAuth();

Types

interface AuthInitOptions {
	signMessageCallback: (args: { message: Uint8Array }) => Promise<{
		signature: string;
	}>;
	walletAddress: string;
}

Example Usage

const afSdk = new Aftermath("MAINNET");
await afSdk.init();

// Initialize with private key
const keypair = Helpers.keypairFromPrivateKey("your-private-key");
const stopAuth = await afSdk.Auth().init({
	signMessageCallback: async ({ message }) => {
		const { signature } = await keypair.signPersonalMessage(message);
		return { signature };
	},
	walletAddress: keypair.toSuiAddress(),
});

// Make authorized requests
const pools = await afSdk.Pools().getAllPools();
const prices = await afSdk.Prices().getCoinPrice({
	coin: "0x2::sui::SUI",
});

// Clean up
stopAuth();
Aftermath Discord