Emit event by sender account but show account address 0x0
#345
-
Discord user IDspielcrypto Describe your question in detail.I have this struct event in my smart contract: #[event]
struct BurnCoinEvent has drop, store {
sender: address,
coin: String,
symbol: String,
} and after in this function I emit it: public entry fun coins<CoinType, BurnCoinType>(account: &signer, nfts_required_holding: vector<address>) acquires Config {
checkHolderOrPayFees<CoinType>(account, nfts_required_holding);
let account_address = signer::address_of(account);
aptos_account::transfer_coins<BurnCoinType>(account, @ghostly_addr, coin::balance<BurnCoinType>(account_address));
let burn_coin_event = BurnCoinEvent {
sender: account_address,
coin: coin::name<CoinType>(),
symbol: coin::symbol<CoinType>()
};
event::emit(burn_coin_event);
} when some account call the function coins the event is emitted but with account curl --request GET \ ✔ 6s
--url https://api.testnet.aptoslabs.com/v1/accounts/0x5cf7605e9a39a8a0610b831ef1bd0d4533b3c97bbf8b94d901437afe100980ce/events/0x9ed8aa766c59553a345523a1840e4727af9e16d6b9b98c0defdea2f639bc0e63::burn::BurnCoinEvent/amount \
--header 'Accept: application/json, application/x-bcs' I get What error, if any, are you getting?No response What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?Linux (Ubuntu, Fedora, Windows WSL, etc.) Which SDK or tool are you using? (if any)Indexer API Describe your environment or tooling in detailNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @dancespiele, Hope you're doing well. As far as I know, there are two types of events in Aptos:
"Account Address" and "Sequence Number" were part of legacy Event Handle Events, where each event had a unique GUID - "Event Handle" and a sequence number. Currently, only legacy Event Handle Events are supported in node APIs. New Module Events do not have a GUID, Account address, or sequence number. These are all set to zero due to backwards compatibility. To access module events, you can use Aptos's indexer GraphQL: Here's an example query for your event: query MyQuery {
events(
where: {transaction_version: {_eq: "5519062748"}, type: {_eq: "0x9ed8aa766c59553a345523a1840e4727af9e16d6b9b98c0defdea2f639bc0e63::burn::BurnCoinEvent"}}
) {
account_address
creation_number
event_index
indexed_type
transaction_block_height
transaction_version
type
sequence_number
data
}
} |
Beta Was this translation helpful? Give feedback.
ok if I write
indexed_type
instead oftype
works and I have what I want. Thanks!