Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Of Change As I work on enhancing our [QuickStart guide](https://docs.cdp.coinbase.com/staking/docs/welcome) to add a concrete example to do a e2e stake tx, I realized that having helper functions around reading unsigned txs given a workflow and then ability to sign unsigned txs given wallet's private key would be very helpful. ## Testing Procedure Created a demo app to import the newly exported functions and get a signed staking tx. This is the example that will go into our Quickstart guide. ``` import { StakingClient, TxSignerFactory, getUnsignedTx } from '@coinbase/staking-client-library-ts'; // Set your api key name and private key here. Get your keys from here: https://portal.cdp.coinbase.com/access/api const apiKeyName: string = 'YOUR_API_KEY_NAME'; const apiPrivateKey: string = 'YOUR_API_PRIVATE_KEY'; // Set your wallet details const walletAddress: string = 'YOUR_WALLET_ADDRESS'; const walletPrivateKey: string = 'YOUR_WALLET_PRIVATE_KEY'; const client = new StakingClient(apiKeyName, apiPrivateKey); async function stake() { // Step 1 - Get an unsigned tx corresponding to a // stake of 11 wei ETH from your wallet on network Holesky. let workflow = await client.Ethereum.stake('holesky', walletAddress, '11'); let unsignedTx = getUnsignedTx(workflow); console.log('Unsigned tx %s', unsignedTx); // Step 2 - Sign the unsigned tx with your wallet's private key. // Note: In production, this part would be performed via a wallet-sdk of your choice. const signer = TxSignerFactory.getSigner('ethereum'); const signedTx = await signer.signTransaction(walletPrivateKey, unsignedTx); console.log('Signed tx %s', signedTx); console.log('You can use this UI https://holesky.etherscan.io/pushTx or ' + 'APIs you are familiar with to help broadcast the signed tx on Holesky.'); } stake().catch((error) => { console.error(error); }); ```
- Loading branch information