templates

package
v0.31.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2023 License: Apache-2.0 Imports: 10 Imported by: 52

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountKeyToCadenceCryptoKey added in v0.25.0

func AccountKeyToCadenceCryptoKey(key *flow.AccountKey) (cadence.Value, error)

AccountKeyToCadenceCryptoKey converts a `flow.AccountKey` key to the Cadence struct `Crypto.KeyListEntry`, so that it can more easily be used as a parameter in scripts and transactions.

example: ```go

key := AccountKeyToCadenceCryptoKey(accountKey)

return flow.NewTransaction().
	SetScript([]byte(templates.AddAccountKey)).
	AddRawArgument(jsoncdc.MustEncode(key))

```

func AddAccountContract added in v0.12.0

func AddAccountContract(address flow.Address, contract Contract) *flow.Transaction

AddAccountContract generates a transaction that deploys a contract to an account.

func AddAccountKey

func AddAccountKey(address flow.Address, accountKey *flow.AccountKey) (*flow.Transaction, error)

AddAccountKey generates a transaction that adds a public key to an account.

func CreateAccount

func CreateAccount(accountKeys []*flow.AccountKey, contracts []Contract, payer flow.Address) (*flow.Transaction, error)

CreateAccount generates a transactions that creates a new account.

This template accepts a list of public keys and a contracts argument, both of which are optional.

The contracts argument is a dictionary of *contract name*: *contract code (in bytes)*. All of the contracts will be deployed to the account.

The final argument is the address of the account that will pay the account creation fee. This account is added as a transaction authorizer and therefore must sign the resulting transaction.

func RemoveAccountContract added in v0.15.0

func RemoveAccountContract(address flow.Address, contractName string) *flow.Transaction

RemoveAccountContract generates a transaction that removes a contract with the given name

func RemoveAccountKey

func RemoveAccountKey(address flow.Address, keyIndex int) *flow.Transaction

RemoveAccountKey generates a transaction that removes a key from an account.

func UpdateAccountContract added in v0.12.0

func UpdateAccountContract(address flow.Address, contract Contract) *flow.Transaction

UpdateAccountContract generates a transaction that updates a contract deployed at an account.

Types

type Contract added in v0.12.0

type Contract struct {
	Name   string
	Source string
}

Contract is a Cadence contract deployed to a Flow account.

Name is the identifier for the contract within the account.

Source is the the Cadence code of the contract.

func (Contract) SourceBytes added in v0.12.0

func (c Contract) SourceBytes() []byte

SourceBytes returns the UTF-8 encoded source code (Source) of the contract.

func (Contract) SourceHex added in v0.12.2

func (c Contract) SourceHex() string

SourceHex returns the UTF-8 encoded source code (Source) of the contract as a hex string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL