-
Notifications
You must be signed in to change notification settings - Fork 22
Description
I'm using VSCode on p2pkh.js but it seems that the code content itself requires Identification and Function, which is why the code p2pkh.js becomes like this below:
const { forgeTx } =require('txforge')
// We'll use these Casts in our transaction
const casts = () => { P2PKH, OpReturn }
// You'll need UTXOs to fund a transaction. Use the toUTXO helper to turn
// your UTXO data into the required objects.
const utxo = () => toUTXO({
txid, // utxo transaction id
vout, // utxo output index
satoshis, // utxo amount
script // utxo lock script
})
// Forge a transaction
const P2PKH = () => { P2PKH }
const myPrivateKey = () => { myPrivateKey }
const tx = forgeTx({
inputs: [
function unlock() {
P2PKH.unlock(utxo, { privkey: myPrivateKey })
}
],
outputs: [
function lock() {
P2PKH.lock(5000, { address: '1DBz6V6CmvjZTvfjvWpvvwuM1X7GkRmWEq' }),
OpReturn.lock(0, { data: ['meta', '1DBz6V6CmvjZTvfjvWpvvwuM1X7GkRmWEq', txid] })
}
],
change: { address: '1Nro9WkpaKm9axmcfPVp79dAJU1Gx7VmMZ' }
})
// And behold! Forged by the Gods and found by a King - a transaction is born.
console.log(tx.toHex())
- When I "Run" the above the error prompted as:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/Users/jsjs77/node_modules/@runonbitcoin/nimble/classes/p2pkhs.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
Any solution for the above? Note that my VScode in Mac unable to Import, that's why use "const"
Thanks