Skip to content

Interacting With COAs #683

Closed
Closed
@gregsantos

Description

@gregsantos

COAs expose two interfaces for interaction, one on the Flow EVM side and one on the Cadence resource side

COA’s Cadence resource interface

address(): EVMAddress returns the address of the smart contract, and the EVM address that is returned could be used to query balance, code, nonce, etc.

deposit(from: @FlowToken.Vault) allows depositing FLOW tokens into the smart contract (Cadence to Flow EVM). On the EVM side, the money for the deposits are always transfering from 0x0000000000000000000000010000000000000000 (native token bridge address). The balance of that address is adjusted before transfer.

withdraw(balance: Balance): @FlowToken.Vault allows withdrawing balance from the Flow EVM address and bridges it back as a FlowToken Vault to be handled on the Cadence side. On the EVM side, the money for the withdraw are always transfered to 0x0000000000000000000000010000000000000000 (native token bridge address) and then the balance of that address is adjusted.

deploy(code: [UInt8], gasLimit: UInt64, value: Balance): EVMAddress lets the COA smart contract deploy smart contracts, and the returned address is the address of the new smart contract. The value (balance) is taken from the COA smart contract and moved to the new smart contract address (if they accept it).

call(to: EVMAddress, data: [UInt8], gasLimit: UInt64, value: Balance): [UInt8] makes a call on behalf of the COA smart contract and the result of the call (the returned value) could be processed by the cadence side. The value (balance) is taken from the COA smart contract. Calling this method emits direct call transaction events.

Add get address example

Scripts, transactions and a test example on how to interact with Solidty contracts through Flow EVM

COA’s EVM smart contract interface

Description and link to EVM doc "Interacting With Cadence Via Cadence Owned Account"

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions