Search code examples
blockchainsmartcontractswavesplatformride

What is the main difference between WriteSet, TransferSet and ContractResult in Ride4dApps?


In Ride4dApps, the callable function returns WriteSet, TransferSet or a ContractResult but I still do not get the main difference between them? and who pays fees for this kind of dApps?


Solution

    • TransferSet, It's a keyValue list which defines what outgoing payments will be made upon your contract invocation.
    • WriteSet, It's a keyValue list which defines what data will be stored in contract's account upon your contract invocation(for example the caller address and balance). So basically it's a list of data entries that should be recorded to read the dApp state.
    • ContractResult, It's the combination of WriteSet and TransferSet.

    The sender pays fees in WAVES(1 + 4*(the cost of each script involved)) to the miner of the invocation.

    Example:

    ContractResult(
                 WriteSet([DataEntry(currentKey, amount)]),
                 TransferSet([ContractTransfer(i.caller, amount, unit)])
                )
    

    Where:

    • DataEntry (key : String, value : String | Binary | Integer | Boolean).
    • i.caller is the caller address.