fix(docs): Fix event type definitions to use H160 for ink! v6 compatibility #537
Merged
Daanvdplas merged 3 commits intouse-ink:masterfrom Nov 27, 2025
Merged
fix(docs): Fix event type definitions to use H160 for ink! v6 compatibility #537Daanvdplas merged 3 commits intouse-ink:masterfrom
Daanvdplas merged 3 commits intouse-ink:masterfrom
Conversation
…bility
## Summary
Corrects the Events documentation to use `H160` type for account addresses, resolving type mismatch errors when developers follow the examples in ink! v6.
## Problem
The current documentation shows event definitions using `AccountId`:
```rust
#[ink(event)]
pub struct Transferred {
from: Option<AccountId>, // Causes compilation error
to: Option<AccountId>,
value: Balance,
}
```
When developers follow this example with ink! v6, they encounter a type mismatch error:
```
error[E0308]: mismatched types
expected `AccountId`, found `H160`
```
This occurs because `Self::env().caller()` returns `H160` in ink! v6's default environment (pallet-revive), not `AccountId`.
## Changes Made
### Event Type Definitions
- Changed `Option<AccountId>` to `Option<H160>` in all event examples
- Updated signature topic example from `blake2b("Transferred(Option<AccountId>,Option<AccountId>,u128)")` to `blake2b("Transferred(Option<H160>,Option<H160>,u128)")`
- Ensured consistency across all code snippets in the Events documentation
### Files Modified
- `docs/basics/events.md`
## Why H160 in ink! v6?
ink! v6 migrated from `pallet-contracts` to `pallet-revive`, which prioritizes Ethereum/Solidity compatibility:
- **pallet-revive uses H160** (20-byte addresses) instead of traditional 32-byte AccountId for Ethereum compatibility
- **`Address` is a type alias for `H160`** in ink_primitives (both are interchangeable)
- **Enables compatibility** with Ethereum tooling like MetaMask, Hardhat, and Solidity contracts
- **`Self::env().caller()`** now returns `H160` by default
## Verification
**Matches official example**: The [official ERC20 example](https://github.com/use-ink/ink-examples/blob/main/erc20/lib.rs) uses `Address` (alias for `H160`)
**Compiles successfully**: Code examples now compile without type mismatch errors in ink! v6
**Consistent with pallet-revive**: Aligns with [pallet-revive's H160 address type](https://docs.rs/pallet-revive/latest/pallet_revive/struct.H160.html)
## References
- [pallet-revive documentation](https://docs.rs/pallet-revive/latest/pallet_revive/)
- [Official ERC20 example using Address which is a type alias for H160](https://github.com/use-ink/ink-examples/blob/main/erc20/lib.rs)
## Testing
- [x] Tested code examples locally with ink! v6
- [x] Verified examples compile without errors
- [x] Cross-referenced with official ink-examples like the ERC20 example in the repository
Daanvdplas
reviewed
Nov 27, 2025
Contributor
Daanvdplas
left a comment
There was a problem hiding this comment.
Thanks a lot Lynette!
Could you search for the word AccountId in this file and update the ones that should be too?
Contributor
Author
|
Wait it's Cecilia 😂. |
Contributor
|
Shit this is Cecilia! Thanks a lot Cecilia, I was not paying attention 😅 |
Contributor
Author
|
@Daanvdplas which file? |
Contributor
|
The file you made changes in |
Updated event definition documentation to use H160 instead of AccountId and clarified topic value encoding for H160.
Contributor
Author
|
Done! @Daanvdplas |
Daanvdplas
reviewed
Nov 27, 2025
Contributor
Daanvdplas
left a comment
There was a problem hiding this comment.
Apologies @CECILIA-MULANDI, looking at some of the recent examples it is Address that we want to use in stead of H160. Can you use that in stead?
Daanvdplas
reviewed
Nov 27, 2025
docs/basics/events.md
Outdated
|
|
||
| ```rust | ||
| use ink::primitives::AccountId; | ||
| use ink::primitives::H160; |
Contributor
Author
There was a problem hiding this comment.
I've made the changes
Daanvdplas
approved these changes
Nov 27, 2025
Contributor
|
Thank you ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Corrects the Events documentation to use
H160type for account addresses, resolving type mismatch errors when developers follow the examples in ink! v6.Problem
The current documentation shows event definitions using
AccountId:When developers follow this example with ink! v6, they encounter a type mismatch error:
This occurs because
Self::env().caller()returnsH160in ink! v6's default environment (pallet-revive), notAccountId.Changes Made
Event Type Definitions
Option<AccountId>toOption<H160>in all event examplesblake2b("Transferred(Option<AccountId>,Option<AccountId>,u128)")toblake2b("Transferred(Option<H160>,Option<H160>,u128)")Files Modified
docs/basics/events.mdWhy H160 in ink! v6?
ink! v6 migrated from
pallet-contractstopallet-revive, which prioritizes Ethereum/Solidity compatibility:Addressis a type alias forH160in ink_primitives (both are interchangeable)Self::env().caller()now returnsH160by defaultVerification
Matches official example: The official ERC20 example uses
Address(alias forH160)Compiles successfully: Code examples now compile without type mismatch errors in ink! v6
Consistent with pallet-revive: Aligns with pallet-revive's H160 address type
References
Testing