IDLs
getIdlFromAddress()

Returns IDL from a specific address. Optionally, you can use a different cluster as a second parameter, which by default will be 'mainnet-beta'. You can use this method in a hook form useRequestIdlFromAddress() (opens in a new tab).

import { getRpcEndpointUrl, getNewConnection, getIdlFromAddress } from '@lndgalante/solutils';
 
const { rpcUrl } = getRpcEndpointUrl('solana', 'mainnet');
const { connection } = getNewConnection(rpcEndpointUrl);
 
const address = 'cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ';
const { idl } = await getIdlFromAddress(connection, address);
 
console.log(idl); // { version: '4.4.0', name: 'candy_machine', ... }