MAINNET:
Loading...
TESTNET:
Loading...
/
onflow.org
Flow Playground

Transaction Templates

Transfer Tokens (FLOW)

transaction(amount: UFix64, to: Address) {

    let vault: @FungibleToken.Vault

    prepare(signer: AuthAccount) {
        self.vault <- signer
            .borrow<&{FungibleToken.Provider}>(from: /storage/flowTokenVault)!
            .withdraw(amount: amount)
    }

    execute {
        getAccount(to)
            .getCapability(/public/flowTokenReceiver)
            .borrow<&{FungibleToken.Receiver}>()!
            .deposit(from: <-self.vault)
    }
}
  • First parameter: amount:

    {
        "type": "UFix64",
        "value": "<integer>.<fractional>"
    }
    
  • Second parameter: receiver address

    {
        "type": "Address",
        "value": "0x0" // as hex-encoded string with 0x prefix
    }
    

Create Account

transaction(publicKeys: [[UInt8]]) {

    prepare(signer: AuthAccount) {
        let acct = AuthAccount(payer: signer)
        for key in publicKeys {
            acct.addPublicKey(key)
        }
    }
}
  • Parameter: public keys

    {
        "type": "Array",
        "value": [
            {
                "type": "Array",
                "value": [
                    {"type": "UInt8", value: 123},
                    ...
                ]
            },
            ...
        ]
    }
    

Add New Key

transaction(publicKey: [UInt8]) {
    prepare(signer: AuthAccount) {
        let acct = AuthAccount(payer: signer)
        acct.addPublicKey(key)
    }
}
  • Parameter: public key

    {
        "type": "Array",
        "value": [
            {"type": "UInt8", value: 123},
            ...
        ]
    }