Zebec Protocol
Search…
⌃K

Initialize Stream Object

User should define an object before starting with core functions.
import { NativeStream, TokenStream } from "@zebec-protocol/stream";
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
​
export const initNativeStream = () => {
const { connection } = useConnection();
const { adapter } = useWallet();
const native = new NativeStream(adapter, connection._rpcEndpoint);
return native;
};
​
export const initTokenStream = () => {
const { connection } = useConnection();
const { adapter } = useWallet();
const token = new TokenStream(adapter, connection._rpcEndpoint);
return token;
};
​
// 'stream' instance is for native token stream and 'token' is for SPL token stream.
​
// You can import these functions and start using them.
​
const native = initNativeStream();
​
const token = initTokenStream();
​
​