Created
July 3, 2020 12:32
-
-
Save Karasiq/43c2f28e1675c783c17889cdd2186c37 to your computer and use it in GitHub Desktop.
Refined scala calls demo
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
import com.wavesplatform.account.Address; | |
import com.wavesplatform.account.KeyPair; | |
import com.wavesplatform.common.state.ByteStr; | |
import com.wavesplatform.state.DataEntry; | |
import com.wavesplatform.transaction.Asset; | |
import com.wavesplatform.transaction.DataTransaction; | |
import com.wavesplatform.transaction.Proofs; | |
import com.wavesplatform.transaction.smart.InvokeScriptTransaction; | |
import com.wavesplatform.transaction.smart.SetScriptTransaction; | |
import com.wavesplatform.transaction.transfer.TransferTransaction; | |
import scala.Option; | |
import scala.collection.immutable.Seq; | |
public class Test { | |
public static void main(String[] args) { | |
final KeyPair keyPair = KeyPair.apply("test".getBytes()); | |
Address address = Address.fromPublicKey(keyPair.publicKey(), (byte) 'W'); | |
TransferTransaction transfer = | |
new TransferTransaction( | |
(byte) 1, | |
keyPair.publicKey(), | |
address, | |
Asset.waves(), | |
100, | |
Asset.waves(), | |
100, | |
ByteStr.empty(), | |
100, | |
Proofs.empty(), | |
(byte) 'W'); | |
TransferTransaction signedTransfer = Transactions.sign(transfer, keyPair.privateKey()); | |
System.out.println(Transactions.jsonString(signedTransfer)); | |
Seq<DataEntry<?>> entries = | |
ScalaColls.list(DataEntries.string("test", "test"), DataEntries.integer("test1", 123)); | |
DataTransaction data = | |
new DataTransaction( | |
(byte) 1, keyPair.publicKey(), entries, 100, 100, Proofs.empty(), (byte) 'W'); | |
DataTransaction signedData = Transactions.sign(data, keyPair.privateKey()); | |
System.out.println(Transactions.jsonString(signedData)); | |
SetScriptTransaction setScript = | |
new SetScriptTransaction( | |
(byte) 1, | |
keyPair.publicKey(), | |
Option.apply(Scripts.compile("true")), | |
100, | |
100, | |
Proofs.empty(), | |
(byte) 'W'); | |
SetScriptTransaction signedSetScript = Transactions.sign(setScript, keyPair.privateKey()); | |
System.out.println(Transactions.jsonString(signedSetScript)); | |
InvokeScriptTransaction invoke = | |
new InvokeScriptTransaction( | |
(byte) 1, | |
keyPair.publicKey(), | |
address, | |
Scripts.functionCall("test", "test", 123), | |
ScalaColls.list(), | |
100, | |
Asset.waves(), | |
100, | |
Proofs.empty(), | |
(byte) 'W'); | |
InvokeScriptTransaction signedInvoke = Transactions.sign(invoke, keyPair.privateKey()); | |
System.out.println(Transactions.jsonString(signedInvoke)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment