Skip to content

Instantly share code, notes, and snippets.

@Karasiq
Created July 3, 2020 11:15
Show Gist options
  • Save Karasiq/90013f431f2065bdac4a9897f1637f97 to your computer and use it in GitHub Desktop.
Save Karasiq/90013f431f2065bdac4a9897f1637f97 to your computer and use it in GitHub Desktop.
waves-transactions-test
package im.mak.waves.transactions;
import im.mak.waves.crypto.account.PrivateKey;
import im.mak.waves.crypto.account.PublicKey;
import im.mak.waves.crypto.account.Seed;
import im.mak.waves.transactions.common.*;
import im.mak.waves.transactions.invocation.Function;
import im.mak.waves.transactions.invocation.StringArg;
import java.util.ArrayList;
public class test {
public static void main(String[] args) {
Seed seed = Seed.from("test");
PrivateKey privateKey = PrivateKey.from(seed);
PublicKey publicKey = PublicKey.from(privateKey);
Recipient address = Recipient.as(publicKey.address((byte) 'W'));
TransferTransaction transfer = TransferTransaction
.with(address, Amount.of(100, Asset.WAVES))
.fee(100)
.feeAsset(Asset.WAVES)
.timestamp(123)
.sender(publicKey)
.attachment("")
.version(1)
.get();
transfer.proofs().add(Proof.as(privateKey.sign(transfer.bodyBytes())));
System.out.println(transfer.toJson());
DataTransaction data = DataTransaction
.with()
.string("test", "test")
.integer("test1", 123)
.sender(publicKey)
.version(1)
.timestamp(123)
.fee(123)
.get();
data.proofs().add(Proof.as(privateKey.sign(data.bodyBytes())));
System.out.println(data.toJson());
byte[] script = new byte[]{1, 2, 3};
SetScriptTransaction setScript = SetScriptTransaction.with(script)
.sender(publicKey)
.fee(123)
.timestamp(123)
.version(1)
.get();
data.proofs().add(Proof.as(privateKey.sign(setScript.bodyBytes())));
System.out.println(setScript.toJson());
InvokeScriptTransaction invoke = InvokeScriptTransaction
.with(address, Function.as("test", new StringArg("test")))
.payments(new ArrayList<>())
.chainId(Waves.chainId)
.fee(100000)
.feeAsset(Asset.WAVES)
.timestamp(123)
.sender(publicKey)
.version(1)
.get();
invoke.proofs().add(Proof.as(privateKey.sign(invoke.bodyBytes())));
System.out.println(invoke.toJson());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment