How to use the @cityofzion/neon-js.u.str2hexstring function in @cityofzion/neon-js

To help you get started, we’ve selected a few @cityofzion/neon-js 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 be-neo / neoblog / packages / smart-contract-js-lib / src / getfromstorage.js View on Github external
import '@babel/polyfill';
import Neon, { api, u } from '@cityofzion/neon-js';
import { scriptHash, localHost } from './blockchain/config';

const client = Neon.create.rpcClient(localHost);
const s2h = u.str2hexstring;

const store_key = u.str2hexstring('post.')+u.int2hex(1);

/* (async function main() {
  queryBlockchain(store_key).then((result) => {
    console.log(result);
  }).catch((e) => {
    console.log(e);
  });
})(); */

export default function queryBlockchain(key) {
  const query = Neon.create.query({
    'method': 'getstorage',
    'params': [
      scriptHash,
      key
    ]
github nos / client / src / main / util / resolve.js View on Github external
async function resolveNameService(url) {
  const { host, pathname } = url;

  const endpoint = await getRPCEndpoint(NOS_TESTNET);
  const client = new rpc.RPCClient(endpoint);
  const storageKey = u.str2hexstring(`${host}.target`);
  const response = await client.getStorage(NS_SCRIPT_HASH, storageKey);

  if (!response) {
    throw new Error('Not found.');
  }

  const target = u.hexstring2str(response);

  return `${target}${pathname}`;
}
github nos / client / src / renderer / browser / util / encodeArgs.js View on Github external
        type ${'string'} ${() => u.str2hexstring(arg)}
        type ${'number'} ${() => u.int2hex(arg)}
github nos / client / src / renderer / shared / util / getStorage.js View on Github external
export const encode = (value) => u.str2hexstring(value);
export const decode = (value) => u.hexstring2str(value);