useProgram() function
Get an SDK instance to interact with any program
Example
import { useProgram } from "@thirdweb-dev/react/solana";
export default function Component() {
const { program } = useProgram("{{program_address}}").program;
// Now you can use the program in the rest of the component
// For example, we can make a transaction
async function functionCall() {
await program.call("mint", ...);
}
...
}
Signature:
export declare function useProgram<TProgramType extends ProgramType>(
address: RequiredParam<string>,
type?: TProgramType,
): UseQueryResult<
Readonly<{
"nft-collection": NFTCollection;
"nft-drop": NFTDrop;
token: Token;
}>[TProgramType],
unknown
> & {
program: Readonly<{
"nft-collection": NFTCollection;
"nft-drop": NFTDrop;
token: Token;
}>[TProgramType];
};
Parameters
Parameter | Type | Description |
---|---|---|
address | RequiredParam<string> | the address of the program to get an interface for |
type | TProgramType | (Optional) optionally, pass in the program type to get static typing |
Returns:
UseQueryResult<Readonly<{ "nft-collection": NFTCollection; "nft-drop": NFTDrop; token: Token; }>[TProgramType], unknown> & { program: Readonly<{ "nft-collection": NFTCollection; "nft-drop": NFTDrop; token: Token; }>[TProgramType]; }