Blockchain Events
Events being logged by GoodDAPP
Definition
Events are the Solidity abstraction on top of the EVM's logging functionality.
Events are inheritable members of contracts. When you call them, they cause the arguments to be stored in the transaction’s log - a special data structure in the blockchain. These logs are associated with the address of the contract, are incorporated into the blockchain, and stay there as long as a block is accessible. The Log and its event data is not accessible from within contracts.
How we listen to events
GoodDAPP currently supports subscription to events through polling. Using GoodWallet
pollForEvents
method, we can listen for logs in an almost real time manner. pollForEvents
is periodically polling for events like the specified event (filters by the specified event) up to the current blockchain block, and perform callback on them.
Under the hood, pollForEvents
relies on another two methods (getEvents
and oneTimeEvents
).
How we parse them
pollForEvents
receive a callback which processes the list of events received from the filtered query.
At GoodWallet
, the method listenTxUpdates
initialize 2 main listeners:
For
Transfer
funds from the account.For
Transfer
funds to the account.
In both cases, events are polled from the latest block that was not polled before (starting from the block the user was created and advancing). Once these events were filtered (found) by the client:
Their receipts + Logs are being loaded from the Blockchain. The receipts + Logs object of each event are sent to the event subscriber. Subscribers to "transferFrom" are subscribing to
receiptUpdated
flag, and to "transferTo" are subscribing toreceiptReceived
flag.Subscribers to "send" / "recieve" (accordingly) and
balanceChanged
flags are invoked also.
How they effect the UI
Account balance is updated after a Transfer
(from or to) event is processed. As well, entitlement (amount to be claimed) is re-queried and updated accordingly.
All the funds movement between accounts, to/from the current account are listed in the Dashboard's feed list.
Contracts
Contracts being used by GoodDAPP logs different information in the form of events.
The list of contracts that GoodDAPP is aware of:
Events by Contract
GoodDollar
PopulatedMarket()
when: During deployment/migration process, in the G$s minting phase. It's a one-time event.
where: Emitted when the
GoodDollar.initialMove()
method is called and successfully executed.
Transfer(address indexed from, address indexed to, uint value)
when: Every time a user Sends (Transfers) G$s to an account.
where: In Send flow, user is able to transfer directly to an account by calling
GoodDollar.transfer()
specifying destination address, email, mobile or username.
Transfer(address indexed from, address indexed to, uint value, bytes data)
when: Every time a user generates a link to share G$s in Send screen.
where: In Send flow, user is able to generate a link to later be withdrawn by calling
GoodDollar.transferAndCall()
.
TransactionFees(uint256 fee, uint256 burned)
when: Every time a Transfer is done.
where: In Send flow, user is able to send G$s to another wallet by specifying its address, email, mobile or username, or by generating a link to later be withdrawn by calling
GoodDollar.transfer()
,GoodDollar.transferAndCall()
.
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
when: During deployment/migration process.
where: At contract deployment step, previous owner is set to
0x0
. And at the end of the migration process, ownership is transferred to theGoodDollarReserve
contract.
MinterAdded(address indexed account)
when: During deployment/migration process.
where: At contract deployment, account used to deploy contract is being assigned. During migration
GoodDollarReserve
contract is also added.
MinterRemoved(address indexed account)
when: During migration process.
where: During migration, after adding
GoodDollarReserve
, the deployer account is being removed. **
Approval(address indexed owner, address indexed spender, uint256 value)
when: Not being used.
where: Not being used.
ContractFallbackCallFailed(address from, address to, uint256 value)
when: When a transfer of G$s is being made to a contract that don't have
onTokenTransfer
method.where: In the ÐApp, when sending directly to an address.
GoodDollarReserve
SignerAdded(address indexed account)
when: During deployment process.
where: At deployment step, when class constructor is called.
SignerRemoved(address indexed account)
when: Not being used.
where: Not being used.
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
when: During deployment/migration process.
where: At contract deployment step, previous owner is set to
0x0
. And at the end of the migration process, ownership is transferred toRedemptionFunctional
contract.
Identity
WhitelistedAdded(address indexed account)
when: During migration process. And every time a new user is validated in GoodDAPP.
where: During migration
GoodDollar
,GoodDollarReserve
andOneTimePaymentLinks
are added to the list. During application lifetime, when a user has been validated (email, mobile and Face Recognition).
WhitelistedRemoved(address indexed account)
when: Not being used.
where: Not being used.
WhitelistAdminAdded(address indexed account)
when: During deployment/migration process.
where: At deployment step, when class constructor is called, sets account used to deploy the contract.
WhitelistAdminRemoved(address indexed account)
when: Not being used.
where: Not being used.
OneTimePaymentLinks
PaymentDeposit(address indexed from, bytes32 hash, uint256 amount)
when: When a deposit is being made from the ÐApp.
where: In Send flow, if user generates a link to share G$s, the amount specified will generate a deposit to the contract.
PaymentWithdraw(address indexed from, address indexed to, bytes32 indexed hash, uint256 amount)
when: When a withdraw is being made from the ÐApp.
where: Accessing the withdraw link being generated by Send -> Generate Link. Or by scanning, in the Receive flow, the QR code generated from the Sender
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
when: During deployment process.
where: At deployment, ownership is transferred to the deployer account.
PaymentCancel(address indexed from, bytes32 hash, uint256 amount)
when: When a user that generates the deposit decides to cancel it.
where: Not being used.
RedemptionFunctional
UBIClaimed(address indexed by, uint256 total)
when: When user claims its G$s.
where: In the ÐApp, when user has G$s to claim, it can go to the Claim flow and receive the G$s after making a Face Recognition validation.
OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
when: During deployment process.
where: At deployment, ownership is transferred to the deployer account.
Last updated