Bluefin's TypeScript and Python clients can be initialized in read-only mode using the revokable API token without the need of a private key. This type of initialization provides access to token generator's data using get routes and allows to subscribe to socket events to receive updates.
Accessing POST APIs is forbidden using read-only token as the user is not allowed to make any updates to an account in read-only mode.
Moreover, if a user chooses to provide both private key in the constructor of firefly-client and read-only token for initializing firefly-client, precedence would be given to validity of the token and user would enter the exchange in read-only mode.
The following examples show how to initialize the client library with the Read-Only token (see how to generate it here).
Examples
/**
* Client initialization code example
*/
/* eslint-disable no-console */
import {
BluefinClient,
Networks,
} from "@bluefin-exchange/bluefin-v2-client";
async function main() {
const client = new BluefinClient(
true,
Networks.TESTNET_SUI // i.e. TESTNET_SUI or PRODUCTION_SUI
); //passing isTermAccepted = true for compliance and authorizarion
// load/init contract addresses using read-only token
await client.init(
false,
null,
"80a5d86820821aeae483f7cdda715e0215c1fdad612b982e7ce22c88de3ac9e2"
);
}
main().then().catch(console.warn);
from bluefin_v2_client import BluefinClient, Networks
from pprint import pprint
import asyncio
async def main():
client = BluefinClient(
True, # agree to terms and conditions
Networks["SUI_STAGING"] # SUI_STAGING or SUI_PROD
)
# load/init contract addresses in read-only mode using API token
await client.init(False, "54b0bfafc9a48728f76e52848a716e96d490263392e3959c2d44f05dea960761")
if __name__ == "__main__":
import asyncio
loop = asyncio.get_event_loop()
loop.run_until_complete(main())