You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
proxy wallets offer strong protection for sensitive coldkeys, but are complex to implement because they are not included in btcli or bittensor python sdk, you have to use polkadot-js
Create proxy
import{ApiPromise,WsProvider,Keyring}from'@polkadot/api';// Replace with your Polkadot or Kusama WebSocket endpointconstWS_PROVIDER='wss://test.finney.opentensor.ai:443 ';// Use Polkadot's endpoint if needed// Replace with your accountsconstPROXIED_ACCOUNT_MNEMONIC='famous caution muscle liar castle fire marble impact design run fetch cake';// The account that is assigning the proxyconstPROXY_ACCOUNT_ADDRESS='5DUe8dTokgDNr34aq9jtJYZcmb8gtCaksjXGes2HnYk3oJDK';// The proxy accountconstPROXY_TYPE='Any';// Options: 'Any', 'NonTransfer', 'Governance', etc.constDELAY=0;// Set delay if neededasyncfunctionsetupProxy(){try{// Connect to the blockchainconstprovider=newWsProvider(WS_PROVIDER);constapi=awaitApiPromise.create({ provider });// Load the proxied account's keyconstkeyring=newKeyring({type: 'sr25519'});constproxiedAccount=keyring.addFromUri(PROXIED_ACCOUNT_MNEMONIC);// Create the extrinsic to add the proxyconstextrinsic=api.tx.proxy.addProxy(PROXY_ACCOUNT_ADDRESS,PROXY_TYPE,DELAY);console.log('Sending transaction to add proxy...');// Sign and send the transactionconstunsub=awaitextrinsic.signAndSend(proxiedAccount,({ status })=>{console.log(`Current status: ${status.type}`);if(status.isInBlock){console.log(`Transaction included at blockHash ${status.asInBlock}`);}elseif(status.isFinalized){console.log(`Transaction finalized at blockHash ${status.asFinalized}`);unsub();}});}catch(error){console.error('Error:',error);}}// Run the functionsetupProxy();
Transfer with proxy:
import{ApiPromise,WsProvider,Keyring}from'@polkadot/api';constWS_PROVIDER='wss://test.finney.opentensor.ai:443';constPROXY_ACCOUNT_MNEMONIC='minute pistol liberty welcome harbor august between spend cherry genius doll jar';constPROXIED_CK_ADDRESS='5ECaCSR1tEzcF6yDiribP1JVsw2ZTepZ1ZPy7xgk7yoUv69b';constDESTINATION_COLDKEY='5EspBPxFuBm8D2MgEENa6HBpAW7mEqzFxaDzd8yhbBdTpkd9';constTRANSFER_AMOUNT=11000000000;// Adjust for token decimals, e.g., TAO uses 9 decimalsasyncfunctionsetupProxy(){try{constprovider=newWsProvider(WS_PROVIDER);constapi=awaitApiPromise.create({ provider });constkeyring=newKeyring({type: 'sr25519'});constproxyAccount=keyring.addFromUri(PROXY_ACCOUNT_MNEMONIC);// Create the inner transfer call (what the proxied account would do)constinnerCall=api.tx.balances.transferKeepAlive(DESTINATION_COLDKEY,TRANSFER_AMOUNT);// Wrap it in a proxy.proxy extrinsicconstproxyExtrinsic=api.tx.proxy.proxy(PROXIED_CK_ADDRESS,'Any',// Proxy type: must match the registered typeinnerCall);console.log('Sending proxy-wrapped transaction...');constunsub=awaitproxyExtrinsic.signAndSend(proxyAccount,({ status, dispatchError })=>{if(status.isInBlock){console.log(`Included in block: ${status.asInBlock}`);}elseif(status.isFinalized){console.log(`Finalized block: ${status.asFinalized}`);unsub();}if(dispatchError){if(dispatchError.isModule){constdecoded=api.registry.findMetaError(dispatchError.asModule);console.error(`Error: ${decoded.section}.${decoded.name} - ${decoded.docs.join(' ')}`);}else{console.error(`Dispatch error: ${dispatchError.toString()}`);}}});}catch(err){console.error('Error during proxy transfer:',err);}}setupProxy();
The text was updated successfully, but these errors were encountered:
proxy wallets offer strong protection for sensitive coldkeys, but are complex to implement because they are not included in btcli or bittensor python sdk, you have to use polkadot-js
Create proxy
Transfer with proxy:
The text was updated successfully, but these errors were encountered: