Token Event

Methods in Common functions are also available.

Get Event Type

judger.getEventSource()

Returns type of the event.

Returns

Returns string of the event type, which could be "execution" or "token".

Example

judger.getEventSource()
> "execution"

Get Event Chain

judger.getChain()

Returns chain of the event.

Returns

Returns string of the chain name, which could be "eth" "bsc" "polygon" "goerli" or "bitkub".

Example

judger.getChain()
> "eth"

Get Ethereum Transaction

judger.getTransaction()

Return an Ethereum transaction of the event.

Returns

Returns object:

  • hash - string: Hash of the transaction.

  • nonce - number: The number of transactions made by the sender prior to this one.

  • blockHash - string: Hash of the block where this transaction was in. null if pending.

  • blockNumber - number: Block number where this transaction was in. null if pending.

  • transactionIndex - number: Integer of the transactions index position in the block. null if pending.

  • from - string: Address of the sender.

  • to - string: Address of the receiver. null if it’s a contract creation transaction.

  • value - string: Value transferred in wei.

  • gas - number: Gas provided by the sender.

  • gasPrice - string: Gas price provided by the sender in wei.

  • input - string: The data sent along with the transaction.

Example

judger.getTransaction()
> {
    "hash": "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b",
    "nonce": 2,
    "blockHash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
    "blockNumber": 3,
    "transactionIndex": 0,
    "from": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
    "to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "value": '123450000000000000',
    "gas": 314159,
    "gasPrice": '2000000000000',
    "input": "0x57cb2fc4"
}

Get Token Info

judger.getTokenInfo()

Returns information of the token

Returns

Returns object:

  • contractAddress - string: Address of the contract

  • tokenName - string: Name of the token.

  • symbol - string: Symbol of the token.

  • divisor - string: divisor of the token.

  • tokenType - string: Type of the token.

  • totalSupply - string: Supply of the token.

Example

judger.getTokenInfo()
> {
        "contractAddress": "0x0bbd16530582cc8f8d129badc848a8d8f485a397",
        "tokenName": "Insdex USD",
        "symbol": "IUSD",
        "divisor": "18",
        "tokenType": "ERC20",
        "totalSupply": "405000000001000000000"
}

Get Token Action Type

judger.getTokenActionType()

Returns action type of the token

Returns

Returns string of the event type, which could be:

  • "native-transfer"

  • "erc20-transfer"

  • "erc20-approval"

  • "erc20-mint"

  • "erc721-transfer"

  • "erc721-approval"

  • "erc721-approval-for-all"

Example

judger.getTokenActionType()
> "native-transfer"

Get Token Action

judger.getTokenAction()

Returns token action data

Returns

Returns object with varied info depending on the kind of token:

  1. "native-transfer":

    • from - string: Address of the sender.

    • to - string: Address of the receiver.

    • value - string: Value transferred in wei.

  2. "erc20-transfer":

    • from - string: Address of the sender.

    • to - string: Address of the receiver.

    • value - string: Value transferred in wei.

  3. "erc20-approval":

    • owner - string: Address of the owner.

    • spender - string: Address of the spender.

    • value - string: Value Approved in wei.

  4. "erc20-mint":

    • from - string: Address of the sender.

    • to - string: Address of the receiver.

    • value - string: Value transferred in wei.

  5. "erc721-transfer":

    • from - string: Address of the sender.

    • to - string: Address of the receiver.

    • tokenId - string: Id of the token.

  6. "erc721-approval":

    • owner - string: Address of the owner.

    • approved - string: Address of the approval.

    • tokenId - string: Id of the token.

  7. "erc721-approval-for-all":

    • owner - string: Address of the owner.

    • operator - string: Address of the operator.

    • approved - boolean: Status of Approval.

Exmaple

judger.getTokenAction()
> {
    "from": "0xBd23e38E81CCb481c64897c7dFE186C5Aa111111",
    "to": "0xBd23e38E81CCb481c64897c7dFE186C5Aa111111",
    "value": "1000000000000000000"
}

Last updated