const Web3 = require('web3');

  // Generate event signature using keccak256 hash algorithm
function encodeEvent(event) {
  const keccakHash = Web3.utils.keccak256(event);
  return keccakHash;
}

  // Generate 32-bytes size specification
function encodeTopic(parameter) {
  const encodedParameter = Web3.utils.padLeft(parameter, 64); // 64 characters = 32 bytes encoding
  return encodedParameter;
}

function main() {

  // Define the event to encode
  const eventToEncode = 'Transfer(address,address,uint256)';
  const signature = encodeEvent(eventToEncode);

  // Define the topic to encode, an Ethereum address in this case
  const topicToEncode = '0xf5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0';
  const topic = encodeTopic(topicToEncode);

  // Topics array to use in eth_getLogs in the 'topics' field of the filter
  const topics = [signature, topic];

  console.log('===== Topics Encoder =====');
  console.log(`Event to track: ${eventToEncode}`);
  console.log(`Event signature: ${signature}`);
  console.log(`Encoded topic: ${topic}\n`);
  console.log('This array filters ERC-20 Transfer events originating from a specific Ethereum address:');
  console.log(topics);
}

main();
$ node web3

===== Topics Encoder =====
Event to track: Transfer(address,address,uint256)
Event signature: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Encoded topic: 0x000000000000000000000000f5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0

This array filters ERC-20 Transfer events originating from a specific Ethereum address:
[
  '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
  '0x000000000000000000000000f5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0'
]
const Web3 = require('web3');

  // Generate event signature using keccak256 hash algorithm
function encodeEvent(event) {
  const keccakHash = Web3.utils.keccak256(event);
  return keccakHash;
}

  // Generate 32-bytes size specification
function encodeTopic(parameter) {
  const encodedParameter = Web3.utils.padLeft(parameter, 64); // 64 characters = 32 bytes encoding
  return encodedParameter;
}

function main() {

  // Define the event to encode
  const eventToEncode = 'Transfer(address,address,uint256)';
  const signature = encodeEvent(eventToEncode);

  // Define the topic to encode, an Ethereum address in this case
  const topicToEncode = '0xf5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0';
  const topic = encodeTopic(topicToEncode);

  // Topics array to use in eth_getLogs in the 'topics' field of the filter
  const topics = [signature, topic];

  console.log('===== Topics Encoder =====');
  console.log(`Event to track: ${eventToEncode}`);
  console.log(`Event signature: ${signature}`);
  console.log(`Encoded topic: ${topic}\n`);
  console.log('This array filters ERC-20 Transfer events originating from a specific Ethereum address:');
  console.log(topics);
}

main();
$ node web3

===== Topics Encoder =====
Event to track: Transfer(address,address,uint256)
Event signature: 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Encoded topic: 0x000000000000000000000000f5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0

This array filters ERC-20 Transfer events originating from a specific Ethereum address:
[
  '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
  '0x000000000000000000000000f5d500B70bfca5987A05Fb4EfcCbfa5E660a81c0'
]