1

Blockquote

I would like to revoke all Wormhole token delegation permissions. I configured ChatGP and Python code as shown below, but it does not run. Transactions with existing permissions are as follows. Please help quickly.(https://solscan.io/tx/2uUX6Qr32XAfuD6Qm6ZJvBAJGqJmACgGyHoc99XMVU1i9qUB6nhAoucs8ApXVzagLUYVZcD1iGUu6Ab38YrB2eKY)

Blockquote

from solana.rpc.api import Client
from spl.token.client import Token
from solana.transaction import Transaction

from solana.rpc.types import TxOpts
from solders.pubkey import Pubkey
from solders.keypair import Keypair
from solana.rpc.core import RPCException

def revoke_authority(token_client: Token, mint_address: str, account_address: str, key_pair: Keypair):
    try:
        # 트랜잭션 구성
        tx = Transaction()
        tx.add(spl_client.transfer(source=account_address, dest=account_address,  owner_account=key_pair.public_key(), amount=0)
      
        )

        # 트랜잭션 서명
        tx.recent_blockhash = token_client.get_recent_blockhash()
        tx.sign(key_pair)

        # 트랜잭션 전송
        result = token_client.conn.send_transaction(tx, opts=TxOpts(skip_confirmation=False, preflight_commitment=None))
        print(f"Authority revoked successfully. Transaction ID: {result}")
    except RPCException as rpc_error:
        print(f"Revoking authority failed: {rpc_error}")
        exit(1)  # 실패 시 스크립트 종료

# 위의 코드에서 필요한 모든 설정을 수행한 후에 아래와 같이 함수를 호출할 수 있습니다.

mint_address = "ddd"
account_address = "ddd"
privkey = 'ddd'

solana_client = Client("https://api.mainnet-beta.solana.com")
spl_client = Token(conn=solana_client, pubkey=Pubkey.from_string(mint_address),
                   program_id=Pubkey.from_string("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
                   payer=Keypair.from_base58_string(privkey))

key_pair = Keypair.from_base58_string(privkey)

revoke_authority(spl_client, mint_address, account_address, key_pair)

1 Answer 1

0

Your code sample is calling transfer with the token client and then trying to add it to a transaction, which is incorrect for two reasons:

  • you want to revoke, not transfer
  • the token client will create, sign, and send the transaction for you already

Instead, you can just do:

def revoke_authority(token_client: Token, account_address: str, key_pair: Keypair):
    try:
        token_client.revoke(account=Pubkey(account_address), owner=key_pair)
    except RPCException as rpc_error:
        print(f"Revoking authority failed: {rpc_error}")
        exit(1)

Lifted from the revoke test at https://github.com/michaelhly/solana-py/blob/master/tests/integration/test_token_client.py#L299 and the function at https://github.com/michaelhly/solana-py/blob/4237ff2a56a7bf29fa98c7bdb595237300c24dff/src/spl/token/client.py#L404

2
  • thanks to your answer. but it 's not work.. it is my wallet tx: solscan.io/tx/… i Think who stollen my authority, so i couldn't revoke this. right?
    – 3111
    Commented Apr 8 at 16:14
  • Ah, unfortunately you gave your account away to that other key, so there's nothing you can do. I'm sorry for your loss
    – Jon C
    Commented Apr 8 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.