-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·38 lines (30 loc) · 903 Bytes
/
deploy.sh
File metadata and controls
executable file
·38 lines (30 loc) · 903 Bytes
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
#!/bin/zsh
set -e
if [[ "$#" -ne 2 ]]; then
echo "usage: $0 <account> <wasm_file>"
exit 1
fi
ACC_ROOT=$1
WASM_FILE=$2
echo "ACC_ROOT=$ACC_ROOT"
echo "WASM_FILE=$WASM_FILE"
near deploy -f --accountId $ACC_ROOT --wasmFile "$(dirname $0)/res/generic_factory.wasm"
script=$(cat <<EOF
const main = async () => {
const accountId = "$ACC_ROOT";
const contractName = accountId;
const fs = require('fs');
const account = await near.account(accountId);
const code = fs.readFileSync("$WASM_FILE");
const result = await account.signAndSendTransaction({
receiverId: contractName,
actions: [nearAPI.transactions.functionCall("set_code", code, 300_000_000_000_000, "0")]
});
console.log(result);
console.log(JSON.parse(atob(result.receipts_outcome[0].outcome.status.SuccessValue)));
console.log('TxHash: ' + result.transaction.hash);
};
main();
EOF
)
echo "$script" | near repl