Create a Blockchain Address

Step-by-step example of how to create a Public Mint blockchain address

In this example you'll learn how to create a valid blockchain address that can be used on Public Mint's blockchain.

Before you start

Public Mint's service APIs offer a series of methods that can be used to integrate with Public Mint services and blockchain. Before you start, it's recommended that you review the full documentation available online on developers.publicmint.io.

Creating Addresses

There are many ways of creating a blockchain address. In this example, we'll use NodeJS with the Web3 lib to communicate with the blockchain.

Example

const Web3 = require('web3');
const provider = 'https://public.tst.publicmint.io:8545'; // Public Mint TestNet Blockchain
const opts = {
    defaultBlock: 'latest',
    transactionConfirmationBlocks: 1,
}
const web3 = new Web3(provider, null, opts);
(async function () {
   const passphrase = 'test';
   const account = await web3.eth.accounts.create(passphrase);  
   console.log('PMINT ACCOUNT address:', account.address);
   console.log('PMINT ACCOUNT PK:', account.privateKey);
})();
// OUTPUT
PMINT ACCOUNT address: 0xEa3F2eb61dD221344834eA6a3fd2128dF6641D4E
PMINT ACCOUNT PK: 0x0edd054f73c62fdca08b3940413df4f713a34cd5b702f88641b984499f165565

This example will return the private key and the public address of the newly created account. Both will be necessary to integrate with Public Mint's blockchain and service APIs.

Last updated