AirGap coin library MIT Licence

We’re excited to announce that the airgap-coin-lib is now under the MIT licence. The AirGap coin library is a protocol-agnostic library that allows easy handling of the most important tasks relating to cryptocurrencies and blockchains.

What does the airgap-coin-lib do?

It implements operations such as preparing, signing and broadcasting transactions for a range of protocols. airgap-coin-lib is written in Typescript and fully browser compatible.

The library consists of a shared interface for all implemented protocols. This is especially useful in the context of AirGap, where you have an offline and an online device. The following operations are specified:

¬ prepareTransaction

The transaction is prepared with a standardised interface for all supported protocols.

prepareTransactionFromPublicKey(

publicKey: string,

recipients: string[],

values: BigNumber[],

fee: BigNumber,

data?: any

)

¬ signTransaction

The unsigned transaction you will get back is in the case of Ethereum a RawEthereumTransaction

export interface RawEthereumTransaction {

nonce: string

gasPrice: string

gasLimit: string

to: string

value: string

chainId: number

data: string

}

This is the transaction that you can plug into the corresponding signWithPrivateKey function to sign the transaction or serialize/deserialize it for another device.

¬ broadcastTransaction

The output of signTransaction is the input for this method and for AirGap is transferred via URL scheme or QR code and then broadcasted.

const deserializedTxSigningRequest: DeserializedSyncProtocol = { protocol: ethereum.protocolIdentifier,

type: EncodedType.SIGNED_TRANSACTION,

payload: {

accountIdentifier: publicKey.substr(-6) // you can use really anything here, up to you

transaction: signedEthereumTx,

// the following properties are optional for certain currencies and not included in the actual QR, but can be recovered form the signed tx

from: from,

amount: amount,

fee: fee,

to: to

}

}

Which protocols are supported?

airgap-coin-lib supported protocols

The coin-lib currently supports the following protocols and for most of them spend operations for now. Aeternity, Bitcoin, Ethereum and Generic ERC20 Tokens. As well as Tezos (Beta) where besides spend operations also delegate, undelegate and originate are supported.

What can be done with this?