0.8.1 • Published 4 months ago

@identity.com/gateway-eth-ts v0.8.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

gateway-eth-ts

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 gateway token issuance, token freezing/unfreezing and revocation.

Installation

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

Metamask integration example

import {
  GatewayTs,
} 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 gateway = new GatewayTs(gatekeeper, network, DEFAULT_GATEWAY_TOKEN_ADDRESS);
  const testUser = '0xD42Ef952F2EA1E77a8b771884f15Bf20e35cF85f';
  await (await gateway.issue(testUser)).wait();
})();

Utility functions

Token bitmask construction

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

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

Examples

Charges

Charging in Eth:

// when charging in ETH - the gatekeeper cannot send the transaction directly
// Use GatewayTsTransaction to generate a transaction that can be sent to the client
const gateway = new GatewayTsTransaction(
    gatekeeper,
    DEFAULT_GATEWAY_TOKEN_ADDRESS
);
const charge = makeWeiCharge(chargeValue, recipientAddress);
const tx = gateway.issue(wallet, gatekeeperNetwork, undefined, undefined, charge)

// send tx to the user to sign and send

Charging in ERC20:

const charge = makeERC20Charge(
    chargeValue,
    erc20TokenAddress,
    userAddress,
    recipientAddress
);
const approvalTx = await approveERC20Charge(
    charge,
    provider
);
const internalApproveTx = await approveInternalERC20Charge(
    charge,
    gatekeeperNetwork,
    provider
);
// send approvalTx and approveInternalTx to the user to sign
// once the user has signed the above transactions

const gateway = new GatewayTs(
    gatekeeper,
    DEFAULT_GATEWAY_TOKEN_ADDRESS
);

await gateway.issue(wallet, gatekeeperNetwork, undefined, undefined, charge)

);

0.8.1

4 months ago

0.8.1-alpha.0

10 months ago

0.8.1-alpha.1

10 months ago

0.8.1-alpha.2

6 months ago

0.8.1-alpha.3

6 months ago

0.8.0

10 months ago

0.8.0-alpha.0

11 months ago

0.7.1

1 year ago

0.5.6

1 year ago

0.7.0

1 year ago

0.5.7

1 year ago

0.6.0-alpha.1

1 year ago

0.6.0-alpha.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.5

1 year ago

0.5.0

1 year ago

0.3.1

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.3.0

1 year ago

0.3.0-alpha.2

1 year ago

0.3.0-alpha.3

1 year ago

0.3.0-alpha.4

1 year ago

0.3.0-alpha.1

1 year ago

0.2.0-alpha.8

2 years ago

0.2.0-alpha.7

2 years ago

0.2.0-alpha.0

2 years ago

0.2.0-alpha.2

2 years ago

0.2.0-alpha.1

2 years ago

0.2.0-alpha.3

2 years ago

0.2.0-alpha.6

2 years ago

0.2.0-alpha.5

2 years ago

0.1.0-beta.3

2 years ago

0.1.0-beta.2

2 years ago

0.1.0-beta.1

2 years ago

0.1.2-beta4

2 years ago

0.1.2-beta5

2 years ago

0.1.2-beta2

2 years ago

0.1.2-beta3

2 years ago

0.1.2-beta1

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.2-beta8

2 years ago

0.1.2-beta6

2 years ago

0.1.2-beta7

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.10

3 years ago

0.0.4-alpha

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago