Deploy your first public contract

The remix is an online IDE for creating, running and deploying contracts in browser setting without the need for an elaborate set-up process. You can get started right away.

Remix offers 3 development environments such as Javascript VM, Injected provider and Web3 provider. In this guide, we would be using Javascript VM and injected provider as it is convenient and doesn't require any external software or node to run the smart contract.

Reloading browser in Javascript VM restarts Remix in an empty state.

Deploying your first public contract

  • Click the Browser label on the left-side menu and create a file invoice.sol with the sample code below.

pragma solidity ^0.5.1;
contract Invoice {
enum Status {
struct InvoiceStruct {
bool isExist;
string invoiceID;
Status status;
mapping (string => InvoiceStruct) invoices;
/* addInvoice function */
function addInvoice(string memory invoiceID, string memory hash) public returns (bool) {
invoices[hash].isExist = true;
invoices[hash].invoiceID = invoiceID;
invoices[hash].status = Status.ACTIVE;
return true;
/* isHashExists function */
function isHashExists(string memory hash) public view returns (bool) {
return true;
return false;
/* getInvoiceID function */
function getInvoiceID(string memory hash) public view returns (string memory) {
return "";
return invoices[hash].invoiceID;
  • Get the Solidity environment loaded.

Select the 'Invoice' smart contract to compile. It should compile without any error.

Compilation errors

If you get errors after compiling, make sure your compiler is set to one of the 0.5.1 compilers.

  • Now select the "Deploy & run transactions" tab in the left-hand menu and change your Environment to Injected Web3 with and click on Deploy.

  • Select the ledgerium account which has XLG balance in it.

  • Check the balance on Ledgerium Wallet.

  • Since the transactions will be sent unsigned, the ledgerium account needs to be unlocked before executing it. It can be done 2 ways.

geth attach
Welcome to the Geth JavaScript console!
instance: Geth/
coinbase: 0x69c30d313cae3233ee4e4dc35d8ba203c6655224
at block: 17044 (Thu, 24 Oct 2019 16:15:37 AEDT)
datadir: /eth
modules: admin:1.0 debug:1.0 eth:1.0 istanbul:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
> personal.unlockAccount("0xef759369e2b95b207fcc9ec2a6925fe3f8945f8f","somepassword")

Or, unlock it programmatically by connecting the node with web3 and call.

  • So once everything looks good, press the Deploy button. You will now see in remix terminal tab that the contract is pending. It will take a few moments for the contract to be deployed. The Remix UI will update upon completion.

With this, your first public smart contract is ready to interact.