Building a DApp

In 7 minutes *

Hello, I'm Salama Ashoush

Senior Software Engineer@Box

I enjoy experimenting with new ideas and building Apps and tools with JS for the Web, Desktop, and Mobile. As a curious tinkerer, I'm always learning.

What is Blockchain?

A blockchain is a type of digital ledger

  • Data Storage: Primarily for transactional data (e.g., financial transactions, sales records). Not ideal for bulk file storage.
     
  • Replication: Data is replicated in real-time across numerous systems. Public blockchains (e.g., Chainweb, Bitcoin, Ethereum) are fully transparent, broadcasting data to all participants.
     
  • Decentralization: Unlike typical web client-server architecture, blockchains use a distributed network of nodes. Information spreads via "gossiping" rather than central broadcasting.

What is Blockchain?

A blockchain is a type of digital ledger

  • Consensus Mechanisms: To validate data, nodes use mechanisms like Proof of Work (PoW) and Proof of Stake (PoS). These are crucial for network integrity and security.
     
  • Cryptography: Utilizes digital signatures for ownership and authenticity, and cryptographic hashes for data reference and tamper detection.
     
  • Smart Contracts: Self-executing programs stored on-chain. Similar to database-stored procedures, they read and write data based on set rules. Essential for web3 applications, they require gas fees for execution.

Kadena

  • Chainweb, a public, proof-of-work blockchain with low gas fees and a unique multi-chain architecture that allows for high transaction throughput.
     
  • Pact, a smart contract programming language that emphasizes security and correctness.
     
  • Kadena.js, a collection of JavaScript libraries for interacting with Chainweb nodes and working with Pact code.

 

Smart Contracts
+
UI/FE/BE
=
A distrusted app (dApp)

Pact

Kadena's smart contract language 

  • Human-Readable Code: Pact code is stored directly on-chain, unlike languages like Solidity that compile to bytecode. This enhances security verification.
     
  • Turing-Incomplete: Disallows recursion and loops, preventing infinite loops and associated blockchain hang-ups.
     
  • Formal Verification: Built-in support for type checking and formal verification using the Z3 theorem prover, eliminating many potential bugs.

Kadena.js

Bridging Kadena and Web Frontends

  • Integration of Chainweb and Pact: Kadena.js serves as a toolkit for applications built on Kadena, integrating Chainweb and Pact, the core technologies for smart contract development on the Kadena platform.
     
  • User-Friendly Interface: Aimed at providing a user-friendly interface, it allows users to interact with smart contracts through a typical web frontend in JavaScript, rather than directly engaging with the contracts.

Wait!

where is my dApp?!

Let's build one

(namespace 'free )
(module world-world G
  (defcap G () true)
  (defun say-hello(name:string)
    (format "Hello, {}!" [name])
  )
)

Hello world

// install pact
brew install kadena-io/pact/pact

pact hello-world.pact
// Load successful
(begin-tx "Load hello world")

(env-data {
  'admin-ks: { "keys": [], "pred": "keys-all" }
})

(define-namespace "free" (read-keyset "admin-ks") (read-keyset "admin-ks"))

(load "hello-world.pact")

(print (hello-world.say-hello "World"))

(expect "Hello, World!" (hello-world.say-hello "World"))

(commit-tx)

It should say hello!

pact pact/hello-world.repl
// Hello, World!
// Load successful

Questions

A community meetup that shares knowledge about Qwik and the JS ecosystem in general.

Build a dApp in 7 mins

By Salama Ashoush

Build a dApp in 7 mins

  • 124