Isa Surfboard, chishandiso chinokutendera kuti umhanye bvunzo pane iripo node.
npm install -g @waves/surfboard
3. Visual Studio Code plugin
Iyi nhanho ndeyekusarudza kana usiri fan weIDE uye sarudza mavara edhita. Yese maturusi anodiwa ndeye command line utilities. Kana iwe ukashandisa vim, teerera kune iyo plugin vim-ride.
Dhawunirodha uye isa Visual Studio Code: https://code.visualstudio.com/
Alice anobvisa 4 WAVES
alice-kero → 100000000
bob-kero → 200000000
Heino kodhi yekunyatsonzwisisa mamiriro acho:
# In this example multiple accounts can deposit their funds and safely take them back. No one can interfere with this.
# An inner state is maintained as mapping `address=>waves`.
{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP #-}
{-# SCRIPT_TYPE ACCOUNT #-}
@Callable(i)
func deposit() = {
let pmt = extract(i.payment)
if (isDefined(pmt.assetId))
then throw("works with waves only")
else {
let currentKey = toBase58String(i.caller.bytes)
let currentAmount = match getInteger(this, currentKey) {
case a:Int => a
case _ => 0
}
let newAmount = currentAmount + pmt.amount
WriteSet([DataEntry(currentKey, newAmount)])
}
}
@Callable(i)
func withdraw(amount: Int) = {
let currentKey = toBase58String(i.caller.bytes)
let currentAmount = match getInteger(this, currentKey) {
case a:Int => a
case _ => 0
}
let newAmount = currentAmount - amount
if (amount < 0)
then throw("Can't withdraw negative amount")
else if (newAmount < 0)
then throw("Not enough balance")
else ScriptResult(
WriteSet([DataEntry(currentKey, newAmount)]),
TransferSet([ScriptTransfer(i.caller, amount, unit)])
)
}
@Verifier(tx)
func verify() = false
wallet test suite
Generating accounts with nonce: ce8d86ee
Account generated: foofoofoofoofoofoofoofoofoofoofoo#ce8d86ee - 3M763WgwDhmry95XzafZedf7WoBf5ixMwhX
Account generated: barbarbarbarbarbarbarbarbarbar#ce8d86ee - 3MAi9KhwnaAk5HSHmYPjLRdpCAnsSFpoY2v
Account generated: wallet#ce8d86ee - 3M5r6XYMZPUsRhxbwYf1ypaTB6MNs2Yo1Gb
Accounts successfully funded
Script has been set
√ Can deposit (4385ms)
√ Cannot withdraw more than was deposited
√ Can withdraw (108ms)
3 passing (15s)
Hooray! Miedzo yakapfuura. Zvino ngatitarisei zvinoitika kana uchishandisa Waves Explorer: tarisa mabhuroko kana namira imwe yemakero ari pamusoro mukutsvaga (semuenzaniso, inoenderana. wallet#. Ikoko iwe unogona kuwana nhoroondo yekutengeserana, dApp chimiro, decompiled binary faira.