Overview
TheMessageTransmitterV2 binding provides Go functions to interact with the MessageTransmitter smart contract, which handles receiving and processing cross-chain messages with attestations. This binding uses the abigen V2 pattern with bind.Call and bind.Transact for type-safe contract interactions.
Creating a Binding
NewMessageTransmitterV2
Creates a new MessageTransmitterV2 binding instance.*MessageTransmitterV2- A new binding instance
Instance() to create a bound contract instance.
Creating Contract Instances
Instance
Creates a wrapper for a deployed contract instance at the given address.Ethereum client connection
MessageTransmitter contract address
*bind.BoundContract- Contract instance for use withbind.Callandbind.Transact
Main Functions
PackReceiveMessage
Packs the parameters for thereceiveMessage function, which processes an attested message on the destination chain to complete a cross-chain transfer.
The CCTP message bytes returned from the attestation API
The attestation signature bytes from Circle’s attestation service
[]byte- Packed transaction data
TryPackReceiveMessage for error handling.
UnpackReceiveMessage
Unpacks the return value from areceiveMessage call.
The return data from the contract call
bool- Success statuserror- Error if unpacking fails
Complete Workflow
Burn tokens on source chain
Use TokenMessengerV2 to call
depositForBurn and get the transaction hash.Usage Example from SDK
Fromtransfer.go:429-434:
Message FormatThe message and attestation bytes must be obtained from Circle’s attestation API:
- Message: Contains the encoded burn transaction details
- Attestation: Circle’s signature validating the burn event
PackReceiveMessage.V2 Binding Pattern
The V2 binding pattern provides better separation of concerns:- Pack methods (
PackReceiveMessage) - Encode function calls into transaction data - Unpack methods (
UnpackReceiveMessage) - Decode return values from call results - bind.Call - Execute read-only contract calls
- bind.Transact - Send state-changing transactions
Benefits:
- Type Safety: Compile-time checking of parameters
- Flexibility: Can inspect/modify packed data before sending
- Error Handling: Separate packing errors from transaction errors
- Testing: Easier to mock and test contract interactions
Related Functions
TryPackReceiveMessage
Non-panicking version that returns an error instead of panicking.PackSendMessage
For sending outbound messages (less commonly used, asdepositForBurn handles this).
Error Handling
Common Errors
- “Message already received”: The message has been processed on the destination chain
- “Invalid attestation”: The attestation signature is invalid or expired
- “Attestation threshold not met”: Not enough attesters have signed (wait longer)
- “Invalid message format”: Message bytes are malformed
See Also
- TokenMessengerV2 - For burning tokens on source chain
- IERC20 - For checking balances after minting