Skip to content

docs: add FROM address monitoring examples #4974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs.wrm/getting-started.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,22 @@ _code: listen for ERC-20 events @lang<script>
// `to` will always be equal to the address of "ethers.eth"
});

// Listen for any Transfer from a specific address
fromAddress = "0x123..."; // Replace with actual address
filter = contract.filters.Transfer(fromAddress, null)
contract.on(filter, (from, to, amount, event) => {
// `from` will always be equal to fromAddress
console.log(`Transfer from ${from} to ${to}: ${formatEther(amount)}`);
});

// Listen for any Transfer from a specific address to a specific address
toAddress = "0x456..."; // Replace with actual address
filter = contract.filters.Transfer(fromAddress, toAddress)
contract.on(filter, (from, to, amount, event) => {
// Both `from` and `to` will be fixed
console.log(`Transfer from ${from} to ${to}: ${formatEther(amount)}`);
});

// Listen for any event, whether it is present in the ABI
// or not. Since unknown events can be picked up, the
// parameters are not destructed.
Expand Down Expand Up @@ -470,6 +486,25 @@ _code: query historic ERC-20 events @lang<javascript>
events[0]
//_result:

// Query all transfers sent from a specific address
fromAddress = "0x123..."; // Replace with actual address
filter = contract.filters.Transfer(fromAddress, null)
events = await contract.queryFilter(filter)

// The first matching event
events[0]
//_result:

// Query all transfers sent from a specific address in the last 1000 blocks
events = await contract.queryFilter(filter, -1000)
//_result:

// Query all transfers sent from a specific address to a specific address
toAddress = "0x456..."; // Replace with actual address
filter = contract.filters.Transfer(fromAddress, toAddress)
events = await contract.queryFilter(filter)
//_result:


_subsection: Signing Messages @<starting-signing>

Expand Down