-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
NativeTransferBuilder might be extended like this:
export class NativeTransferBuilderWithSrId extends NativeTransferBuilder {
private _sr_id: any;
constructor() {
super();
this._sr_id = null;
}
/**
* Sets the transfer ID.
*/
public srId(value: number): any {
let arr = new Array<number>(32).fill(0);
arr[0] = value;
this._sr_id = CLValue.newCLByteArray(Uint8Array.from(arr));
return this;
}
/**
* Builds and returns the Native Transfer transaction.
*/
public build(): any {
const transactionV1 = super.build().getTransactionV1();;
if (!transactionV1) {
throw new Error("TransactionV1 is not correct. Check the parameters.");
}
transactionV1.payload.fields.args.insert("sr_id", this._sr_id);
const _transactionV1 = TransactionV1.makeTransactionV1(
transactionV1.payload,
);
return Transaction.fromTransactionV1(_transactionV1);
}
public buildFor1_5(): any {
throw new Error("Use build() instead");
}
}then:
const transaction = new NativeTransferBuilderWithSrId()
.srId(15)
.from(privateKey.publicKey)
.target(PublicKey.fromHex('0202f5a92ab6da536e7b1a351406f3744224bec85d7acbab1497b65de48a1a707b64'))
.amount('4200000000')
.chainName('casper-test')
.build();Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels