SlideShare a Scribd company logo
1 of 39
Download to read offline
How to build a
dApp in Starknet
Vishnu C
Before we start
ZKX is a permissionless protocol for derivatives
built on StarkNet, with a decentralised order
book and a unique way to offer complex financial
instruments as swaps.
Trustless, Permissionless, and Borderless.
Ethereum and Layer 2
Smart contract
A "smart contract" is simply a program that
runs on the blockchain. It's a collection of code
(its functions) and data (its state) that resides at
a specific address on the blockchain.
What is layer 2?
A layer 2 is a separate blockchain that extends
Ethereum and inherits the security guarantees
of Ethereum.
Why do we need layer 2?
StarkNet and Cairo
StarkNet
A permissionless decentralised ZK-Rollup. It
operates as an L2 network over Ethereum
enabling massive scalability without
compromising Ethereum’s composability and
security.
Cairo
The learning curve - quirks of Cairo
Recursion instead of iteration
Everything should be in felt data type
No concept of arrays - use mappings instead
Debugging cairo smart contracts can get quite
complicated
The learning curve - quirks of Cairo
Absence of boolean expressions
Solidity: if (x == 2 && y == 2) { … }
In Cairo, this is not possible!
But there are workarounds like the following:
assert (x - 1) * (y - 1) = 0 can be used for assert x || y
assert x * y = 0 can be used for assert !x || !y
assert x + y = 2 can be used for assert x && y
Starknet and Cairo are amazing!
The community
The amount of documentation and tutorials
Great frameworks for development
Workshops and hackathons
Cairo just keeps getting better!
No need to mention again, but transactions are cheap!
A basic dApp
Stake L1 contract
function stake() - payable
function withdraw(uint256 amount)
Stake L2 contract
func deposit(from_address, user_l1_address, amount) - l1
handler
func withdraw(user_l1_address, amount)
func take_fee(user_l1_address)
func get_balance(user_l1_address) - view function
L1 <—> L2 Communication
One important property of a good L2 system is the ability to
interact with the L1 system it’s built on.
Every StarkNet contract may send and receive messages
to/from any L1 contract.
L1 -> L2 messaging
L1 contract can initiate a message to L2 by calling
sendMessageToL2 function on the StarkNet core
contract.
The arguments for this function are:
toAddress
selector
payload
This invokes function annotated with l1_handler
decorator on the target contract.
L2 -> L1 messaging
L2 contract can send a message to L1 by calling
send_message_to_l1 syscall.
The arguments for this function are:
to_address
payload_size
payload
After the state update that included this transaction is
proved and L1 state is updated, hash of this message is
stored on StarkNet core contract.
L2 -> L1 messaging
Recipient address on L1 can consume this message by
providing the message parameters by calling
consumeMessageFromL2 function on the StarkNet core
contract.
Arguments needed are:
fromAddress
payload
Contracts and Functions
L1
L1
L2
L2
L2
L1
Compile and Deploy
StarkNet
Ethereum
References
Stake dApp Github -
https://github.com/StarkCon/workshop01
StarkNet documentation - https://cairo-
lang.org/docs/hello_starknet/index.html
L1 <-> L2 communication - https://cairo-
lang.org/docs/hello_starknet/l1l2.html
Thank
you!
Twitter: @zkxprotocol
Website: zkx.fi

More Related Content

What's hot

Blockchain HyperLedger Fabric Internals - Clavent
Blockchain HyperLedger Fabric Internals - ClaventBlockchain HyperLedger Fabric Internals - Clavent
Blockchain HyperLedger Fabric Internals - ClaventAraf Karsh Hamid
 
Opentracing jaeger
Opentracing jaegerOpentracing jaeger
Opentracing jaegerOracle Korea
 
Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)Chris Richardson
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code QAware GmbH
 
Observability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerObservability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerVMware Tanzu
 
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracing
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracingTracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracing
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracingYuri Shkuro
 
Microservices Testing Strategies JUnit Cucumber Mockito Pact
Microservices Testing Strategies JUnit Cucumber Mockito PactMicroservices Testing Strategies JUnit Cucumber Mockito Pact
Microservices Testing Strategies JUnit Cucumber Mockito PactAraf Karsh Hamid
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - ObservabilityAraf Karsh Hamid
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
Scaling Ethereum using Zero-Knowledge Proofs
Scaling Ethereum using Zero-Knowledge ProofsScaling Ethereum using Zero-Knowledge Proofs
Scaling Ethereum using Zero-Knowledge ProofsHyojun Kim
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to TestcontainersVMware Tanzu
 
Blockchain Intro to Hyperledger Fabric
Blockchain Intro to Hyperledger Fabric Blockchain Intro to Hyperledger Fabric
Blockchain Intro to Hyperledger Fabric Araf Karsh Hamid
 
Streaming architecture patterns
Streaming architecture patternsStreaming architecture patterns
Streaming architecture patternshadooparchbook
 
IBM Blockchain Platform - Architectural Good Practices v1.0
IBM Blockchain Platform - Architectural Good Practices v1.0IBM Blockchain Platform - Architectural Good Practices v1.0
IBM Blockchain Platform - Architectural Good Practices v1.0Matt Lucas
 
Distributed tracing using open tracing &amp; jaeger 2
Distributed tracing using open tracing &amp; jaeger 2Distributed tracing using open tracing &amp; jaeger 2
Distributed tracing using open tracing &amp; jaeger 2Chandresh Pancholi
 
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1Gilbert Verdian
 
Introducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring StatemachineIntroducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring StatemachineVMware Tanzu
 

What's hot (20)

Blockchain HyperLedger Fabric Internals - Clavent
Blockchain HyperLedger Fabric Internals - ClaventBlockchain HyperLedger Fabric Internals - Clavent
Blockchain HyperLedger Fabric Internals - Clavent
 
Opentracing jaeger
Opentracing jaegerOpentracing jaeger
Opentracing jaeger
 
Hyperledger fabric 3
Hyperledger fabric 3Hyperledger fabric 3
Hyperledger fabric 3
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)
 
Clean Infrastructure as Code
Clean Infrastructure as Code Clean Infrastructure as Code
Clean Infrastructure as Code
 
Observability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing PrimerObservability, Distributed Tracing, and Open Source: The Missing Primer
Observability, Distributed Tracing, and Open Source: The Missing Primer
 
Elastic-Engineering
Elastic-EngineeringElastic-Engineering
Elastic-Engineering
 
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracing
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracingTracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracing
Tracing 2000+ polyglot microservices at Uber with Jaeger and OpenTracing
 
Microservices Testing Strategies JUnit Cucumber Mockito Pact
Microservices Testing Strategies JUnit Cucumber Mockito PactMicroservices Testing Strategies JUnit Cucumber Mockito Pact
Microservices Testing Strategies JUnit Cucumber Mockito Pact
 
Service Mesh - Observability
Service Mesh - ObservabilityService Mesh - Observability
Service Mesh - Observability
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Scaling Ethereum using Zero-Knowledge Proofs
Scaling Ethereum using Zero-Knowledge ProofsScaling Ethereum using Zero-Knowledge Proofs
Scaling Ethereum using Zero-Knowledge Proofs
 
Introduction to Testcontainers
Introduction to TestcontainersIntroduction to Testcontainers
Introduction to Testcontainers
 
Blockchain Intro to Hyperledger Fabric
Blockchain Intro to Hyperledger Fabric Blockchain Intro to Hyperledger Fabric
Blockchain Intro to Hyperledger Fabric
 
Streaming architecture patterns
Streaming architecture patternsStreaming architecture patterns
Streaming architecture patterns
 
IBM Blockchain Platform - Architectural Good Practices v1.0
IBM Blockchain Platform - Architectural Good Practices v1.0IBM Blockchain Platform - Architectural Good Practices v1.0
IBM Blockchain Platform - Architectural Good Practices v1.0
 
Distributed tracing using open tracing &amp; jaeger 2
Distributed tracing using open tracing &amp; jaeger 2Distributed tracing using open tracing &amp; jaeger 2
Distributed tracing using open tracing &amp; jaeger 2
 
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1
Quant Overledger for Mobility, IOT and Automotive sectors - MOBI 20190220 v1
 
Introducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring StatemachineIntroducing Saga Pattern in Microservices with Spring Statemachine
Introducing Saga Pattern in Microservices with Spring Statemachine
 

Similar to How to build a dApp in StarkNet

Layer-2 after “The Merge”
Layer-2 after “The Merge”Layer-2 after “The Merge”
Layer-2 after “The Merge”Jiyun Kim
 
Cryptographic Agility in Corda
Cryptographic Agility in CordaCryptographic Agility in Corda
Cryptographic Agility in CordaGuy Hochstetler
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxWijdenBenothmen1
 
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101Simone Onofri
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Tomoaki Sato
 
Ethereum Blockchain and DApps - Workshop at Software University
Ethereum Blockchain and DApps  - Workshop at Software UniversityEthereum Blockchain and DApps  - Workshop at Software University
Ethereum Blockchain and DApps - Workshop at Software UniversityOpen Source University
 
以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12Aludirk Wong
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contractsssusercc3bf81
 
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...Docker, Inc.
 
آموزش پرایس اکشن (price action)
آموزش پرایس اکشن (price action)آموزش پرایس اکشن (price action)
آموزش پرایس اکشن (price action)price act
 
UNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.pptUNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.pptAsmitSilhare1
 
IRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and EthereumIRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and EthereumIRJET Journal
 
Lilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdfAlly339821
 

Similar to How to build a dApp in StarkNet (20)

Layer-2 after “The Merge”
Layer-2 after “The Merge”Layer-2 after “The Merge”
Layer-2 after “The Merge”
 
Cryptographic Agility in Corda
Cryptographic Agility in CordaCryptographic Agility in Corda
Cryptographic Agility in Corda
 
Ethereum vs fabric vs corda
Ethereum vs fabric vs cordaEthereum vs fabric vs corda
Ethereum vs fabric vs corda
 
Hyperledger
HyperledgerHyperledger
Hyperledger
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptx
 
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
 
How to design, code, deploy and execute a smart contract
How to design, code, deploy and execute a smart contractHow to design, code, deploy and execute a smart contract
How to design, code, deploy and execute a smart contract
 
All About Ethereum
All About EthereumAll About Ethereum
All About Ethereum
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)
 
Ethereum
EthereumEthereum
Ethereum
 
Ethereum Blockchain and DApps - Workshop at Software University
Ethereum Blockchain and DApps  - Workshop at Software UniversityEthereum Blockchain and DApps  - Workshop at Software University
Ethereum Blockchain and DApps - Workshop at Software University
 
以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12以太坊代幣付款委託 @ Open Source Developer Meetup #12
以太坊代幣付款委託 @ Open Source Developer Meetup #12
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contracts
 
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
DockerCon EU 2015: The Missing Piece: when Docker networking unleashing soft ...
 
آموزش پرایس اکشن (price action)
آموزش پرایس اکشن (price action)آموزش پرایس اکشن (price action)
آموزش پرایس اکشن (price action)
 
UNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.pptUNIT V - The OMG way-system object model Notes.ppt
UNIT V - The OMG way-system object model Notes.ppt
 
IRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and EthereumIRJET- Proof of Document using Multichain and Ethereum
IRJET- Proof of Document using Multichain and Ethereum
 
Ethereum-Cryptocurrency (All about Ethereum)
Ethereum-Cryptocurrency (All about Ethereum) Ethereum-Cryptocurrency (All about Ethereum)
Ethereum-Cryptocurrency (All about Ethereum)
 
Lilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdfLilypad @ Labweek, Istanbul, 2023.pdf
Lilypad @ Labweek, Istanbul, 2023.pdf
 
NFT Layer 2 Development
NFT Layer 2 DevelopmentNFT Layer 2 Development
NFT Layer 2 Development
 

More from TinaBregovi

Building LSD Use Cases on Bifrost
Building LSD Use Cases on BifrostBuilding LSD Use Cases on Bifrost
Building LSD Use Cases on BifrostTinaBregovi
 
Urbit Launch Event
Urbit Launch EventUrbit Launch Event
Urbit Launch EventTinaBregovi
 
Layer Hack: Boba Network: Understanding Hybrid Compute
Layer Hack: Boba Network: Understanding Hybrid ComputeLayer Hack: Boba Network: Understanding Hybrid Compute
Layer Hack: Boba Network: Understanding Hybrid ComputeTinaBregovi
 
Layer Hack: zkSync - Intro to zkEVM
Layer Hack: zkSync - Intro to zkEVMLayer Hack: zkSync - Intro to zkEVM
Layer Hack: zkSync - Intro to zkEVMTinaBregovi
 
Rollup-as-a-service and why it matters to the next-gen of dApps
Rollup-as-a-service and why it matters to the next-gen of dAppsRollup-as-a-service and why it matters to the next-gen of dApps
Rollup-as-a-service and why it matters to the next-gen of dAppsTinaBregovi
 
Layer Hack: AltLayer Workshop
Layer Hack: AltLayer WorkshopLayer Hack: AltLayer Workshop
Layer Hack: AltLayer WorkshopTinaBregovi
 
Layer Hack Launch Event
Layer Hack Launch EventLayer Hack Launch Event
Layer Hack Launch EventTinaBregovi
 
Bridging with StarkNet
Bridging with StarkNetBridging with StarkNet
Bridging with StarkNetTinaBregovi
 
How To Build Better NFTs with Briq
How To Build Better NFTs with BriqHow To Build Better NFTs with Briq
How To Build Better NFTs with BriqTinaBregovi
 
NFTs on StarkNet
NFTs on StarkNetNFTs on StarkNet
NFTs on StarkNetTinaBregovi
 
Braavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfBraavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfTinaBregovi
 
StarkNet Autumn Hackathon Launch Event.pptx
StarkNet Autumn Hackathon Launch Event.pptxStarkNet Autumn Hackathon Launch Event.pptx
StarkNet Autumn Hackathon Launch Event.pptxTinaBregovi
 
Harmony Marketplace SDK.pptx
Harmony Marketplace SDK.pptxHarmony Marketplace SDK.pptx
Harmony Marketplace SDK.pptxTinaBregovi
 
Get Ready for Coinbase Node
Get Ready for Coinbase NodeGet Ready for Coinbase Node
Get Ready for Coinbase NodeTinaBregovi
 
MANIFOLD MEV Bounty Competition
MANIFOLD MEV Bounty CompetitionMANIFOLD MEV Bounty Competition
MANIFOLD MEV Bounty CompetitionTinaBregovi
 
Public SP Meeting
Public SP MeetingPublic SP Meeting
Public SP MeetingTinaBregovi
 
Welcome to the Web 3.0
Welcome to the Web 3.0Welcome to the Web 3.0
Welcome to the Web 3.0TinaBregovi
 
Introduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionIntroduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionTinaBregovi
 

More from TinaBregovi (20)

Building LSD Use Cases on Bifrost
Building LSD Use Cases on BifrostBuilding LSD Use Cases on Bifrost
Building LSD Use Cases on Bifrost
 
Urbit Launch Event
Urbit Launch EventUrbit Launch Event
Urbit Launch Event
 
Layer Hack: Boba Network: Understanding Hybrid Compute
Layer Hack: Boba Network: Understanding Hybrid ComputeLayer Hack: Boba Network: Understanding Hybrid Compute
Layer Hack: Boba Network: Understanding Hybrid Compute
 
Layer Hack: zkSync - Intro to zkEVM
Layer Hack: zkSync - Intro to zkEVMLayer Hack: zkSync - Intro to zkEVM
Layer Hack: zkSync - Intro to zkEVM
 
Rollup-as-a-service and why it matters to the next-gen of dApps
Rollup-as-a-service and why it matters to the next-gen of dAppsRollup-as-a-service and why it matters to the next-gen of dApps
Rollup-as-a-service and why it matters to the next-gen of dApps
 
Layer Hack: AltLayer Workshop
Layer Hack: AltLayer WorkshopLayer Hack: AltLayer Workshop
Layer Hack: AltLayer Workshop
 
Layer Hack Launch Event
Layer Hack Launch EventLayer Hack Launch Event
Layer Hack Launch Event
 
Bridging with StarkNet
Bridging with StarkNetBridging with StarkNet
Bridging with StarkNet
 
How To Build Better NFTs with Briq
How To Build Better NFTs with BriqHow To Build Better NFTs with Briq
How To Build Better NFTs with Briq
 
NFTs on StarkNet
NFTs on StarkNetNFTs on StarkNet
NFTs on StarkNet
 
Braavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdfBraavos Wallet Workshop.pdf
Braavos Wallet Workshop.pdf
 
StarkNet Autumn Hackathon Launch Event.pptx
StarkNet Autumn Hackathon Launch Event.pptxStarkNet Autumn Hackathon Launch Event.pptx
StarkNet Autumn Hackathon Launch Event.pptx
 
Harmony Marketplace SDK.pptx
Harmony Marketplace SDK.pptxHarmony Marketplace SDK.pptx
Harmony Marketplace SDK.pptx
 
Coinbase Node
Coinbase NodeCoinbase Node
Coinbase Node
 
Get Ready for Coinbase Node
Get Ready for Coinbase NodeGet Ready for Coinbase Node
Get Ready for Coinbase Node
 
MANIFOLD MEV Bounty Competition
MANIFOLD MEV Bounty CompetitionMANIFOLD MEV Bounty Competition
MANIFOLD MEV Bounty Competition
 
Public SP Meeting
Public SP MeetingPublic SP Meeting
Public SP Meeting
 
Ecosystem WG
Ecosystem WGEcosystem WG
Ecosystem WG
 
Welcome to the Web 3.0
Welcome to the Web 3.0Welcome to the Web 3.0
Welcome to the Web 3.0
 
Introduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionIntroduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer version
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

How to build a dApp in StarkNet

  • 1. How to build a dApp in Starknet Vishnu C
  • 3. ZKX is a permissionless protocol for derivatives built on StarkNet, with a decentralised order book and a unique way to offer complex financial instruments as swaps. Trustless, Permissionless, and Borderless.
  • 5. Smart contract A "smart contract" is simply a program that runs on the blockchain. It's a collection of code (its functions) and data (its state) that resides at a specific address on the blockchain.
  • 6. What is layer 2? A layer 2 is a separate blockchain that extends Ethereum and inherits the security guarantees of Ethereum.
  • 7. Why do we need layer 2?
  • 9. StarkNet A permissionless decentralised ZK-Rollup. It operates as an L2 network over Ethereum enabling massive scalability without compromising Ethereum’s composability and security.
  • 10. Cairo
  • 11. The learning curve - quirks of Cairo Recursion instead of iteration Everything should be in felt data type No concept of arrays - use mappings instead Debugging cairo smart contracts can get quite complicated
  • 12. The learning curve - quirks of Cairo Absence of boolean expressions Solidity: if (x == 2 && y == 2) { … } In Cairo, this is not possible! But there are workarounds like the following: assert (x - 1) * (y - 1) = 0 can be used for assert x || y assert x * y = 0 can be used for assert !x || !y assert x + y = 2 can be used for assert x && y
  • 13. Starknet and Cairo are amazing! The community The amount of documentation and tutorials Great frameworks for development Workshops and hackathons Cairo just keeps getting better! No need to mention again, but transactions are cheap!
  • 15.
  • 16.
  • 17. Stake L1 contract function stake() - payable function withdraw(uint256 amount)
  • 18. Stake L2 contract func deposit(from_address, user_l1_address, amount) - l1 handler func withdraw(user_l1_address, amount) func take_fee(user_l1_address) func get_balance(user_l1_address) - view function
  • 19. L1 <—> L2 Communication
  • 20. One important property of a good L2 system is the ability to interact with the L1 system it’s built on. Every StarkNet contract may send and receive messages to/from any L1 contract.
  • 21. L1 -> L2 messaging L1 contract can initiate a message to L2 by calling sendMessageToL2 function on the StarkNet core contract. The arguments for this function are: toAddress selector payload This invokes function annotated with l1_handler decorator on the target contract.
  • 22. L2 -> L1 messaging L2 contract can send a message to L1 by calling send_message_to_l1 syscall. The arguments for this function are: to_address payload_size payload After the state update that included this transaction is proved and L1 state is updated, hash of this message is stored on StarkNet core contract.
  • 23. L2 -> L1 messaging Recipient address on L1 can consume this message by providing the message parameters by calling consumeMessageFromL2 function on the StarkNet core contract. Arguments needed are: fromAddress payload
  • 25. L1
  • 26. L1
  • 27. L2
  • 28. L2
  • 29. L2
  • 30. L1
  • 33.
  • 35.
  • 36.
  • 37.
  • 38. References Stake dApp Github - https://github.com/StarkCon/workshop01 StarkNet documentation - https://cairo- lang.org/docs/hello_starknet/index.html L1 <-> L2 communication - https://cairo- lang.org/docs/hello_starknet/l1l2.html