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
:
Parameter | Required | Description |
---|---|---|
chainId | true | The chain ID of the asset. |
assetSymbol | true | The asset symbol. |
version | false | The version of the spend. |
amount | false | The amount of the spend. |
useRelayer | false | Whether to use a relayer. |
queryTimeoutMs | false | The query timeout in milliseconds. |
spendType | false | The type of spend. |
bridgeType | false | The bridge type. |
SpendQuote
data structure is as follows:
Property | Type | Description |
---|---|---|
valid | Bool | Whether the quote is valid. |
assetSymbol | String | The asset symbol. |
assetDecimals | Int | The asset decimals. |
currentBalance | Double | The current balance. |
currentDecimalBalance | String | The current decimal balance. |
numOfInputs | Int | The number of inputs. |
numOfOutputs | Int | The number of outputs. |
minRollupFee | Double | The minimum rollup fee. |
minRollupFeeDecimal | String | The minimum rollup fee decimal. |
rollupFeeAssetSymbol | String | The rollup fee asset symbol. |
rollupFeeAssetDecimals | Int | The rollup fee asset decimals. |
fixedAmounts | List<double> | The fixed amounts. |
fixedDecimalAmounts | List<string> | The fixed decimal amounts. |
selectedCommitments | List<string> | The selected commitments. |
gasRelayers | List<GasRelayer> | The gas relayers. |
maxGasRelayerFee | Double | The maximum gas relayer fee. |
maxGasRelayerFeeDecimal | String | The maximum gas relayer fee decimal. |
gasRelayerFeeAssetSymbol | String | The gas relayer fee asset symbol. |
gasRelayerFeeAssetDecimals | Int | The gas relayer fee asset decimals. |
invalidCode | SpendInvalidCode | The invalid code. |
amountRange | AmountRange | 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
:
Parameter | Required | Description |
---|---|---|
chainId | true | The chain ID of the asset. |
assetSymbol | true | The asset symbol. |
amount | true | The amount of the spend. |
recipient | true | The recipient address. |
walletPassword | true | The wallet password. |
version | false | The version of the spend. |
rollupFeeAmount | false | The rollup fee amount. |
gasRelayer | false | The gas relayer. |
queryTimeoutMs | false | The query timeout in milliseconds. |
spendQuote | false | The spend quote. |
spendType | false | The type of spend. |
bridgeType | false | The bridge type. |
SpendSummary
data structure is as follows:
Property | Type | Description |
---|---|---|
assetSymbol | String | The asset symbol. |
assetDecimals | Int | The asset decimals. |
currentBalance | Double | The current balance. |
currentDecimalBalance | String | The current decimal balance. |
newBalance | Double | The new balance. |
newDecimalBalance | String | The new decimal balance. |
amount | Double | The amount. |
decimalAmount | String | The decimal amount. |
recipient | String | The recipient address. |
rollupFeeAmount | Double | The rollup fee amount. |
rollupFeeDecimalAmount | String | The rollup fee decimal amount. |
rollupFeeTotalAmount | Double | The rollup fee total amount. |
rollupFeeTotalDecimalAmount | String | The rollup fee total decimal amount. |
rollupFeeAssetSymbol | String | The rollup fee asset symbol. |
rollupFeeAssetDecimals | Int | The rollup fee asset decimals. |
gasRelayerFeeAmount | Double | The gas relayer fee amount. |
gasRelayerFeeDecimalAmount | String | The gas relayer fee decimal amount. |
gasRelayerFeeAssetSymbol | String | The gas relayer fee asset symbol. |
gasRelayerFeeAssetDecimals | Int | The gas relayer fee asset decimals. |
gasRelayerAddress | String | The gas relayer address. |
gasRelayerName | String | The gas relayer name. |
gasRelayerUrl | String | 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:
Property | Type | Description |
---|---|---|
id | String | The ID of the spend. |
createdAt | Int64 | The creation time of the spend. |
updatedAt | Int64 | The update time of the spend. |
chainId | Int64 | The chain ID of the asset. |
contractAddress | String | The contract address. |
assetSymbol | String | The asset symbol. |
assetDecimals | Int | The asset decimals. |
amount | Double | The amount. |
decimalAmount | String | The decimal amount. |
recipient | String | The recipient address. |
walletId | String | The wallet ID. |
inputCommitments | List<String> | The input commitments. |
outputCommitments | List<String> | The output commitments. |
nullifiers | List<String> | The nullifiers. |
signaturePublicKeyHashes | List<String> | The signature public key hashes. |
encryptedAuditorNotes | List<String> | The encrypted auditor notes. |
rollupFeeAmount | Double | The rollup fee amount. |
rollupFeeDecimalAmount | String | The rollup fee decimal amount. |
rollupFeeTotalAmount | Double | The rollup fee total amount. |
rollupFeeTotalDecimalAmount | String | The rollup fee total decimal amount. |
gasRelayerFeeAmount | Double | The gas relayer fee amount. |
gasRelayerFeeDecimalAmount | String | The gas relayer fee decimal amount. |
signaturePublicKey | String | The signature public key. |
assetAddress | String | The asset address. |
proof | String | The proof. |
rootHash | String | The root hash. |
gasRelayerAddress | String | The gas relayer address. |
gasRelayerUrl | String | The gas relayer URL. |
signature | String | The signature. |
randomAuditingPublicKey | String | The random auditing public key. |
errorMessage | String | The error message. |
transactionHash | String | The transaction hash. |
bridgeType | BridgeType | The bridge type. |
spendType | SpendType | The spend type. |
status | SpendStatus | 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
:
Parameter | Required | Description |
---|---|---|
spendId | true | The ID of the spend. |
walletPassword | true | The wallet password. |
privateKey | true | The private key. |
signerProvider | false | The signer provider. |
queryTimeoutMs | false | The query timeout in milliseconds. |
spendConfirmations | false | The spend confirmations. |
txSendTimeoutMs | false | The transaction send timeout in milliseconds. |
txWaitTimeoutMs | false | The transaction wait timeout in milliseconds. |
txWaitIntervalMs | false | The transaction wait interval in milliseconds. |
relayerWaitTimeoutMs | false | The relayer wait timeout in milliseconds. |
relayerWaitIntervalMs | false | The relayer wait interval in milliseconds. |
tx | false | The transaction. |
rawMerkleTree | false | The raw Merkle tree. |
rawZkProgram | false | The raw ZK program. |
rawZkProvingKey | false | The raw ZK proving key. |
rawZkVerifyingKey | false | The raw ZK verifying key. |
rawZkAbi | false | 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
:
Parameter | Required | Description |
---|---|---|
host | true | Host. |
port | true | Port. |
isSsl | false | Is SSL. |
sslCert | false | SSL cert. |
sslCertPath | false | SSL cert path. |
sslServerName | false | 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();