diff --git a/examples/node/brc-20-deploy.js b/examples/node/brc-20-deploy.js new file mode 100644 index 00000000..52a7f727 --- /dev/null +++ b/examples/node/brc-20-deploy.js @@ -0,0 +1,33 @@ +import { BRC20Deploy, JsonRpcDatasource, Ordit } from '@sadoprotocol/ordit-sdk' + +const network = 'regtest' +const wallet = new Ordit({ + bip39: '', + network +}) +wallet.setDefaultAddress('taproot') +const datasource = new JsonRpcDatasource({ network }) + +async function main() { + const tx = new BRC20Deploy({ + address: wallet.selectedAddress, + pubKey: wallet.publicKey, + destinationAddress: wallet.selectedAddress, + feeRate: 2, + network: 'regtest', + tick: 'TEST', + supply: 1000000000, + limit: 100, + }) + + const revealData = await tx.reveal() + console.log({ revealData }) + + const hex = await tx.deploy() + const signedTxHex = wallet.signPsbt(hex, { isRevealTx: true }) + const txId = await datasource.relay({ hex: signedTxHex }) + + console.log({ txId }) +} + +main() \ No newline at end of file diff --git a/examples/node/brc-20-mint.js b/examples/node/brc-20-mint.js new file mode 100644 index 00000000..2c350216 --- /dev/null +++ b/examples/node/brc-20-mint.js @@ -0,0 +1,34 @@ +import { BRC20Mint, JsonRpcDatasource, Ordit } from '@sadoprotocol/ordit-sdk' + +const network = 'regtest' +const wallet = new Ordit({ + bip39: '', + network +}) +wallet.setDefaultAddress('taproot') +const datasource = new JsonRpcDatasource({ network }) + +async function main() { + const tx = new BRC20Mint({ + address: wallet.selectedAddress, + pubKey: wallet.publicKey, + destinationAddress: wallet.selectedAddress, + feeRate: 2, + network, + tick: 'TEST', + amount: 100 + }) + + const revealData = await tx.reveal() + console.log({ revealData }) + + const hex = await tx.mint() + if(!hex) return + + const signedTxHex = wallet.signPsbt(hex, { isRevealTx: true }) + const txId = await datasource.relay({ hex: signedTxHex }) + + console.log({ txId }) +} + +main() \ No newline at end of file diff --git a/examples/node/brc-20-transfer-executor.js b/examples/node/brc-20-transfer-executor.js new file mode 100644 index 00000000..301a98b4 --- /dev/null +++ b/examples/node/brc-20-transfer-executor.js @@ -0,0 +1,38 @@ +import { BRC20TransferExecutor, JsonRpcDatasource, Ordit } from '@sadoprotocol/ordit-sdk' + +const network = 'regtest' +const wallet = new Ordit({ + bip39: '', + network +}) + +const destWallet = new Ordit({ + bip39: '', + network +}) + +wallet.setDefaultAddress('taproot') +destWallet.setDefaultAddress('taproot') +const datasource = new JsonRpcDatasource({ network }) +const destinationAddress = wallet.selectedAddress + +async function main() { + const tx = new BRC20TransferExecutor({ + address: wallet.selectedAddress, + pubKey: wallet.publicKey, + destinationAddress, + feeRate: 2, + network, + tick: 'TEST', + amount: 10 + }) + + const hex = await tx.transfer() + if(hex) { + const signedTxHex = wallet.signPsbt(hex, { isRevealTx: true }) + const txId = await datasource.relay({ hex: signedTxHex }) + console.log({ txId }) + } +} + +main() \ No newline at end of file diff --git a/examples/node/brc-20-transfer-generator.js b/examples/node/brc-20-transfer-generator.js new file mode 100644 index 00000000..b0c776fd --- /dev/null +++ b/examples/node/brc-20-transfer-generator.js @@ -0,0 +1,34 @@ +import { BRC20TransferGenerator, JsonRpcDatasource, Ordit } from '@sadoprotocol/ordit-sdk' + +const network = 'regtest' +const wallet = new Ordit({ + bip39: '', + network +}) +wallet.setDefaultAddress('taproot') +const datasource = new JsonRpcDatasource({ network }) + +async function main() { + const tx = new BRC20TransferGenerator({ + address: wallet.selectedAddress, + pubKey: wallet.publicKey, + feeRate: 3, + network, + tick: 'TEST', + amount: 10 + }) + + const revealData = await tx.reveal() + console.log({ revealData }) + + // generate transfer inscription + const hex = await tx.generate() + + if(hex) { + const signedTxHex = wallet.signPsbt(hex, { isRevealTx: true }) + const txId = await datasource.relay({ hex: signedTxHex }) + console.log({ txId }) + } +} + +main() \ No newline at end of file diff --git a/examples/node/package.json b/examples/node/package.json index 20dd0919..d1917165 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -12,7 +12,11 @@ "instant-buy": "node instant-buy", "publish-collection": "node collections", "build-psbt": "node build-psbt", - "split-utxo": "node split-utxo" + "split-utxo": "node split-utxo", + "brc20-deploy": "node brc-20-deploy", + "brc20-mint": "node brc-20-mint", + "brc20-transfer-generator": "node brc-20-transfer-generator", + "brc20-transfer-executor": "node brc-20-transfer-executor" }, "author": "", "license": "ISC",