# infinitechain_client

> Infinitechain Client SDK

Latest version **0.0.5** (published 2018-02-01) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install infinitechain_client
pnpm add infinitechain_client
yarn add infinitechain_client
bun add infinitechain_client
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2018-02-01 |
| First published | 2018-01-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 (+27 in 3 direct dependencies) |
| Install scripts | no |
| Author | ifc-dev |
| Maintainers | ifc-dev, juinc |

## Links

- npm: https://www.npmjs.com/package/infinitechain_client
- Repository: https://github.com/TideiSunTaipei/infinitechain_client
- Homepage: https://github.com/TideiSunTaipei/infinitechain_client#readme
- Issues: https://github.com/TideiSunTaipei/infinitechain_client/issues
- npm.io page: https://npm.io/package/infinitechain_client

## Dependencies (11)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [web3](https://npm.io/package/web3.md) ^0.20.1
- [axios](https://npm.io/package/axios.md) ^0.17.1
- [js-sha3](https://npm.io/package/js-sha3.md) ^0.6.1
- [node-rsa](https://npm.io/package/node-rsa.md) ^0.4.2
- [constants](https://npm.io/package/constants.md) 0.0.2
- [keythereum](https://npm.io/package/keythereum.md) ^1.0.2
- [child_process](https://npm.io/package/child_process.md) ^1.0.2
- [ethereumjs-tx](https://npm.io/package/ethereumjs-tx.md) ^1.3.3
- [ethereumjs-util](https://npm.io/package/ethereumjs-util.md) ^5.1.2
- [ethereumjs-wallet](https://npm.io/package/ethereumjs-wallet.md) ^0.6.0

## Recent versions

- 0.0.5 (latest) — 2018-02-01
- 0.0.4 — 2018-02-01
- 0.0.3 — 2018-01-30
- 0.0.2 — 2018-01-26
- 0.0.1 — 2018-01-19

## README

# Infinitechain Client
## Structure
IFCBuilder

IFC
- client
  - makeRawPayment
  - audit
  - takeObjection
  - verifyPayment
  - saveRawPayment
  - getRawPayment
  - savePayment
  - getPayment
  - export
- crypto
  - getOrNewKeyPair
  - importSignerKey
  - importCipherKey
  - encrypt
  - decrypt
  - sign
  - verify
  - getSignerAddress
  - keyInfo
- sidechain
  - getIFCContract
  - getStage
  - getStageRootHash
  - getLatestStageHeight
  - getSlice
- event
  - watchAddStage
  - watchObjection
  - watchExonerate
  - watchFinalize

## Example
### 1. Use IFCBuilder to create an ifc object
```javascript
ifc = new IFCBuilder()
      .setNodeUrl("http://0.0.0.0:3000")
      .setWeb3Url("http://0.0.0.0:8545")
      .setStorageType('chrome-extension')
      .setClientAddress('0x49aabbbe9141fe7a80804bdf01473e250a3414cb')
      .setServerAddress('0x5b9688b5719f608f1cb20fdc59626e717fbeaa9a')
      .build()
```

### 2. Use `crypto` to generate key pair and you can also import your private key.
```javascript
ifc.crypto.getOrNewKeyPair()
ifc.crypto.keyInfo()
ifc.crypto.importSignerKey('YOUR_PRIVATE_KEY')
```

### 3. Make raw payment with specific format
When client wants to purchase a product, `makeRawPayment()` should be called to produce a raw payment. After that, client can call `saveRawPayment()` to save it and then send to server.
```javascript
rawPayment = ifc.client.makeRawPayment(value, data)
ifc.client.saveRawPayment(rawPayment)

/* 
rawPayment = {
  from: '0x49aabbbe9141fe7a80804bdf01473e250a3414cb',
  to: '0x5b9688b5719f608f1cb20fdc59626e717fbeaa9a',
  value: 100,
  localSequenceNumber: 99,
  stageHeight: 3,
  data: {
    foo: 'bar',
    pkClient: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5SxAR4lIyHg3vF/DbWKq\nZfedueCC6TpSMmD3LMZ2vhvI8cO1ydmDRTngJlgiKCcQFGGRcDqI5vxBfE4vdCy/\nDFw1zTiT9pPLUWGZNT4YxlcdFUJ26b4YqRHUk8Tfg4YNSUTaNKaj2VKj3NyLrchN\neunMWeLj+QlfdjV5zUkOy9pbMj0co1gDAK85jnO8NJupycWyA/ezfpaoTfJj2Ijd\n2b0+nCWCdWw8oWBJH9uXhCetbTI2QjYYOXj77aICrr2OUH4OkiZMoiIXAIV0D+P9\nysa6hgFzv5xAlO39mOnnu4wRoYJIIaHZyvNMVkdt4ZavZPuTuAQIPODy8/n19QWq\nRQIDAQAB\n-----END PUBLIC KEY-----',
    pkStakeholder: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQgP8iTDok0b1JSIPmbE\nzCKSphTfHm57Mu3LIgz9PD3vfcVW43sqAMOkelRijqmUpNLW0OBYzNIgH7sIIrhG\n89zXxXG/s4ewrbcbJn8XhotFoJQFLzBFovgYv34v3ZYmlCZsApWAtXkxWveq54FJ\nsQFrUWA+J/FNkp4uqu2Ekenn8OnuYYn25LdZPiUugOPMrALk4hS6nDSBmfVSPPka\nDilawdZwjkQGH9uu8pOFYG+oT1q9MYahrkmRzY05Q4zHOhB8HPzsbz0HpuwanXga\n/HqEmvBn0EJs+SrkZZmyZ6bjz1Izx8Io67HEje9JUeV6qDLE/ZQ/PXoRLnqg3Yqd\nIwIDAQAB\n-----END PUBLIC KEY-----'
  }
}
*/
console.log(rawPayment);
```
### 4. Verify payment
After client receive a payment that included a server's signature, client should call `verifyPayment()` to verify the integrity of payment. If it is valid, client could call `savePayment()` to save it.
```javascript
ifc.client.verifyPayment(payment)
ifc.client.savePayment(payment)
```
### 5. Audit payment
After client is notified by a `AddNewStage event`, he can call `audit()` to audit the payments that are related to the event.
```javascript
ifc.client.audit(paymentHash)
```
### 6. Take objection
When a result of the distributed auditing is false, client can call `takeObjection()`.
```javascript
ifc.client.takeObjection(payment)
```

---
_Source: https://npm.io/package/infinitechain_client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
