How to use nem2-sdk - 10 common examples

To help you get started, we’ve selected a few nem2-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 44uk / nem2-dev-ui / src / util / convert.ts View on Github external
export const convertIdentifierToNamespaceId = (value: string) => {
  if(/[0-9a-fA-F]{16}/.test(value)) {
    return NamespaceId.createFromEncoded(value)
  }
  try {
    const namespaceId = new NamespaceId(value)
    return namespaceId
  } catch (_) {
    // try next
  }
  const hex = convertUInt64ToHex(value)
  if(! /[0-9a-fA-F]{16}/.test(hex)) {
    throw new Error("Can't convert")
  }
  return NamespaceId.createFromEncoded(hex)
}
github evias / nem2-sandbox / src / commands / aggregate / mosaicConfiguration.ts View on Github external
addresses.map((address: Address) => {
            const transferTx = TransferTransaction.create(
                Deadline.create(),
                address,
                [new Mosaic(mosaicId, UInt64.fromUint(amount))],
                PlainMessage.create('nem2-sandbox initial coin distribution'),
                this.networkType,
                UInt64.fromUint(1000000), // 1 XEM fee
            )

            transferTxes.push(transferTx.toAggregate(publicAccount))
        })
github evias / nem2-sandbox / src / commands / aggregate / mosaicConfiguration.ts View on Github external
addresses.map((address: Address) => {
            const transferTx = TransferTransaction.create(
                Deadline.create(),
                address,
                [new Mosaic(mosaicId, UInt64.fromUint(amount))],
                PlainMessage.create('nem2-sandbox initial coin distribution'),
                this.networkType,
                UInt64.fromUint(1000000), // 1 XEM fee
            )

            transferTxes.push(transferTx.toAggregate(publicAccount))
        })
github luxtagofficial / Apostille-library / src / hash / keccak-256.ts View on Github external
public signedHashing(data: string, signerPrivateKey: string, networkType: NetworkType): string {
    const dataHash = CryptoJS.SHA3(data, { outputLength: 256 }).toString();

    if (networkType === NetworkType.MAIN_NET || networkType === NetworkType.TEST_NET) {
      const keyPair = nem.crypto.keyPair.create(signerPrivateKey);
      return this.checksum +  keyPair.sign(dataHash).toString();
    } else {
      // sha-3 signing
      const signer = Account.createFromPrivateKey(signerPrivateKey, networkType);
      return this.checksum +  signer.signData(dataHash);
    }
  }
}
github luxtagofficial / Apostille-library / tests / e2e / PrivateApostille / Apostille.spec.ts View on Github external
it('should return true after creation', async () => {
    const privateApostille = Apostille.initFromSeed('new random seed', generator);
    const creator = Account.createFromPrivateKey(sk, NetworkType.MIJIN_TEST);
    const Icreator = new Initiator(creator);
    expect.assertions(1);
    const creationTransaction = privateApostille.update('raw');
    const signedTransaction = Icreator.sign(creationTransaction, generationHash);
    await apostilleHttp.announce(signedTransaction);
    return apostilleHttp.isCreated(privateApostille.publicAccount).then((result) => {
      expect(result).toBeTruthy();
    });
  });
github evias / nem2-sandbox / src / commands / cow / tester.ts View on Github external
private getAccount(): Account
    {
        return Account.createFromPrivateKey(this.privateKey, NetworkType.MIJIN_TEST);
    }
github nemtech / nem2-cli / src / service / mosaic.service.ts View on Github external
static getMosaicId(rawMosaicId: string): MosaicId | NamespaceId {
        let mosaicId: MosaicId | NamespaceId;
        if (rawMosaicId.charAt(0) === MosaicService.ALIAS_TAG) {
            mosaicId = new NamespaceId(rawMosaicId.substring(1));
        } else {
            mosaicId = new MosaicId(rawMosaicId);
        }
        return mosaicId;
    }
github nemtech / nem2-cli / src / service / mosaic.service.ts View on Github external
static getMosaicId(rawMosaicId: string): MosaicId | NamespaceId {
        let mosaicId: MosaicId | NamespaceId;
        if (rawMosaicId.charAt(0) === MosaicService.ALIAS_TAG) {
            mosaicId = new NamespaceId(rawMosaicId.substring(1));
        } else {
            mosaicId = new MosaicId(rawMosaicId);
        }
        return mosaicId;
    }
github luxtagofficial / Apostille-library / src / infrastructure / ApostilleHttp.ts View on Github external
public static createLockFundsTransaction(signedAggregateBondedTransaction: SignedTransaction): LockFundsTransaction {
    const lockFundsTransaction = LockFundsTransaction.create(
      Deadline.create(),
      new Mosaic(new NamespaceId('nem.xem'), UInt64.fromUint(10)),
      UInt64.fromUint(480),
      signedAggregateBondedTransaction,
      signedAggregateBondedTransaction.networkType);

    return lockFundsTransaction;
  }
github luxtagofficial / Apostille-library / src / model / apostille / PublicApostille.ts View on Github external
public update(fileContent: string, hashFunction: HashFunction): TransferTransaction {
    this.hash = hashFunction.nonSignedHashing(fileContent);
    const creationTransaction = TransferTransaction.create(
      Deadline.create(),
      this.sinkAddress,
      [
        new Mosaic(new NamespaceId('nem.xem'), UInt64.fromUint(10)),
      ],
      PlainMessage.create(this.hash),
      this.sinkAddress.networkType,
    );
    return creationTransaction;
  }

nem2-sdk

Reactive Nem2 sdk for typescript and javascript

Apache-2.0
Latest version published 5 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages