First Steps in Development

First Steps with æternity Blockchain Development

Setting Up Your First Project

Getting started with æternity blockchain development is straightforward with the æternity project tool (aeproject). This command-line utility helps you initialize projects, compile smart contracts, run tests, and deploy to the blockchain.

To begin your journey, create a new project directory and initialize it with the aeproject tool:

mkdir my-aepp
cd my-aepp
aeproject init

The initialization process creates a well-organized project structure with dedicated directories for your smart contracts, deployment scripts, tests, and Docker configuration. The initialization process creates a well-organized project structure: my-aepp/

├── contracts/       # Sophia smart contracts
├── deployment/      # Deployment scripts
├── test/           # Test files
└── docker/         # Docker configuration

Now it's time to write your first smart contract in the Sophia language:

// contracts/HelloWorld.aes
contract HelloWorld =
  entrypoint sayHello(name : string) : string =
    String.concat("Hello, ", name)

To ensure your contract works as expected, write a test file:

// test/helloWorldTest.js
const { assert } = require('chai')
const { utils } = require('@aeternity/aeproject')

describe('HelloWorld', () => {
  let contract
  
  before(async () => {
    contract = await utils.deployContract('HelloWorld')
  })
  
  it('should say hello', async () => {
    const result = await contract.sayHello('æternity')
    assert.equal(result, 'Hello, æternity')
  })
})

Run your tests with aeproject test.

Wallet Setup and Acquiring Test Tokens

To interact with the æternity blockchain, you'll need a wallet. The Base æpp (Mobile Wallet) is a comprehensive mobile wallet for iOS and Android. Create a new account and securely store your seed phrase.

For browser-based development, install the SuperHero Wallet (Browser Extension). It allows easy switching between mainnet and testnet environments.

Before deploying to mainnet, develop on the testnet using free test tokens. Visit https://faucet.aeternity.io or use the command:

curl -X POST -H "Content-Type: application/json" \
  -d '{"address": "YOUR_PUBLIC_KEY"}' \
  https://faucet.aeternity.io/account/balance

Environment Configuration

Configure your environment to connect to the appropriate æternity network:

// config/network.js
module.exports = {
  networks: {
    testnet: {
      node: "https://testnet.aeternity.io",
      compilerUrl: "https://compiler.aeternity.io"
    },
    local: {
      node: "http://localhost:3001",
      compilerUrl: "http://localhost:3080"
    }
  }
}

During development, use a local node with aeproject node for faster testing.

Next Steps

Explore æternity's advanced features like state channels for off-chain scaling, oracles for accessing external data, and the AENS naming system for human-readable addresses.

Join the æternity Forum to connect with the community.

Always develop on testnet before moving to mainnet, and carefully review your code for security vulnerabilities.

Last updated

Was this helpful?