public class ScriptBuilder
extends java.lang.Object
| Constructor and Description |
|---|
ScriptBuilder() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
buildVerificationScript(byte[] encodedPublicKey)
Builds a verification script for the given public key.
|
static byte[] |
buildVerificationScript(java.util.List<byte[]> encodedPublicKeys,
int signingThreshold)
Builds a verification script for a multi signature account from the given public keys.
|
ScriptBuilder |
contractCall(ScriptHash scriptHash,
java.lang.String method,
java.util.List<ContractParameter> params)
Appends a call to the contract denoted by the given script hash.
|
ScriptBuilder |
opCode(OpCode opCode)
Appends an OpCode to the script.
|
ScriptBuilder |
opCode(OpCode opCode,
byte[] argument)
Appends an OpCode and a belonging argument to the script.
|
ScriptBuilder |
pack() |
ScriptBuilder |
pushArray(ContractParameter[] params) |
ScriptBuilder |
pushBoolean(boolean bool) |
ScriptBuilder |
pushData(byte[] data)
Adds the data to the script, prefixed with the correct code for its length.
|
ScriptBuilder |
pushData(java.lang.String data)
Adds the data to the script, prefixed with the correct code for its length.
|
ScriptBuilder |
pushInteger(java.math.BigInteger v)
Adds a push operation with the given integer to the script.
|
ScriptBuilder |
pushInteger(int v)
Adds a push operation with the given integer to the script.
|
ScriptBuilder |
pushParam(ContractParameter param) |
ScriptBuilder |
pushParams(java.util.List<ContractParameter> params)
Adds the given contract parameters to the script.
|
ScriptBuilder |
sysCall(InteropServiceCode operation) |
byte[] |
toArray() |
public ScriptBuilder opCode(OpCode opCode)
opCode - The OpCode to append.public ScriptBuilder opCode(OpCode opCode, byte[] argument)
opCode - The OpCode to append.argument - The argument of the OpCode.public ScriptBuilder contractCall(ScriptHash scriptHash, java.lang.String method, java.util.List<ContractParameter> params)
scriptHash - The script hash of the contract to call.method - The method to call.params - The parameters that will be used in the call. Need to be in correct order.public ScriptBuilder sysCall(InteropServiceCode operation)
public ScriptBuilder pushParams(java.util.List<ContractParameter> params)
Example with two parameters in the list:
PUSHBYTES4 a3b00183 PUSHBYTES20 0100000000000000000000000000000000000000 PUSH2 PACK
This method should also be used if the parameters list is empty. In that case the script looks like the following:
PUSH0 PACK
params - The list of parameters to add.public ScriptBuilder pushParam(ContractParameter param)
public ScriptBuilder pushInteger(int v)
v - The number to push.java.lang.IllegalArgumentException - if the given number is smaller than -1.public ScriptBuilder pushInteger(java.math.BigInteger v)
The integer can be up to 32 bytes long.
v - The integer to push.java.lang.IllegalArgumentException - if the given integer is smaller than -1 or takes more space
than 32 bytes.public ScriptBuilder pushBoolean(boolean bool)
public ScriptBuilder pushData(java.lang.String data)
data - The data to add to the script.public ScriptBuilder pushData(byte[] data)
data - The data to add to the script.public ScriptBuilder pushArray(ContractParameter[] params)
public ScriptBuilder pack()
public byte[] toArray()
public static byte[] buildVerificationScript(byte[] encodedPublicKey)
encodedPublicKey - The public key encoded in compressed format.public static byte[] buildVerificationScript(java.util.List<byte[]> encodedPublicKeys,
int signingThreshold)
encodedPublicKeys - The public keys encoded in compressed format.signingThreshold - The desired minimum number of signatures required when using the
multi-sig account.