Skip to content

Instantly share code, notes, and snippets.

@justinbarry
Last active July 26, 2022 03:50
Show Gist options
  • Save justinbarry/f6a0be0737bf80624de7d54c239597ed to your computer and use it in GitHub Desktop.
Save justinbarry/f6a0be0737bf80624de7d54c239597ed to your computer and use it in GitHub Desktop.
curl -X POST -H "Content-Type: application/json" -d '{"code": "import FungibleToken from 0xf233dcee88fe0abe\nimport FiatToken from 0xb19436aae4d94622\n\ntransaction {\n prepare(signer: AuthAccount) {\n // Return early if the account already stores a FiatToken Vault\n if signer.borrow<&FiatToken.Vault>(from: FiatToken.VaultStoragePath) != nil {\n return\n }\n // Create a new ExampleToken Vault and put it in storage\n signer.save(\n <-FiatToken.createEmptyVault(),\n to: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the deposit function through the Receiver interface\n signer.link<&FiatToken.Vault{FungibleToken.Receiver}>(\n FiatToken.VaultReceiverPubPath,\n target: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the UUID() function through the VaultUUID interface\n signer.link<&FiatToken.Vault{FiatToken.ResourceId}>(\n FiatToken.VaultUUIDPubPath,\n target: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the balance field through the Balance interface\n signer.link<&FiatToken.Vault{FungibleToken.Balance}>(\n FiatToken.VaultBalancePubPath,\n target: FiatToken.VaultStoragePath\n )\n }\n}", "arguments": []}
' https://YOUR_WALLET_API/v1/accounts/THE_ACCOUNT_TO_SETUP/transactions
{
"code": "import FungibleToken from 0xf233dcee88fe0abe\nimport FiatToken from 0xb19436aae4d94622\n\ntransaction {\n prepare(signer: AuthAccount) {\n // Return early if the account already stores a FiatToken Vault\n if signer.borrow<&FiatToken.Vault>(from: FiatToken.VaultStoragePath) != nil {\n return\n }\n // Create a new ExampleToken Vault and put it in storage\n signer.save(\n <-FiatToken.createEmptyVault(),\n to: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the deposit function through the Receiver interface\n signer.link<&FiatToken.Vault{FungibleToken.Receiver}>(\n FiatToken.VaultReceiverPubPath,\n target: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the UUID() function through the VaultUUID interface\n signer.link<&FiatToken.Vault{FiatToken.ResourceId}>(\n FiatToken.VaultUUIDPubPath,\n target: FiatToken.VaultStoragePath\n )\n // Create a public capability to the Vault that only exposes\n // the balance field through the Balance interface\n signer.link<&FiatToken.Vault{FungibleToken.Balance}>(\n FiatToken.VaultBalancePubPath,\n target: FiatToken.VaultStoragePath\n )\n }\n}",
"arguments": []
}
import FungibleToken from 0xf233dcee88fe0abe
import FiatToken from 0xb19436aae4d94622
transaction {
prepare(signer: AuthAccount) {
// Return early if the account already stores a FiatToken Vault
if signer.borrow<&FiatToken.Vault>(from: FiatToken.VaultStoragePath) != nil {
return
}
// Create a new ExampleToken Vault and put it in storage
signer.save(
<-FiatToken.createEmptyVault(),
to: FiatToken.VaultStoragePath
)
// Create a public capability to the Vault that only exposes
// the deposit function through the Receiver interface
signer.link<&FiatToken.Vault{FungibleToken.Receiver}>(
FiatToken.VaultReceiverPubPath,
target: FiatToken.VaultStoragePath
)
// Create a public capability to the Vault that only exposes
// the UUID() function through the VaultUUID interface
signer.link<&FiatToken.Vault{FiatToken.ResourceId}>(
FiatToken.VaultUUIDPubPath,
target: FiatToken.VaultStoragePath
)
// Create a public capability to the Vault that only exposes
// the balance field through the Balance interface
signer.link<&FiatToken.Vault{FungibleToken.Balance}>(
FiatToken.VaultBalancePubPath,
target: FiatToken.VaultStoragePath
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment