Instruction Set Authority
Thay đổi authority của mint hoặc account. Điều này cho phép chuyển giao quyền sở hữu hoặc cập nhật các loại authority cụ thể.
Trước khi chúng ta có thể set authority của bất kỳ token hoặc token account nào, chúng ta sẽ cần phải có:
- Account
Mint
đã khởi tạo mà chúng ta giữmintAuthority
hoặcfreezeAuthority
- Account
Token
hoặc accountAssociated Token
đã khởi tạo mà chúng ta sở hữu
Đây là cách gọi CPI đến instruction set_authority()
:
set_authority(
CpiContext::new(
ctx.accounts.token_program.to_account_info(),
SetAuthority {
account_or_mint: ctx.accounts.mint_account.to_account_info(),
to: ctx.accounts.to_token_account.to_account_info(),
current_authority: ctx.accounts.authority.to_account_info(),
},
),
&spl_token::instruction::AuthorityType::MintTokens, // authority_type
Some(new_authority.key()) // new_autority
)?;