Client Library
The method Generate Read Only Token allows users to generate a revokable API token to provide read-only access to their data and socket events to non-owners of the account without sharing the wallet's private key.
This read-only token will only be available in the response to this API call. It can be invalidated by generating a new token through the same API, with the purpose of revoking the existing one. Any user holding the revoked token will no more be authorized to access wallet owner's data or socket events.
The method returns a 32-bit revokable API token.
Examples
/**
* Client initialization code example
*/
/* eslint-disable no-console */
import {
BluefinClient,
Networks,
} from "@bluefin-exchange/bluefin-v2-client";
async function main() {
const dummyAccountKey =
"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
dummyAccountKey,
"ED25519" // valid values are ED25519 or Secp256k1
); //passing isTermAccepted = true for compliance and authorizarion
// load/init contract addresses
await client.init()
//receive read-only token in response
const resp=await client.generateReadOnlyToken();
console.log(resp.data);
}
main().then().catch(console.warn);
from bluefin_v2_client import BluefinClient, Networks
from pprint import pprint
import asyncio
async def main():
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
)
# initialize the client
# onboards user on Bluefin. Must be set to true for first time use
await client.init(True)
print('Account Address:', client.get_public_address())
# generates read-only token for user
data = await client.generate_readonly_token()
print("Read-only Token:", str(data))
await client.close_connections()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
loop.run_until_complete(main())
loop.close()
HTTPs
Alternatively, if you have obtained your API auth token, you may use this to generate the Read-Only token by making an HTTPs call to the POST /generateReadOnlyToken by using the tool on the right or locally from any other language supporting HTTPs network calls.