-
Notifications
You must be signed in to change notification settings - Fork 4
/
update-message.js
executable file
·44 lines (38 loc) · 1.1 KB
/
update-message.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
const {
AnchorMode,
broadcastTransaction,
cvToHex,
makeContractCall,
stringUtf8CV,
} = require("@stacks/transactions");
const { StacksTestnet } = require("@stacks/network");
var argv = require("yargs/yargs")(process.argv.slice(2))
.usage("Usage: $0 <message> [options]")
.default({ a: "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", n: "billboard" })
.demandCommand(1)
.demandOption(["k"])
.alias("k", "private-key")
.describe("k", "private key")
.alias("a", "address")
.describe("a", "contract principal address")
.alias("n", "contract-name")
.describe("n", "contract name")
.help("h")
.alias("h", "help").argv;
const network = new StacksTestnet({ url: "http://localhost:3999" });
const txOptions = {
contractAddress: argv.a,
contractName: argv.n,
functionName: "set-message",
functionArgs: [stringUtf8CV(argv._[0])],
senderKey: argv.k,
validateWithAbi: true,
network,
anchorMode: AnchorMode.Any,
postConditionMode: 1,
};
const transaction = makeContractCall(txOptions).then((txn) => {
broadcastTransaction(txn, network);
console.log(argv._[0]);
});