2

What's the best way to create an address in Ontology using Javascript?

I can see how to call getBalance and getTransactions but need to get an address first.

Wyetro
  • 8,439
  • 9
  • 46
  • 64
Rudrika
  • 155
  • 9
  • Instead of asking the solution from here better you can google it. You'll get more solutions. – Mayur Jun 11 '19 at 06:40
  • Already Googled it. – Rudrika Jun 11 '19 at 07:06
  • @Rudrika check out my answer below. I'm a contributor to Ontology so I can help out with any questions you have. I'd head over to the Ontology discord for more questions - they'll probably lock this question. – Wyetro Jun 11 '19 at 18:47

1 Answers1

0

You can create a new Ontology wallet with the Ontology TS SDK.

Install it with yarn or npm:

npm install 'ontology-ts-sdk' --save

And use with the following:

const Ont = require('ontology-ts-sdk');

const {
  Crypto,
  Account,
} = Ont;

const {
  PrivateKey,
} = Crypto;

const {
  Account,
} = Account;

const privateKey = PrivateKey.random();
const account = Account.create(privateKey, '123456', 'mickey');
console.log('Address: ' + account.address.toBase58());

Source: Ontology Typescript SDK

Wyetro
  • 8,439
  • 9
  • 46
  • 64