import { createRlpEncodedAuthorization } from "@otim/sdk"
// get the delegate contract address first
const config = await otimClient.config.getDelegateAddress({ chainId: 1 });
const nonce = await publicClient.getTransactionCount({
address: account.address
});
// sign authorization (eip-7702)
// example assuming that you're using the **privateKeyToAccount** function from viem.
const authorization = await account.signAuthorization({
contractAddress: onfig.otimDelegateAddress,
chainId: 1,
nonce,
});
// convert to rlp format and delegate
const rlpAuthorization = createRlpEncodedAuthorization(authorization);
// perform delegation (submit to API)
const result = await otimClient.delegation.delegate({
signedAuthorization: rlpAuthorization,
});
console.log(`delegation submitted: ${result.transactionHash}`);