Skip to content

Commit

Permalink
update transaction comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sisyphusSmiling committed Nov 5, 2024
1 parent 71206e8 commit e008205
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
18 changes: 16 additions & 2 deletions cadence/transactions/bundled/wrap_and_mint.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@ import "FungibleToken"
import "FlowToken"
import "EVM"

/// This transaction wraps FLOW as WFLOW, approves an ERC721 contract to move the mint amount, and attempts to mint an
/// ERC721 token. The transaction is reverted if any of the EVM interactions fail
/// This transaction demonstrates how multiple EVM calls can be batched in a single Cadence transaction via
/// CadenceOwnedAccount (COA), performing the following actions:
///
/// 1. Configures a COA in the signer's account if needed
/// 2. Funds the signer's COA with the cost of minting an ERC721 token
/// 3. Wraps FLOW as WFLOW - EVM call 1
/// 4. Approves an example ERC721 contract accepting WFLOW to move the mint amount - EVM call 2
/// 5. Attempts to mint an ERC721 token - EVM call 3
///
/// Importantly, the transaction is reverted if any of the EVM interactions fail returning the account to the original
/// state before the transaction was executed across Cadence & EVM.
///
/// For more context, see https://github.com/onflow/batched-evm-exec-example
///
/// @param wflowAddressHex: The EVM address hex of the WFLOW contract as a String
/// @param maybeMintERC721AddressHex: The EVM address hex of the ERC721 contract as a String
///
transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {

Expand Down
5 changes: 4 additions & 1 deletion cadence/transactions/stepwise/0_create_coa.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import "FungibleToken"
import "FlowToken"
import "EVM"

/// Creates a CadenceOwnedAccount & funds with the specified amount. If the COA already exists, the transaction reverts.
/// Creates a CadenceOwnedAccount (COA) & funds with the specified amount.
/// If a COA already exists in storage at /storage/evm, the transaction reverts.
///
/// @param amount: The amount of FLOW to fund the COA with, sourcing funds from the signer's FlowToken Vault
///
transaction(amount: UFix64) {

Expand Down
11 changes: 10 additions & 1 deletion cadence/transactions/stepwise/1_wrap_flow.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import "FungibleToken"
import "FlowToken"
import "EVM"

/// This transaction wraps FLOW as WFLOW, funing the signer's CadenceOwnedAccount with the mint cost
/// This transaction wraps FLOW as WFLOW, sourcing the wrapped FLOW from the signer's FlowToken Vault in the amount of
/// 1.0 FLOW to cover the mint cost of 1 MaybeMintERC721 token. If a CadenceOwnedAccount (COA) is not configured in the
/// signer's account, one is configured, allowing the Flow account to interact with Flow's EVM runtime.
///
/// While not interesting on its own, this transaction demonstrates a single step in the bundled EVM execution example,
/// showcasing how Cadence can be used to atomically orchestrate multiple EVM interactions in a single transaction.
///
/// For more context, see https://github.com/onflow/batched-evm-exec-example
///
/// @param wflowAddressHex: The EVM address hex of the WFLOW contract as a String
///
transaction(wflowAddressHex: String) {

Expand Down
10 changes: 8 additions & 2 deletions cadence/transactions/stepwise/2_approve.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ import "FungibleToken"
import "FlowToken"
import "EVM"

/// This transaction wraps FLOW as WFLOW, approves an ERC721 contract to move the mint amount, and attempts to mint an
/// ERC721 token. The transaction is reverted if any of the EVM interactions fail
/// This transaction approves the provided ERC721 address to move the mint amount on the WFLOW contract. In this example
/// the mint amount is 1.0 WFLOW. While not included in the code below, this transaction is part of a larger example
/// showcasing how Cadence can be used to atomically orchestrate multiple EVM interactions in a single transaction.
///
/// For more context, see https://github.com/onflow/batched-evm-exec-example
///
/// @param wflowAddressHex: The EVM address hex of the WFLOW contract as a String
/// @param maybeMintERC721AddressHex: The EVM address hex of the ERC721 contract as a String
///
transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {

Expand Down
11 changes: 10 additions & 1 deletion cadence/transactions/stepwise/3_mint.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@ import "FungibleToken"
import "FlowToken"
import "EVM"

/// This transaction attempts to mint the ERC721 token, reverting if the mint fails
/// This transaction attempts to mint the ERC721 token, reverting if the mint fails. The intended example is part of a
/// larger example showcasing how Cadence can be used to atomically orchestrate multiple EVM interactions in a single
/// transaction. In this case, the MaybeMintERC721 contract mints an ERC721 token in exchange for WFLOW with a 50%
/// probability of success. If the mint fails, the transaction can be reverted, ensuring the account is returned to the
/// original state before the transaction was executed across Cadence & EVM.
///
/// For more context, see https://github.com/onflow/batched-evm-exec-example
///
/// @param wflowAddressHex: The EVM address hex of the WFLOW contract as a String
/// @param maybeMintERC721AddressHex: The EVM address hex of the ERC721 contract as a String
///
transaction(wflowAddressHex: String, maybeMintERC721AddressHex: String) {

Expand Down

0 comments on commit e008205

Please sign in to comment.