Hi, I am trying to extend FungibleToken transaction to try to load vaults from each account and creates if it does not exist.
transaction {
prepare(first: AuthAccount, second:AuthAccount, third:AuthAccount, forth: AuthAccount) {
// Create a link to the Vault in storage that is restricted to the
// fields and functions in `Receiver` and `Balance` interfaces,
// this only exposes the balance field
// and deposit function of the underlying vault.
//
log("Empty Vault stored")
var array = [first, second, third, forth]
var a = 0
while a < array.length {
var element = array[a]
var vault <- element.load<@FungibleToken.Vault>(from: /storage/MainVault)
if vault {
log("The vault already exists")
} else {
vault <- FungibleToken.createEmptyVault()
element.save<@FungibleToken.Vault>(<-vault, to: /storage/MainVault)
element.link<&FungibleToken.Vault{FungibleToken.Receiver, FungibleToken.Balance}>(/public/MainReceiver, target: /storage/MainVault)
}
a = a + 1
}
log("Public Receiver reference created!")
}
However, I am getting the error in the title at var vault <- element.load<@FungibleToken.Vault>(from: /storage/MainVault)