Hi,
can somebody provide me code snippet to transfer flow from one account to another using cadence, I will use it from go SDK. I have tried to use below code but not able to succeed
template := `
// Transfer Tokens
//import FungibleToken from ee82856bf20e2aa6
import FlowToken from 0ae53cb6e3f42a79
// This transaction is a template for a transaction that
// could be used by anyone to send tokens to another account
// that owns a Vault
transaction {
// Temporary Vault object that holds the balance that is being transferred
var temporaryVault: @FungibleToken.Vault
prepare(acct: AuthAccount) {
// withdraw tokens from your vault by borrowing a reference to it
// and calling the withdraw function with that reference
let vaultRef = acct.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault)
?? panic("Could not borrow a reference to the owner's vault")
self.temporaryVault <- vaultRef.withdraw(amount: 10.0)
}
execute {
// get the recipient's public account object
let recipient = getAccount(0x%s)
// get the recipient's Receiver reference to their Vault
// by borrowing the reference from the public capability
let receiverRef = recipient.getCapability(/public/flowTokenReceiver)
.borrow<&FlowToken.Vault{FlowToken.Receiver}>()
?? panic("Could not borrow a reference to the receiver")
// deposit your tokens to their Vault
receiverRef.deposit(from: <-self.temporaryVault)
log("Transfer succeeded!")
}
}