token.useSetRoleAdmin
Sets the admin role for a specific role on a TIP-20 token. Requires appropriate permissions. Learn more about token roles
Usage
ts
import { } from 'wagmi/tempo'
const = ..()
// Call `mutate` in response to user action (e.g. button click, form submission)
.({
: 'defaultAdmin',
: 'issuer',
: '0x20c0000000000000000000000000000000000000',
})
.('Transaction hash:', .?..)
Transaction hash: 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdefts
import { createConfig, http } from 'wagmi'
import { tempoTestnet } from 'wagmi/chains'
import { KeyManager, webAuthn } from 'wagmi/tempo'
export const config = createConfig({
connectors: [
webAuthn({
keyManager: KeyManager.localStorage(),
}),
],
chains: [tempoTestnet],
multiInjectedProviderDiscovery: false,
transports: {
[tempoTestnet.id]: http(),
},
})Asynchronous Usage
The example above uses a *Sync variant of the action, that will wait for the transaction to be included before returning.
If you are optimizing for performance, you should use the non-sync token.setRoleAdmin action and wait for inclusion manually:
ts
import { Hooks } from 'wagmi/tempo'
import { Actions } from 'viem/tempo'
import { useWaitForTransactionReceipt } from 'wagmi'
const setRoleAdmin = Hooks.token.useSetRoleAdmin()
const { data: receipt } = useWaitForTransactionReceipt({ hash: setRoleAdmin.data })
// Call `mutate` in response to user action (e.g. button click, form submission)
setRoleAdmin.mutate({
adminRole: 'defaultAdmin',
role: 'issuer',
token: '0x20c0000000000000000000000000000000000000',
})
if (receipt) {
const { args }
= Actions.token.setRoleAdmin.extractEvent(receipt.logs)Return Type
See TanStack Query mutation docs for more info hook return types.
data
See Wagmi Action token.setRoleAdmin Return Type
mutate/mutateAsync
See Wagmi Action token.setRoleAdmin Parameters
Parameters
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
mutation
See the TanStack Query mutation docs for more info hook parameters.