How to use @cityofzion/neon-core - 10 common examples

To help you get started, we’ve selected a few @cityofzion/neon-core 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 CityOfZion / neon-js / packages / neon-api / src / funcs / common.ts View on Github external
export async function modifyTransactionForEmptyTransaction<
  U extends tx.BaseTransaction,
  T extends ManagedApiBasicConfig<u>
&gt;(config: T): Promise {
  if (config.tx!.inputs.length === 0 &amp;&amp; config.tx!.outputs.length === 0) {
    config.tx!.addAttribute(
      tx.TxAttrUsage.Script,
      u.reverseHex(wallet.getScriptHashFromAddress(config.account!.address))
    );
    // This adds some random bits to the transaction to prevent any hash collision.
    config.tx!.addRemark(
      Date.now().toString() + u.ab2hexstring(u.generateRandomArray(4))
    );
  }
  return config;
}

</u>
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
            } catch (error) {
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
            } catch (error) {
                this.chrome.windowCallback({
                    error: ERRORS.INSUFFICIENT_FUNDS,
                    return: requestTarget.Deploy,
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
            } catch (error) {
                this.chrome.windowCallback({
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
            } catch (error) {
                this.chrome.windowCallback({
                    error: ERRORS.INSUFFICIENT_FUNDS,
github NeoNextClub / neoline / src / app / popup / notification / deploy / deploy.component.ts View on Github external
return new Promise(async (resolve, reject) => {
            const amount = (this.pramsData.dynamicInvoke === 'true'  ? 500 : 0) + (this.pramsData.needsStorage === 'true' ? 400 : 0) + 90;
            const fromAddress = this.neon.wallet.accounts[0].address;
            let newTx = new tx.InvocationTransaction();
            // tslint:disable-next-line: no-bitwise
            const num = (this.pramsData.needsStorage === 'true' ? 1 : 0) | (this.pramsData.dynamicInvoke === 'true' ? 2 : 0) |
                        (this.pramsData.isPayable === 'true' ? 4 : 0);
            const sb = new ScriptBuilder();
            sb.emitPush(str2hexstring(this.pramsData.description))
                .emitPush(str2hexstring(this.pramsData.email))
                .emitPush(str2hexstring(this.pramsData.author))
                .emitPush(str2hexstring(this.pramsData.version))
                .emitPush(str2hexstring(this.pramsData.name))
                .emitPush(num)
                .emitPush(this.pramsData.returnType || 'ff00')
                .emitPush(this.pramsData.parameterList)
                .emitPush(this.pramsData.code)
                .emitSysCall('Neo.Contract.Create');
            try {
                newTx.script = sb.str;
            } catch (error) {
                reject(error);
            }
            try {
                newTx = await this.addFee(fromAddress, newTx, amount + parseFloat(this.pramsData.networkFee));
github CityOfZion / neon-js / packages / neon-api / __tests__ / transaction / builder.ts View on Github external
test("setFee", () => {
    const transaction = new TransactionBuilder()
      .setSystemFee(new u.Fixed8(10))
      .setNetworkFee(new u.Fixed8(2))
      .build();
    expect(transaction.systemFee.equals(10)).toBeTruthy();
    expect(transaction.networkFee.equals(2)).toBeTruthy();
  });
});
github CityOfZion / neon-js / packages / neon-nep5 / __tests__ / abi.ts View on Github external
test("balanceOf", () => {
  const resultFunction = abi.balanceOf(scriptHash, fromAddr);
  const resultScript = resultFunction().str;
  expect(resultScript).toBe(
    `14${u.reverseHex(
      wallet.getScriptHashFromAddress(fromAddr)
    )}51c10962616c616e63654f6667${u.reverseHex(scriptHash)}`
  );
});
github CityOfZion / neon-js / packages / neon-nep5 / __tests__ / abi.ts View on Github external
test("decimals", () => {
  const resultFunction = abi.decimals(scriptHash);
  const resultScript = resultFunction().str;
  expect(resultScript).toBe(
    `0008646563696d616c7367${u.reverseHex(scriptHash)}`
  );
});