reset proxy key
API details
This API is used to set or reset the delegate key for a registered wallet. The delegate key is generated by the client and encrypted before being stored on the Hibit Chain. Note: The encryption is handled automatically by the Hibit SDK’s API and cannot be performed manually by developers.
Body
chainstringOptional
chainNetworkstring | nullableOptional
messagestring | nullableOptional
signaturestring | nullableOptional
Responses
200
OK
400
Bad Request
401
Unauthorized
403
Forbidden
404
Not Found
500
Internal Server Error
501
Not Implemented
post
POST /v1/proxy-key/reset HTTP/1.1
Host: testnetopenapi.hibit.app
Content-Type: application/json
Accept: */*
Content-Length: 74
{
"chain": "text",
"chainNetwork": "text",
"message": "text",
"signature": "text"
}
{
"code": 1,
"message": "text",
"data": {}
}
Code example
import { hibitClient, Chain, WalletSignatureSchema, Keypair } from '@delandlabs/hibit-sdk';
import { MyWalletApi } from './my-wallet-api'; // Replace with your IWalletApi implementation
// Set client options (replace with your actual values)
hibitClient.setOptions({
network: 'Testnet', // or HibitNetwork.Testnet if imported
hin: 10000n, // your wallet HIN
});
// Set your wallet API implementation
hibitClient.setWalletApi(new MyWalletApi());
// Generate a new proxy key pair
const keypair = Keypair.generate();
const proxyPrivateKey = keypair.privateKeyHex;
const proxyPublicKey = keypair.publicKeyHex;
// Fetch the current nonce for the wallet
const nonce = await hibitClient.getNonce();
// Prepare the input for resetting the proxy key
const resetProxyKeyInput = {
chain: Chain.Ethereum,
nonce,
signatureSchema: WalletSignatureSchema.EvmEcdsa,
proxyPrivateKey,
proxyPublicKey
};
// Example reset proxy key message generated by IWalletApi:
// subject: main secret reset
// wallet_id: 0x<your_wallet_hin_in_hex>
// nonce: 0x<nonce_in_hex>
// sign_schema: 0x<signature_schema_in_hex>
// data.encrypted_pri_key: 0x<encrypted_proxy_private_key>
// data.l2_pub_key: 0x<proxy_public_key>
// Call resetProxyKey. This API will automatically encrypt the proxy private key before sending.
await hibitClient.resetProxyKey(resetProxyKeyInput);
console.log('Proxy key reset successful');
SDK
Source code https://github.com/Deland-Labs/hibit-sdk
References
Last updated