Client Initialization

The client initialization create a wallet object to make on-chain contract calls & signer objects to sign off-chain payload such as orders. The following parameters are required for initialization

  • Is Term Accepted: Boolean value indicating that you accepted the Terms of Use & Privacy Policy of Bluefin Exchange. Passing this value true lets you use the authorized routes of the exchange.

  • Network: These are predefined set of Network in the library which we support connecting to.

  • Account Seed Phrase or Private Key: The seed phrase or private key of the account that will be used for trading. The client library solely uses it to create a signer object for signing orders and on-chain transaction - it is never exposed outside this signer object or transmitted.

Note: Python clients only support ED25519 wallets

Examples

/**
 * Client initialization code example
 */

/* eslint-disable no-console */
import {
  BluefinClient,
  Networks,
} from "@bluefin-exchange/bluefin-v2-client";

async function main() {
  
  // Initialize using seed phrase
  const seedPhrase =
    "royal reopen journey royal enlist vote core cluster shield slush hill sample";
 
  const client = new BluefinClient(
    true,
    Networks.TESTNET_SUI, // i.e. TESTNET_SUI or PRODUCTION_SUI
    seedPhrase,
    "ED25519" // valid values are ED25519 or Secp256k1
  ); //passing isTermAccepted = true for compliance and authorizarion
  
  
  
  //  OR Initialize using private key
  const privateKey = "0xa06e982b82f6d748add9d37843b222b0170a3fd5fbd9569e645ddcf69f5607f5"
  client = new BluefinClient(
    true,
    Networks.TESTNET_SUI, // i.e. TESTNET_SUI or PRODUCTION_SUI
    privateKey,
    "ED25519" // valid values are ED25519 or Secp256k1
  ); 
  
  await client.init();
  // prints client address
  console.log(client.getPublicAddress());  
}

main().then().catch(console.warn);
from bluefin_v2_client import BluefinClient, Networks
from pprint import pprint
import asyncio

async def main():
  
  # Initialize using seed phrase
  ed25519_wallet_seed_phrase =
    "person essence firm tail chapter forest return pulse dismiss unlock zebra amateur";
    
  client = BluefinClient(
      True, # agree to terms and conditions
      Networks["SUI_STAGING"], # SUI_STAGING or SUI_PROD
      ed25519_wallet_seed_phrase, # seed phrase of the wallet
  )
  
  
  # OR Initialize using private key
  privateKey = "0xa06e982b82f6d748add9d37843b222b0170a3fd5fbd9569e645ddcf69f5607f5"
  client = BluefinClient(
      True, # agree to terms and conditions
      Networks["SUI_STAGING"], # SUI_STAGING or SUI_PROD
      privateKey, # seed phrase of the wallet
  )
  


  # on boards user on bluefin. Must be set to true for firs time use
  await client.init(True)

  print('Account address:', client.get_public_address())

  # gets user account on-chain data
  data = await client.get_user_account_data()

  # close aio http connection
  await client.apis.close_session()

  pprint(data)

if __name__ == "__main__":
  loop = asyncio.new_event_loop()
  loop.run_until_complete(main())
  loop.close()