-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
918332b
commit 204acc2
Showing
44 changed files
with
319 additions
and
2,235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["ping-pong", "ping-pong/meta", "ping-pong/interactor"] | ||
members = [ | ||
"ping-pong", | ||
"ping-pong/meta" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Ping-pong | ||
|
||
First [set up a node terminal](../../../../tutorial/src/interaction/interaction-basic.md). | ||
|
||
```javascript | ||
let erdjs = await require('@elrondnetwork/erdjs'); | ||
let { erdSys, Egld, wallets: { alice, bob, carol, dan } } = await erdjs.setupInteractive("local-testnet"); | ||
|
||
let pingPong = await erdSys.loadWrapper("contracts/examples/ping-pong"); | ||
|
||
await pingPong.sender(alice).gas(150_000_000).call.deploy(Egld(0.5), 2 * 60, null, Egld(1.5)); | ||
|
||
await pingPong.gas(20_000_000).sender(alice).value(Egld(0.5)).ping("note 1"); | ||
|
||
await pingPong.sender(bob).value(Egld(0.5)).ping(null); | ||
await pingPong.sender(carol).value(Egld(0.5)).ping(null); | ||
|
||
// this fails because of the balance limit of 1.5 egld | ||
await pingPong.sender(dan).value(Egld(0.5).ping(null); | ||
|
||
await pingPong.pongAll(); | ||
|
||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
PEM_FILE="./ping-pong.pem" | ||
PING_PONG_CONTRACT="output/ping-pong.wasm" | ||
|
||
PROXY_ARGUMENT="--proxy=https://devnet-api.multiversx.com" | ||
CHAIN_ARGUMENT="--chain=D" | ||
|
||
build_ping_pong() { | ||
(set -x; mxpy --verbose contract build "$PING_PONG_CONTRACT") | ||
} | ||
|
||
deploy_ping_pong() { | ||
# local TOKEN_ID=0x45474c44 # "EGLD" | ||
local PING_AMOUNT=1500000000000000000 # 1.5 EGLD | ||
local DURATION=86400 # 1 day in seconds | ||
# local ACTIVATION_TIMESTAMP= # skipped | ||
# local MAX_FUNDS= #skipped | ||
|
||
local OUTFILE="out.json" | ||
(set -x; mxpy contract deploy --bytecode="$PING_PONG_CONTRACT" \ | ||
--pem="$PEM_FILE" \ | ||
$PROXY_ARGUMENT $CHAIN_ARGUMENT \ | ||
--outfile="$OUTFILE" --recall-nonce --gas-limit=60000000 \ | ||
--arguments ${PING_AMOUNT} ${DURATION} --send \ | ||
|| return) | ||
|
||
local RESULT_ADDRESS=$(mxpy data parse --file="$OUTFILE" --expression="data['emitted_tx']['address']") | ||
local RESULT_TRANSACTION=$(mxpy data parse --file="$OUTFILE" --expression="data['emitted_tx']['hash']") | ||
|
||
echo "" | ||
echo "Deployed contract with:" | ||
echo " \$RESULT_ADDRESS == ${RESULT_ADDRESS}" | ||
echo " \$RESULT_TRANSACTION == ${RESULT_TRANSACTION}" | ||
echo "" | ||
} | ||
|
||
number_to_u64() { | ||
local NUMBER=$1 | ||
printf "%016x" $NUMBER | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.