1.8 KiB
1.8 KiB
aside
| aside |
|---|
| false |
Sandbox
We can include Code Sandboxes in our documentation.
This'll be very useful for:
- Guides
- Testing
Primitives
The below is Address mess.
<CodeSandbox :libs="xocashLibs"
import { Address } from '@xocash/stack';
const lockscriptHex = Address.from('bitcoincash:qr2084lauctzarqk20kqlhef8gyneqhceqy75wvw8q').toLockscriptHex();
console.log(lockscriptHex);
// Testing one new line
console.log({
someText: 'abc'
});
console.info('yep');
Blockchain Connections
We can have more than one per page too. For example:
<CodeSandbox :libs="xocashLibs"
import { BlockchainElectrum } from '@xocash/stack';
const blockchain = new BlockchainElectrum();
await blockchain.start();
const tx = await blockchain.fetchTransaction('a23bbd321067fd039da53f007b26f62591e58e6554b0488d83534c032dbca38b');
console.log('Transaction Hex', tx.toHex());
Wallet Example
The below demonstrates instantiating a wallet.
<CodeSandbox :libs="xocashLibs"
import { BlockchainElectrum, WalletP2PKH } from '@xocash/stack';
const wallet = WalletP2PKH.generateRandom({
blockchain: new BlockchainElectrum
});
const address = await wallet.getReceivingAddress();
console.log(address.toCashAddr());