@identity.com/gateway-eth-ts
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.4 • Public • Published

    gateway-eth-ts

    oclif Version Downloads/week License

    Gateway ETH TS library

    This client library allows JS/TS applications to communicate with Gateway token system on Ethereum blockchain. Common methods include validation of existing tokens, new identity token issuance, token freezing/unfreezing and revokation.

    Installation

    yarn add @identity.com/gateway-eth-ts

    Metamask integration example

    import {
      GatewayETH,
      getGatekeeperAccountKeyFromGatekeeperAuthority,
      getGatewayTokenKeyForOwner,
      issueVanilla,
      findGatewayTokens,
    } from "@identity.com/gateway-eth-ts";
    import {
      getDefaultProvider,
      Wallet,
      providers
    } = from 'ethers';
    import { useWallet } from 'use-wallet';
    
    
    (async function() {
      const { ethereum } = useWallet();
      const chainId = Number(ethereum.chainId);
      const provider = new ethers.providers.Web3Provider(
          ethereum,
          chainId
      );
      const signer = provider.getSigner();
      const network = await provider.getNetwork();
      const gatewayLib = new GatewayETH(signer, network);
      const testUser = '0xD42Ef952F2EA1E77a8b771884f15Bf20e35cF85f';
      const tokenId = await gtLib.getDefaultTokenId(testUser);
      const tx = await gtLib.getTokenState(tokenId);
    })();
    

    Utility functions

    Token ID generation

    To issue a new token a library prepares a token ID for user, based on user's ETH address and additional constrains. The first 20 bytes of address are concateneted to a bytes32 string on the right side. Constrains concateneted to the left side, those constrains are limited to 12 bytes.

    Typically constrains are reflected as the number of identity tokens created for user.

    For example for 0xD42Ef952F2EA1E77a8b771884f15Bf20e35cF85f address identity token ids would be generated in a following sequence:

    0x01d42ef952f2ea1e77a8b771884f15bf20e35cf85f => 0x02d42ef952f2ea1e77a8b771884f15bf20e35cf85f => 0x03d42ef952f2ea1e77a8b771884f15bf20e35cf85f ...

    Token bitmask construction

    The easiest way to associate certain flags with the identity token is by using list of supported KYC flags, and addFlagsToBitmask function.

      flags = [KYCFlags.IDCOM_1];
      bitmask = addFlagsToBitmask(bitmask, flags);
    

    Gateway ETH TS library CLI

    Usage

    $ npm install -g @identity.com/gateway-eth-ts
    $ gateway-eth-ts COMMAND
    running command...
    $ gateway-eth-ts (-v|--version|version)
    @identity.com/gateway-eth-ts/0.1.4 darwin-x64 node-v14.19.1
    $ gateway-eth-ts --help [COMMAND]
    USAGE
      $ gateway-eth-ts COMMAND
    ...

    Commands

    gateway-eth-ts add-gatekeeper ADDRESS

    Add a gatekeeper to a GatewayToken contract

    USAGE
      $ gateway-eth-ts add-gatekeeper ADDRESS
    
    ARGUMENTS
      ADDRESS  Gatekeeper address to add to the GatewayToken contract
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway add-gatekeeper 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/add-gatekeeper.ts

    gateway-eth-ts add-network-authority ADDRESS

    Add a network authority to a GatewayToken contract

    USAGE
      $ gateway-eth-ts add-network-authority ADDRESS
    
    ARGUMENTS
      ADDRESS  Network authority address to add to the GatewayToken contract
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway add-network-authority 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/add-network-authority.ts

    gateway-eth-ts blacklist ADDRESS

    Blacklist user globaly in the gateway token system

    USAGE
      $ gateway-eth-ts blacklist ADDRESS
    
    ARGUMENTS
      ADDRESS  User ETH address to blacklist
    
    OPTIONS
      -c, --confirmations=confirmations  [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee      [default: [object Promise]] Gas Price level to execute transaction with. For
                                         example: instant, fast, standard, slow
    
      -h, --help                         Show CLI help.
    
      -n, --network=network              [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey        [default: [object Promise]] The ethereum address private key for signing messages
    
    EXAMPLE
      $ gateway blacklist 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/blacklist.ts

    gateway-eth-ts burn TOKENID

    Burn existing identity token using TokenID

    USAGE
      $ gateway-eth-ts burn TOKENID
    
    ARGUMENTS
      TOKENID  Token ID number to burn
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway burn 10
    

    See code: dist/commands/burn.ts

    gateway-eth-ts freeze TOKENID

    Freeze existing identity token using TokenID

    USAGE
      $ gateway-eth-ts freeze TOKENID
    
    ARGUMENTS
      TOKENID  Token ID number to freeze
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway freeze 10
    

    See code: dist/commands/freeze.ts

    gateway-eth-ts get-token TOKENID

    Get information related to gateway token by tokenID

    USAGE
      $ gateway-eth-ts get-token TOKENID
    
    ARGUMENTS
      TOKENID  Owner address to verify identity token for
    
    OPTIONS
      -h, --help                                     Show CLI help.
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway get-token 10
    

    See code: dist/commands/get-token.ts

    gateway-eth-ts get-token-id ADDRESS

    Get default gateway token ID by owner's address

    USAGE
      $ gateway-eth-ts get-token-id ADDRESS
    
    ARGUMENTS
      ADDRESS  Owner address to verify identity token for
    
    OPTIONS
      -h, --help                                     Show CLI help.
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway get-token-id 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/get-token-id.ts

    gateway-eth-ts help [COMMAND]

    display help for gateway-eth-ts

    USAGE
      $ gateway-eth-ts help [COMMAND]
    
    ARGUMENTS
      COMMAND  command to show help for
    
    OPTIONS
      --all  see all commands in CLI
    

    See code: @oclif/plugin-help

    gateway-eth-ts issue ADDRESS [EXPIRATION] [CONSTRAINS]

    Issue new identity token with TokenID for Ethereum address

    USAGE
      $ gateway-eth-ts issue ADDRESS [EXPIRATION] [CONSTRAINS]
    
    ARGUMENTS
      ADDRESS     Owner ethereum address to tokenID for
      EXPIRATION  [default: 0] Expiration timestamp for newly issued token
      CONSTRAINS  [default: 0] Constrains to generate tokenId
    
    OPTIONS
      -b, --bitmask=bitmask                          [default: 0] Bitmask constrains to link with newly minting tokenID
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -g, --[no-]generateTokenId                     Identifier used to determine wether tokenId has to be generated
    
      -h, --help                                     Show CLI help.
    
      -i, --tokenID=tokenID                          Token ID number to issue
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
      --[no-]forwardTransaction                      Whether the transaction will be sent via the Forwarder contract
    
    EXAMPLE
      $ gateway issue 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94 -i <TokenID>
    

    See code: dist/commands/issue.ts

    gateway-eth-ts refresh TOKENID [EXPIRY]

    Refresh existing identity token with TokenID for Ethereum address

    USAGE
      $ gateway-eth-ts refresh TOKENID [EXPIRY]
    
    ARGUMENTS
      TOKENID  Token ID number to refresh
      EXPIRY   The new expiry time in seconds for the gateway token (default 14 days)
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway refresh 10 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/refresh.ts

    gateway-eth-ts remove-gatekeeper ADDRESS

    Remove gatekeeper to a GatewayToken contract

    USAGE
      $ gateway-eth-ts remove-gatekeeper ADDRESS
    
    ARGUMENTS
      ADDRESS  Gatekeeper address to remove to the GatewayToken contract
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway remove-gatekeeper 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/remove-gatekeeper.ts

    gateway-eth-ts remove-network-authority ADDRESS

    Remove network authority to a GatewayToken contract

    USAGE
      $ gateway-eth-ts remove-network-authority ADDRESS
    
    ARGUMENTS
      ADDRESS  Network authority address to remove to the GatewayToken contract
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway remove-network-authority 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/remove-network-authority.ts

    gateway-eth-ts revoke TOKENID

    Revoke existing identity token by TokenID

    USAGE
      $ gateway-eth-ts revoke TOKENID
    
    ARGUMENTS
      TOKENID  Token ID number to revoke
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway revoke 10
    

    See code: dist/commands/revoke.ts

    gateway-eth-ts unfreeze TOKENID

    Unfreeze existing identity token using TokenID

    USAGE
      $ gateway-eth-ts unfreeze TOKENID
    
    ARGUMENTS
      TOKENID  Token ID number to unfreeze
    
    OPTIONS
      -c, --confirmations=confirmations              [default: 0] The amount of blocks to wait mined transaction
    
      -f, --gasPriceFee=gasPriceFee                  [default: [object Promise]] Gas Price level to execute transaction
                                                     with. For example: instant, fast, standard, slow
    
      -h, --help                                     Show CLI help.
    
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway unfreeze 10
    

    See code: dist/commands/unfreeze.ts

    gateway-eth-ts verify ADDRESS [TOKENID]

    Verify existing identity using token owner address

    USAGE
      $ gateway-eth-ts verify ADDRESS [TOKENID]
    
    ARGUMENTS
      ADDRESS  Owner address to verify identity token for
      TOKENID  Token ID to verify identity for
    
    OPTIONS
      -h, --help                                     Show CLI help.
      -n, --network=network                          [default: [object Promise]] Specify target network to work with
    
      -p, --privateKey=privateKey                    [default: [object Promise]] The ethereum address private key for
                                                     signing messages
    
      -t, --gatewayTokenAddress=gatewayTokenAddress  [default: [object Promise]] GatewayToken address to target
    
    EXAMPLE
      $ gateway verify 0x893F4Be53274353CD3379C87C8fd1cb4f8458F94
    

    See code: dist/commands/verify.ts

    gateway-eth-ts version

    USAGE
      $ gateway-eth-ts version
    

    See code: @oclif/plugin-version

    Keywords

    none

    Install

    npm i @identity.com/gateway-eth-ts

    DownloadsWeekly Downloads

    285

    Version

    0.1.4

    License

    MIT

    Unpacked Size

    251 kB

    Total Files

    125

    Last publish

    Collaborators

    • diosakhilleus
    • chriteixeira
    • rado0x54
    • araptarchis
    • mitchcivic
    • identity.com-ci
    • dankelleher
    • flippiescholtz
    • kevinhcolgan
    • pbshoemaker
    • tyronemichael
    • lucmir
    • william-identity