-
Notifications
You must be signed in to change notification settings - Fork 6
Waves Models
Vladimir edited this page Jul 23, 2019
·
12 revisions
This collection contains the models of transactions and other data transfer objects that you will need for integrating the Waves Services functionality. To read more about transactions please visit the definitions page.
enum TransactionType: Int8 {
case issue = 3
case transfer = 4
case reissue = 5
case burn = 6
case exchange = 7
case lease = 8
case cancelLease = 9
case alias = 10
case massTransfer = 11
case data = 12
case script = 13
case sponsorship = 14
case assetScript = 15
case invokeScript = 16
}
public protocol BaseTransactionQueryProtocol {
/**
ID of the transaction type. Correct values in [1; 16]
*/
var type: Int { get }
/**
Version number of the data structure of the transaction.
The value has to be equal to 2
*/
var version: Int { get }
/**
Determines the network where the transaction will be published to.
T or 84 in bytes for test network,
W or 87 in for main network
*/
var chainId: String { get }
/**
A transaction fee is a fee that an account owner pays to send a transaction.
Transaction fee in WAVELET
[Wiki about Fee](https://docs.wavesplatform.com/en/blockchain/transaction-fee.html)
*/
var fee: Int64 { get }
/**
Unix time of sending of transaction to blockchain, must be in current time +/- 1.5 hour
*/
var timestamp: Int64 { get }
/**
Account public key of the sender in Base58
*/
var senderPublicKey: String { get }
/**
Signatures v2 string set.
A transaction signature is a digital signature
with which the sender confirms the ownership of the outgoing transaction.
If the array is empty, then S= 3. If the array is not empty,
then S = 3 + 2 × N + (P1 + P2 + ... + Pn), where N is the number of proofs in the array,
Pn is the size on N-th proof in bytes.
The maximum number of proofs in the array is 8. The maximum size of each proof is 64 bytes
*/
var proofs: [String] { get }
}
public extension NodeService.DTO {
/**
Transfer transaction sends amount of asset on address.
It is used to transfer a specific amount of an asset (WAVES by default)
to the recipient (by address or alias).
*/
struct TransferTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
/**
Address or alias of Waves blockchain
*/
public let recipient: String
/**
Id of transferable asset in Waves blockchain, different for main and test net
*/
public let assetId: String?
/**
Asset id instead Waves for transaction commission withdrawal
*/
public let feeAssetId: String?
/**
Amount of asset in satoshi
*/
public let amount: Int64
/**
Additional info [0,140] bytes of string
*/
public let attachment: String?
}
}
public extension NodeService.DTO {
/**
The Data transaction stores data in account data storage of the blockchain.
The storage contains data recorded using a data transaction or an invoke script transaction.
The maximum length of the data array is 100 elements.
The maximum size of the data array is 140 kilobytes.
Each element of the data array is an object that has 3 fields: key, type, value.
The array of data cannot contain two elements with the same key field.
Fee depends of data transaction length (0.001 per 1kb)
*/
struct DataTransaction: Decodable {
/**
Data of Data transaction
*/
public struct Data: Decodable {
public enum Value {
case bool(Bool)
case integer(Int)
case string(String)
case binary(String)
}
/**
Key of data of Data transaction
*/
public let key: String
/**
Type of data of the Data transaction type can be only "string", "boolean", "integer", "binary"
*/
public let type: String
/**
Data transaction value can be one of four types:
[Long] for integer(0),
[Boolean] for boolean(1),
[String] for binary(2) You can use "base64:binaryString" and just "binaryString".
and [String] string(3).
Can't be empty string
*/
public let value: Value
}
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let height: Int64?
public let version: Int
public let proofs: [String]?
/**
Data as JSON-string as byte array
The value of the key field is a UTF-8 encoded string
of length from 1 to 100 characters inclusive.
It can be of four types - integer(0), boolean(1), binary array(2) and string(3).
The size of value field can be from 0 to 65025 bytes.
Example:
"data": [
{"key": "int", "type": "integer", "value": 24},
{"key": "bool", "type": "boolean", "value": true},
{"key": "blob", "type": "binary", "value": "base64:BzWHaQU="}
{"key": "My poem", "type": "string", "value": "Oh waves!"}
],
*/
public let data: [Data]
}
}
extension NodeService.DTO {
/**
Invoke script transaction is a transaction that invokes functions of the dApp script.
dApp contains compiled functions developed with [Waves Ride IDE]({https://ide.wavesplatform.com/)
You can invoke one of them by name with some arguments.
*/
public struct InvokeScriptTransaction: Decodable {
/**
Call the function from dApp (address or alias) with typed arguments
*/
public struct Call: Decodable {
/**
Arguments for the function call
*/
public struct Args: Decodable {
public enum Value {
case bool(Bool)
case integer(Int)
case string(String)
case binary(String)
}
public let type: String
public let value: Value
}
/**
Function unique name
*/
public let function: String
/**
List of arguments
*/
public let args: [Args]
}
/**
Payment for function of dApp. Now it works with only one payment.
*/
public struct Payment: Decodable {
/**
Amount in satoshi
*/
public let amount: Int64
/**
Asset Id in Waves blockchain
*/
public let assetId: String?
}
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let proofs: [String]?
public let version: Int
public let height: Int64?
/**
Asset id instead Waves for transaction commission withdrawal
*/
public let feeAssetId: String?
/**
dApp – address or alias of contract with function on RIDE language
*/
public let dApp: String
/**
Function name in dApp with array of arguments
*/
public let call: Call?
/**
Payments for function of dApp. Now it works with only one payment.
*/
public let payment: [Payment]
}
}
public extension NodeService.DTO {
/**
The Alias transaction creates short readable alias for address
*/
struct AliasTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
/**
Alias, short name for address in Waves blockchain.
Alias bytes must be in [4;30]
Alphabet: -.0123456789@_abcdefghijklmnopqrstuvwxyz
*/
public let alias: String
}
}
BurnTransaction – irreversible deletes amount of some asset. It's impossible to burn WAVES with the burn transaction.
public extension NodeService.DTO {
/**
The Burn transaction irreversible deletes amount of some asset
It's impossible to burn WAVES with the burn transaction.
*/
struct BurnTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let chainId: Int?
/**
Id of burnable asset in Waves blockchain, different for main and test net
*/
public let assetId: String
/**
Amount of asset to burn in satoshi
*/
public let amount: Int64
}
}
public extension NodeService.DTO {
/**
The Issue transaction add a new asset in blockchain.
Issue transaction is used to give the user the possibility to issue his/her own tokens
on Waves blockchain. The user can define the exact amount of the issued tokens
and he can reissue more tokens later by enabling the reissuable flag (1- true).
Script can be developed with [Waves Ride IDE]({https://ide.wavesplatform.com/)
*/
struct IssueTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let assetId: String
/**
Name of your new asset byte length must be in [4,16]
*/
public let name: String
/**
Quantity defines the total tokens supply that your asset will contain.
*/
public let quantity: Int64
/**
Reissuability allows for additional tokens creation that will be added
to the total token supply of asset.
A non-reissuable asset will be permanently limited to the total token supply
defined during the transaction.
*/
public let reissuable: Bool
/**
Decimals defines the number of decimals that your asset token will be divided in.
Max decimals is 8
*/
public let decimals: Int
/**
Description of your new asset byte length must be in [0;1000]
*/
public let description: String
/**
A Smart Asset is an asset with an attached script that places conditions
on every transaction made for the token in question.
Each validation of a transaction by a Smart Asset's script increases the transaction fee
by 0.004 WAVES. For example,
if a regular tx is made for a Smart Asset, the cost is 0.001 + 0.004 = 0.005 WAVES.
If an exchange transaction is made, the cost is 0.003 + 0.004 = 0.007 WAVES.
Null - issue without script.
You can update it later only if here in issue script != null.
You can't update later if set script == null now
You can use "base64:compiledScriptStringInBase64" and just "compiledScriptStringInBase64"
Can't be empty string
*/
public let script: String?
}
}
public extension NodeService.DTO {
/**
The Cancel leasing transaction reverse [LeaseTransaction].
Lease cancel transaction is used to to cancel
and discontinue the WAVES leasing process to a Waves node.
*/
struct LeaseCancelTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let chainId: Int?
/**
Id of Leasing Transaction to cancel
*/
public let leaseId: String
public let lease: NodeService.DTO.LeaseTransaction?
}
}
public extension NodeService.DTO {
/**
The Leasing transaction leases amount of Waves to node operator.
it can be address or alias by Proof-of-Stake consensus. It will perform at non-node address.
You always can reverse the any leased amount by [LeaseCancelTransaction]
*/
struct LeaseTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
/**
Amount to lease of Waves in satoshi
*/
public let amount: Int64
/**
Address or alias of Waves blockchain to lease
*/
public let recipient: String
}
}
public extension NodeService.DTO {
/**
The Mass-Transfer transaction sends a lot of transactions of asset for recipients set
Transfer transaction is used to combine several ordinary transfer transactions
that share single sender and asset ID (it has a list of recipients,
and an amount to be transferred to each recipient).
The maximum number of recipients in a single transaction is 100.
The transfers to self are allowed, as well as zero valued transfers.
In the recipients list, a recipient can occur several times, this is not considered an error.
Fee depends of mass transactions count
0.001 + 0.0005 × N, N is the number of transfers inside of a transaction
*/
struct MassTransferTransaction: Decodable {
/**
* The item of the Mass-transfer transaction
*/
public struct Transfer: Decodable {
/**
Address or alias of Waves blockchain
*/
public let recipient: String
/**
Amount of asset in satoshi
*/
public let amount: Int64
}
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let proofs: [String]?
/**
Id of transferable asset in Waves blockchain, different for main and test net
*/
public let assetId: String?
/**
Additional info in Base58 converted string
[0,140] bytes of string encoded in Base58
*/
public let attachment: String
/**
Not necessary
*/
public let transferCount: Int
/**
Not necessary
*/
public let totalAmount: Int64
/**
Collection of recipients with amount each
*/
public let transfers: [Transfer]
}
}
public extension NodeService.DTO {
/**
The Reissue transaction is used to give the ability to reissue more tokens of an asset
by specifying the amount and the asset id. Only quantity and reissuable can be new values
*/
struct ReissueTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let version: Int
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let chainId: Int?
/**
Id of asset that should be changed
*/
public let assetId: String
/**
Quantity defines the total tokens supply that your asset will contain
*/
public let quantity: Int64
/**
Reissuability allows for additional tokens creation that will be added
to the total token supply of asset.
A non-reissuable asset will be permanently limited to the total token supply
defined during the transaction.
*/
public let reissuable: Bool
}
}
public extension NodeService.DTO {
/**
Set asset script transaction (set script to asset)
You can only update script of asset, that was issued before by [IssueTransaction]
An asset script is a script that is attached to an asset with a set asset script transaction.
An asset with the attached script is called a smart asset.
You can attach a script to an asset only during the creation of the asset.
Script can be developed with [Waves Ride IDE]({https://ide.wavesplatform.com/)
Smart assets are unique virtual currency tokens that may represent a tangible real-world asset,
or a non-tangible ownership that can be purchased, sold, or exchanged as defined
by the rules of a script on the Waves blockchain network.
Only the issuer of that asset can change the asset's script.
*/
struct AssetScriptTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let chainId: Int?
public let version: Int
/**
Selected for script asset Id
*/
public let assetId: String
/**
Base64 binary string with Waves Ride script
You can use "base64:compiledScriptStringInBase64" and just "compiledScriptStringInBase64".
Can't be empty string
*/
public let script: String?
}
}
public extension NodeService.DTO {
/**
Script transactions (set script to account) allow you to extend the available functionality
of the standard Waves application. One of the uses of script transaction
is creating a multi-signature wallet. Script can be developed
with [Waves Ride IDE]({https://ide.wavesplatform.com/)
An account with the attached script is called a smart account.
You can also cancel the active script transaction. You must send transaction with null script.
Before you start, please keep in mind.
We do not recommend you submit script transactions unless you are an experienced user.
!!! Errors can lead to permanent loss of access to your account.
Set script transaction is used to setup an smart account,
The account needs to issue Set script transaction which contains the predicate.
Upon success, every outgoing transaction will be validated not by the default mechanism
of signature validation, but according to the predicate logic.
Account script can be changed or cleared if the script installed allows
the new set script transaction to process. The set script transaction can be changed
by another set script transaction call unless it’s prohibited by a previous set script.
*/
struct ScriptTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let chainId: Int?
public let version: Int
/**
Base64 binary string with Waves Ride script
Null for cancel script. Watch out about commissions on set and cancel script
You can use "base64:compiledScriptStringInBase64" and just "compiledScriptStringInBase64".
Can't be empty string
*/
public let script: String?
}
}
SponsorshipTransaction – moves Waves-fees for selected asset for all transfer transactions to your account
public extension NodeService.DTO {
/**
Sponsorship transaction (or is Autonomous Assets)
moves Waves-fees for selected asset for all transfer transactions
to your account.
Sponsorship transaction is used to set a transaction fee nominated in an asset.
However, node owners need to explicitly allow transaction fees in the asset
by manually editing node configuration file.
Otherwise, node won't be able to mine a block with these transactions.
The sponsorship could be set for an asset. In this case miner will receive fee in waves
for the processing of transactions, the fee of which is nominated in sponsored asset.
After this transaction is confirmed, it becomes possible to use this asset
as a fee (automatically for all miners). When transaction with fee in sponsored fee
asset appears any miner just puts it to forged block.
Instead of just transferring fee asset to miner's balance blockchain does a bit different thing:
It automatically moves fee asset to sponsor's (issuer's) account
and transfers standard transaction cost in WAVES from sponsor's to miner's accounts.
In fact two miners will receive these WAVES because of NG 40/60 fee distributions.
Example:
I issue my own asset - Super Coin. I want others to use super coin as a fee.
I create SponsorshipTransaction(asset="Super Coin's id", sponsored=true, transactionFee=0.1).
Then I put 100 waves to my account. Now anyone can create Transfer transaction
with 0.1 super coin as a fee. Someone creates transaction with fee = 0.1 super coin,
as a result I get 0.1 super coin on my account, and miners get 0.001 waves from my account.
Since I have 100 waves, users can do 100000 transaction until
the deposit will be fully transferred to miners,
at this moment I will have 10000 super coins from fees.
When deposit is gone no new transactions with super coin fees can be made.
Only the issuer of an asset can set up sponsorship.
The sponsorship is set by giving the rate at which fee in an asset is converted to Waves.
For cancel send with minSponsoredAssetFee == 0
*/
struct SponsorshipTransaction: Decodable {
public let type: Int
public let id: String
public let sender: String
public let senderPublicKey: String
public let fee: Int64
public let timestamp: Date
public let height: Int64?
public let signature: String?
public let proofs: [String]?
public let version: Int
/**
Selected your asset Id for sponsorship
*/
public let assetId: String
/**
Min sponsored asset fee. If "0" Sponsorship will be cancelled
*/
public let minSponsoredAssetFee: Int64?
}
}
Find full methods list of the Matcher available in Matcher-Service
- CreateOrderRequest – create a order to DEX-matcher, decentralized exchange of Waves
/**
Create Order Request to DEX-matcher, decentralized exchange of Waves.
It collects orders from users who created CreateOrderRequest,
matches and sends it to blockchain it by Exchange transactions.
*/
struct CreateOrder {
public enum OrderType: String {
case sell
case buy
}
public struct AssetPair {
public let amountAssetId: String
public let priceAssetId: String
internal var paramenters: [String : String] {
return [Constants.amountAsset : amountAssetId.normalizeWavesAssetId,
Constants.priceAsset : priceAssetId.normalizeWavesAssetId]
}
public init(amountAssetId: String,
priceAssetId: String) {
self.amountAssetId = amountAssetId
self.priceAssetId = priceAssetId
}
}
/**
Matcher Public Key, available in MatcherService.matcherPublicKey() for DEX
*/
public let matcherPublicKey: String
/**
Account public key of the sender in Base58
*/
public let senderPublicKey: String
/**
Exchangeable pair. We sell or buy always amount asset and we always give price asset
*/
public let assetPair: AssetPair
/**
Amount of asset in satoshi
*/
public let amount: Int64
/**
Price for amount
*/
public let price: Int64
/**
Order type "buy" or "sell"
*/
public let orderType: OrderType
/**
Amount matcher fee of Waves in satoshi
*/
public let matcherFee: Int64
/**
Unix time of sending of transaction to blockchain, must be in current time +/- half of hour
*/
public let timestamp: Int64
/**
Unix time of expiration of transaction to blockchain
*/
public let expirationTimestamp: Int64
/**
If the array is empty, then S= 3. If the array is not empty,
then S = 3 + 2 × N + (P1 + P2 + ... + Pn), where N is the number of proofs in the array,
Pn is the size on N-th proof in bytes.
The maximum number of proofs in the array is 8. The maximum size of each proof is 64 bytes
*/
public let proofs: [String]
- CancelOrderRequest – cancel the order in DEX-matcher
/**
Cancel Order Request in DEX-matcher, decentralized exchange of Waves.
It collects orders from users who created CreateOrderRequest,
matches and sends it to blockchain it by Exchange transactions.
*/
struct CancelOrder {
/**
Order Id of order to cancel
*/
public let orderId: String
/**
Order signature by account private key
*/
public let signature: String
/**
Account public key of the sender in Base58
*/
public let senderPublicKey: String
public let amountAsset: String
public let priceAsset: String