Skip to main content

Spend

Mystiko Spend Related APIs.

Data Structures

Quote

Retrieve quote information for a spend.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<SpendQuote, SpendError> = await api.quote(QuoteSpendOptions(chainId: 1, asset_symbol: 'MTT'));

QuoteSpendOptions:

ParameterRequiredDescription
chainIdtrue
The chain ID of the asset.
assetSymboltrue
The asset symbol.
versionfalse
The version of the spend.
amountfalse
The amount of the spend.
useRelayerfalse
Whether to use a relayer.
queryTimeoutMsfalse
The query timeout in milliseconds.
spendTypefalse
The type of spend.
bridgeTypefalse
The bridge type.

SpendQuote data structure is as follows:

PropertyTypeDescription
validBool
Whether the quote is valid.
assetSymbolString
The asset symbol.
assetDecimalsInt
The asset decimals.
currentBalanceDouble
The current balance.
currentDecimalBalanceString
The current decimal balance.
numOfInputsInt
The number of inputs.
numOfOutputsInt
The number of outputs.
minRollupFeeDouble
The minimum rollup fee.
minRollupFeeDecimalString
The minimum rollup fee decimal.
rollupFeeAssetSymbolString
The rollup fee asset symbol.
rollupFeeAssetDecimalsInt
The rollup fee asset decimals.
fixedAmountsList<double>
The fixed amounts.
fixedDecimalAmountsList<string>
The fixed decimal amounts.
selectedCommitmentsList<string>
The selected commitments.
gasRelayersList<GasRelayer>
The gas relayers.
maxGasRelayerFeeDouble
The maximum gas relayer fee.
maxGasRelayerFeeDecimalString
The maximum gas relayer fee decimal.
gasRelayerFeeAssetSymbolString
The gas relayer fee asset symbol.
gasRelayerFeeAssetDecimalsInt
The gas relayer fee asset decimals.
invalidCodeSpendInvalidCode
The invalid code.
amountRangeAmountRange
The amount range.

Summary

Retrieve summary information for a spend.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<SpendSummary, SpendError> response = await api.summary(CreateSpendOptions(
chainId: 1,
asset_symbol: 'MTT',
amount: 100,
recipient: '0x1234567890',
wallet_password: 'password',
));

CreateSpendOptions:

ParameterRequiredDescription
chainIdtrue
The chain ID of the asset.
assetSymboltrue
The asset symbol.
amounttrue
The amount of the spend.
recipienttrue
The recipient address.
walletPasswordtrue
The wallet password.
versionfalse
The version of the spend.
rollupFeeAmountfalse
The rollup fee amount.
gasRelayerfalse
The gas relayer.
queryTimeoutMsfalse
The query timeout in milliseconds.
spendQuotefalse
The spend quote.
spendTypefalse
The type of spend.
bridgeTypefalse
The bridge type.

SpendSummary data structure is as follows:

PropertyTypeDescription
assetSymbolString
The asset symbol.
assetDecimalsInt
The asset decimals.
currentBalanceDouble
The current balance.
currentDecimalBalanceString
The current decimal balance.
newBalanceDouble
The new balance.
newDecimalBalanceString
The new decimal balance.
amountDouble
The amount.
decimalAmountString
The decimal amount.
recipientString
The recipient address.
rollupFeeAmountDouble
The rollup fee amount.
rollupFeeDecimalAmountString
The rollup fee decimal amount.
rollupFeeTotalAmountDouble
The rollup fee total amount.
rollupFeeTotalDecimalAmountString
The rollup fee total decimal amount.
rollupFeeAssetSymbolString
The rollup fee asset symbol.
rollupFeeAssetDecimalsInt
The rollup fee asset decimals.
gasRelayerFeeAmountDouble
The gas relayer fee amount.
gasRelayerFeeDecimalAmountString
The gas relayer fee decimal amount.
gasRelayerFeeAssetSymbolString
The gas relayer fee asset symbol.
gasRelayerFeeAssetDecimalsInt
The gas relayer fee asset decimals.
gasRelayerAddressString
The gas relayer address.
gasRelayerNameString
The gas relayer name.
gasRelayerUrlString
The gas relayer URL.

Create

Create a Spend request.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Spend, SpendError> response = await api.create(CreateSpendOptions(
chainId: 1,
asset_symbol: 'MTT',
amount: 100,
recipient: '0x1234567890',
wallet_password: 'password',
));

Spend data structure is as follows:

PropertyTypeDescription
idString
The ID of the spend.
createdAtInt64
The creation time of the spend.
updatedAtInt64
The update time of the spend.
chainIdInt64
The chain ID of the asset.
contractAddressString
The contract address.
assetSymbolString
The asset symbol.
assetDecimalsInt
The asset decimals.
amountDouble
The amount.
decimalAmountString
The decimal amount.
recipientString
The recipient address.
walletIdString
The wallet ID.
inputCommitmentsList<String>
The input commitments.
outputCommitmentsList<String>
The output commitments.
nullifiersList<String>
The nullifiers.
signaturePublicKeyHashesList<String>
The signature public key hashes.
encryptedAuditorNotesList<String>
The encrypted auditor notes.
rollupFeeAmountDouble
The rollup fee amount.
rollupFeeDecimalAmountString
The rollup fee decimal amount.
rollupFeeTotalAmountDouble
The rollup fee total amount.
rollupFeeTotalDecimalAmountString
The rollup fee total decimal amount.
gasRelayerFeeAmountDouble
The gas relayer fee amount.
gasRelayerFeeDecimalAmountString
The gas relayer fee decimal amount.
signaturePublicKeyString
The signature public key.
assetAddressString
The asset address.
proofString
The proof.
rootHashString
The root hash.
gasRelayerAddressString
The gas relayer address.
gasRelayerUrlString
The gas relayer URL.
signatureString
The signature.
randomAuditingPublicKeyString
The random auditing public key.
errorMessageString
The error message.
transactionHashString
The transaction hash.
bridgeTypeBridgeType
The bridge type.
spendTypeSpendType
The spend type.
statusSpendStatus
The spend status.

Send

Send a spend transaction using a private key.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Spend, SpendError> response = await api.send(SendSpendOptions(
spendId: 'id',
privateKey: 'privateKey',
walletPassword: 'password',
));

SendSpendOptions:

ParameterRequiredDescription
spendIdtrue
The ID of the spend.
walletPasswordtrue
The wallet password.
privateKeytrue
The private key.
signerProviderfalse
The signer provider.
queryTimeoutMsfalse
The query timeout in milliseconds.
spendConfirmationsfalse
The spend confirmations.
txSendTimeoutMsfalse
The transaction send timeout in milliseconds.
txWaitTimeoutMsfalse
The transaction wait timeout in milliseconds.
txWaitIntervalMsfalse
The transaction wait interval in milliseconds.
relayerWaitTimeoutMsfalse
The relayer wait timeout in milliseconds.
relayerWaitIntervalMsfalse
The relayer wait interval in milliseconds.
txfalse
The transaction.
rawMerkleTreefalse
The raw Merkle tree.
rawZkProgramfalse
The raw ZK program.
rawZkProvingKeyfalse
The raw ZK proving key.
rawZkVerifyingKeyfalse
The raw ZK verifying key.
rawZkAbifalse
The raw ZK ABI.

SendWithGrpc

Send a spend transaction by signing through the given gRPC interface.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
SendSpendOptions sendOptions = SendSpendOptions(
spendId: 'id',
walletPassword: 'password',
);
ClientOptions clientOptions = ClientOptions(
host: 'localhost',
port: 9090,
);
Response<Spend, SpendError> response = await api.sendWithGrpc(sendOptions, clientOptions);

ClientOptions:

ParameterRequiredDescription
hosttrue
Host.
porttrue
Port.
isSslfalse
Is SSL.
sslCertfalse
SSL cert.
sslCertPathfalse
SSL cert path.
sslServerNamefalse
SSL server name.

Find

Query Spend data using QueryFilter.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<List<Spend>, SpendError> response = await api.find(QueryFilter());

FindAll

Query all Spend data.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<List<Spend>, SpendError> response = await api.findAll();

FindOne

Find a single Spend record using QueryFilter.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Spend, SpendError> response = await api.findOne(QueryFilter());

FindById

Find a single Spend record by its ID.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
<Response<Spend, SpendError> response = await api.findById('id');

Count

Query the count of data that matches the QueryFilter criteria.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Int64, SpendError> response = await api.count(QueryFilter());

CountAll

Query the total count of all Spend data.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Int64, SpendError> response = await api.countAll();

Update

Update a Spend record.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<Spend, SpendError> response = await api.update(Spend());

UpdateBatch

Batch update Spend records.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
List<Spend> spends = [Spend(), Spend()];
Response<List<Spend>, SpendError> response = await api.updateBatch(List<Spend>());

UpdateByFilter

Update Spend records based on the conditions specified in the QueryFilter.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
List<ColumnValuePair> pairs = [ColumnValuePair(column: 'chainId', value: ColumnValue(i64Value: 1))];
Response<void, SpendError> response = await api.updateByFilter(pairs, QueryFilter());

UpdateAll

Update all Spend records.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
List<ColumnValuePair> pairs = [ColumnValuePair()];
Response<void, SpendError> response = await api.updateAll(pairs);

Delete

Delete a Spend record.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<void, SpendError> response = await api.delete(Spend());

DeleteBatch

Batch delete Spend records.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
List<Spend> spends = [Spend(), Spend()];
Response<void, SpendError> response = await api.deleteBatch(spends);

DeleteByFilter

Delete Spend records based on the conditions specified in the QueryFilter.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<void, SpendError> response = await api.deleteByFilter(QueryFilter());

DeleteAll

Delete all Spend records.

import 'package:mystiko_spend/mystiko_spend.dart';

MystikoSpendApi api = await Mystiko.mystikoSpendApi();
Response<void, SpendError> response = await api.deleteAll();