fisherBridgeSend
Function Type: external
Function Signature: fisherBridgeSend(address,address,address,uint256,uint256,bytes)
Access Control: onlyFisherExecutor
Returns: void
Facilitates cross-chain withdrawals through the fisher bridge system by validating user signatures and emitting events for external chain processing. This function enables gasless withdrawals where authorized fisher executors can initiate transfers on behalf of users.
Parameters
Parameter | Type | Description |
---|---|---|
from | address | User initiating the withdrawal from EVVM |
addressToReceive | address | Recipient address on the external chain |
tokenAddress | address | Token contract address or address(0) for native coin |
priorityFee | uint256 | Fee amount paid to the fisher executor |
amount | uint256 | Amount to withdraw from user's EVVM balance |
signature | bytes | Cryptographic signature (EIP-191) from the from address authorizing this withdrawal. |
Access Control
modifier onlyFisherExecutor() {
if (msg.sender != fisherExecutor.current) {
revert();
}
_;
}
Only addresses with the current fisherExecutor
role can call this function.
Workflow
1. Principal Token Validation
if (tokenAddress == Evvm(evvmAddress).getEvvmMetadata().principalTokenAddress)
revert ErrorsLib.PrincipalTokenIsNotWithdrawable();
Prevents withdrawal of the ecosystem's principal token to maintain system integrity.
2. Balance Verification
if (Evvm(evvmAddress).getBalance(from, tokenAddress) < amount)
revert ErrorsLib.InsufficientBalance();
Ensures the user has sufficient EVVM balance before processing the withdrawal.
3. Signature Verification
if (!SignatureUtils.verifyMessageSignedForFisherBridge(
from,
addressToReceive,
nextFisherExecutionNonce[from],
tokenAddress,
priorityFee,
amount,
signature
)) revert ErrorsLib.InvalidSignature();
For more information about the signature structure, refer to the Fisher Bridge Signature Structure.
4. Nonce Management
nextFisherExecutionNonce[from]++;
Increments the user's execution nonce to prevent replay attacks.
5. Balance Updates
User Balance Debit
executerEVVM(false, from, tokenAddress, amount + priorityFee);
Removes the total amount (withdrawal + priority fee) from the user's EVVM balance.
Fisher Fee Credit
if (priorityFee > 0)
executerEVVM(true, msg.sender, tokenAddress, priorityFee);
Credits the priority fee to the fisher executor's EVVM balance if specified.
6. Event Emission
emit FisherBridgeSend(
from,
addressToReceive,
tokenAddress,
priorityFee,
amount,
nextFisherExecutionNonce[from] - 1
);
Emits an event containing all transfer details for external chain monitoring and processing.
Event Definition
event FisherBridgeSend(
address indexed from,
address indexed addressToReceive,
address indexed tokenAddress,
uint256 priorityFee,
uint256 amount,
uint256 nonce
);
Event Parameters
from
: User who initiated the withdrawal (indexed)addressToReceive
: Recipient on external chain (indexed)tokenAddress
: Token being withdrawn (indexed)priorityFee
: Fee paid to fisher executoramount
: Withdrawal amountnonce
: Execution nonce used for this transaction
External Chain Processing
The emitted event serves as a signal for external chain operations. The corresponding external chain station or fisher services should:
- Monitor for
FisherBridgeSend
events - Extract transfer details from event parameters
- Execute the actual token transfer on the external chain
- Transfer
amount
oftokenAddress
toaddressToReceive
Security Features
Signature Security
- EIP-191 Compliance: Standard Ethereum signed message format
- Nonce Protection: Prevents signature replay attacks
- User Authorization: Cryptographic proof of user consent
Balance Protection
- Principal Token Guard: Prevents withdrawal of ecosystem's core token
- Sufficient Balance Check: Validates user has adequate funds
- Atomic Operations: Balance updates are processed atomically
Access Control
- Fisher Authorization: Only current fisher executor can initiate withdrawals
- Signature Validation: Requires valid user signature for each transaction (see signature format)
Fee Structure
The priority fee mechanism incentivizes fisher executors:
- User Pays: Total debit of
amount + priorityFee
from user balance - Fisher Receives: Priority fee credited to executor's EVVM balance
- Net Transfer: User receives
amount
on external chain
Error Conditions
Error | Condition |
---|---|
PrincipalTokenIsNotWithdrawable | Attempting to withdraw principal token |
InsufficientBalance | User lacks sufficient EVVM balance |
InvalidSignature | Signature verification fails |
Access Control Revert | Called by unauthorized address |
Usage Flow
- User Intent: User wants to withdraw tokens from EVVM to external chain
- Signature Creation: User signs withdrawal authorization message
- Fisher Execution: Authorized fisher calls
fisherBridgeSend
with signature - Validation: Function validates signature and user balance
- Balance Update: EVVM balances updated (user debited, fisher credited fee)
- Event Emission: Event emitted for external chain processing
- External Transfer: External services process the actual token transfer
This function only updates EVVM balances and emits events. The actual token transfer on the external chain must be handled by off-chain services monitoring these events.