@@ -83,13 +83,14 @@ type ethService struct {
8383}
8484
8585const (
86- decimalStringBase = 10
87- defaultGasPriceWeiInt64 = int64 (1_000_000_000 )
88- defaultGasPriceWeiUint64 = uint64 (1_000_000_000 )
8986 functionSelectorSize = 4
90- topicSizeBytes = 32
9187 confirmationBufferBlocks = uint64 (12 )
9288 syntheticBlockTimeSeconds = uint64 (12 )
89+ // DefaultGasLimit is the cosmetic gas limit the facade reports (eth_estimateGas,
90+ // block gasLimit, tx gas, synthetic block gasUsed). The facade executes
91+ // transfers on Canton rather than an EVM, so gas is never metered — and the
92+ // gas price is fixed at 0 — making this value purely informational for wallets.
93+ DefaultGasLimit = 21_000
9394)
9495
9596// NewService creates a new ethService.
@@ -140,21 +141,24 @@ func (s *ethService) BlockNumber(ctx context.Context) (hexutil.Uint64, error) {
140141 return hexutil .Uint64 (max (baseBlock , timeBasedBlocks )), nil
141142}
142143
143- func (s * ethService ) GasPrice (_ context.Context ) (* hexutil.Big , error ) {
144- gasPrice := new (big.Int )
145- if _ , ok := gasPrice .SetString (s .cfg .GasPriceWei , decimalStringBase ); ! ok {
146- return nil , apperr .GeneralError (fmt .Errorf ("invalid gas price wei: %q" , s .cfg .GasPriceWei ))
147- }
148-
149- return (* hexutil .Big )(gasPrice ), nil
144+ // GasPrice always reports 0, and so do maxPriorityFeePerGas, block
145+ // baseFeePerGas, and receipt effectiveGasPrice. The facade never charges gas,
146+ // and MetaMask's client-side pre-flight check is
147+ // `balance >= value + gasLimit*gasPrice`. Since eth_getBalance reports a zero
148+ // native balance and this facade only accepts zero-value ERC-20 transfers, the
149+ // check collapses to `0 >= 0` only while gas is 0 — any non-zero gas price would
150+ // make MetaMask reject transfers with "insufficient funds for gas". Gas is
151+ // therefore fixed at 0 in code rather than exposed as config.
152+ func (* ethService ) GasPrice (_ context.Context ) (* hexutil.Big , error ) {
153+ return (* hexutil .Big )(big .NewInt (0 )), nil
150154}
151155
152156func (* ethService ) MaxPriorityFeePerGas (_ context.Context ) (* hexutil.Big , error ) {
153- return (* hexutil .Big )(big .NewInt (defaultGasPriceWeiInt64 )), nil
157+ return (* hexutil .Big )(big .NewInt (0 )), nil
154158}
155159
156- func (s * ethService ) EstimateGas (_ context.Context , _ * ethrpc.CallArgs ) (hexutil.Uint64 , error ) {
157- return hexutil .Uint64 (s . cfg . GasLimit ), nil
160+ func (* ethService ) EstimateGas (_ context.Context , _ * ethrpc.CallArgs ) (hexutil.Uint64 , error ) {
161+ return hexutil .Uint64 (DefaultGasLimit ), nil
158162}
159163
160164func (s * ethService ) GetBalance (ctx context.Context , address common.Address ) (* hexutil.Big , error ) {
@@ -328,7 +332,7 @@ func (s *ethService) GetTransactionReceipt(ctx context.Context, hash common.Hash
328332 Logs : logs ,
329333 LogsBloom : bloom ,
330334 Status : hexutil .Uint64 (row .Status ),
331- EffectiveGasPrice : hexutil .Uint64 (defaultGasPriceWeiUint64 ),
335+ EffectiveGasPrice : hexutil .Uint64 (0 ),
332336 Type : hexutil .Uint64 (2 ),
333337 // RevertReason is omitted when empty (omitempty), so successful
334338 // receipts keep the standard JSON shape.
@@ -350,7 +354,7 @@ func (s *ethService) GetTransactionByHash(ctx context.Context, hash common.Hash)
350354 blockHash := common .BytesToHash (row .BlockHash )
351355 blockNum := hexutil .Uint64 (row .BlockNumber )
352356 txIndex := hexutil .Uint (row .TxIndex )
353- gasPrice := big .NewInt (defaultGasPriceWeiInt64 )
357+ gasPrice := big .NewInt (0 )
354358
355359 return & ethrpc.RPCTransaction {
356360 Hash : hash ,
@@ -362,7 +366,7 @@ func (s *ethService) GetTransactionByHash(ctx context.Context, hash common.Hash)
362366 To : & to ,
363367 Value : (* hexutil .Big )(big .NewInt (0 )),
364368 GasPrice : (* hexutil .Big )(gasPrice ),
365- Gas : hexutil .Uint64 (s . cfg . GasLimit ),
369+ Gas : hexutil .Uint64 (DefaultGasLimit ),
366370 Input : row .Input ,
367371 Type : hexutil .Uint64 (2 ),
368372 ChainID : (* hexutil .Big )(new (big.Int ).Set (s .chainID )),
@@ -557,12 +561,12 @@ func (s *ethService) GetBlockByNumber(ctx context.Context, block ethrpc.BlockNum
557561 TotalDifficulty : (* hexutil .Big )(big .NewInt (0 )),
558562 ExtraData : []byte {},
559563 Size : hexutil .Uint64 (0 ),
560- GasLimit : hexutil .Uint64 (s . cfg . GasLimit ),
564+ GasLimit : hexutil .Uint64 (DefaultGasLimit ),
561565 GasUsed : hexutil .Uint64 (0 ),
562566 Timestamp : hexutil .Uint64 (blockNum * syntheticBlockTimeSeconds ),
563567 Transactions : []any {},
564568 Uncles : []common.Hash {},
565- BaseFeePerGas : (* hexutil .Big )(big .NewInt (defaultGasPriceWeiInt64 )),
569+ BaseFeePerGas : (* hexutil .Big )(big .NewInt (0 )),
566570 }, nil
567571}
568572
0 commit comments