All Projects → ironaddicteddog → anchor-escrow

ironaddicteddog / anchor-escrow

Licence: MIT license
Escrow program implemented in Anchor

Programming Languages

rust
11053 projects
typescript
32286 projects

Projects that are alternatives of or similar to anchor-escrow

OpenLoginSdk
Pluggable auth infrastructure for Web3 wallets and dapps
Stars: ✭ 108 (-23.94%)
Mutual labels:  web3, solana
solana-mobile-wallet
💳 Non-custodial cross-platform wallet for Solana
Stars: ✭ 64 (-54.93%)
Mutual labels:  web3, solana
expo-solana-wallet
Cross-Platform Solana Wallet built with Expo and Solana/web3.js
Stars: ✭ 122 (-14.08%)
Mutual labels:  web3, solana
Solnet
Solana's .NET SDK and integration library.
Stars: ✭ 252 (+77.46%)
Mutual labels:  web3, solana
fetch-nft
🖼🎑🌠 A utility to fetch and easily display Ethereum & Solana NFTs in a common format given any wallet
Stars: ✭ 83 (-41.55%)
Mutual labels:  web3, solana
solana-web3-demo
a quick demo for solana web3
Stars: ✭ 93 (-34.51%)
Mutual labels:  web3, solana
nina
a self-publishing protocol for musicians - on solana
Stars: ✭ 27 (-80.99%)
Mutual labels:  web3, solana
circles-myxogastria
Webapp and mobile client for Circles
Stars: ✭ 32 (-77.46%)
Mutual labels:  web3
nextjs-dapp-starter-ts
A fullstack monorepo template to develop ethereum dapps
Stars: ✭ 228 (+60.56%)
Mutual labels:  web3
geesome-node
🦈 Your self-hosted decentralized Messenger, Social network, Media file storage on top of IPFS! Freely communicate in encrypted chat groups, share images, video, text or any data without a risk of censorship or blocking.
Stars: ✭ 90 (-36.62%)
Mutual labels:  web3
crypto-high-score
Add your name to the global, immutable leaderboard by paying in ETH.
Stars: ✭ 18 (-87.32%)
Mutual labels:  web3
oxo-chat-client
基于websocket、json、blockchain的公告、聊天(客户端到客户端加密)客户端。账号无需注册,本地生成!
Stars: ✭ 52 (-63.38%)
Mutual labels:  web3
0x-event-extractor
NodeJS worker built for 0x Tracker which extracts 0x fill events from the Ethereum blockchain and persists them to MongoDB
Stars: ✭ 32 (-77.46%)
Mutual labels:  web3
mev-inspect-rs
Discover historic Miner Extractable Value (MEV) opportunities
Stars: ✭ 443 (+211.97%)
Mutual labels:  web3
SkyGallery
Create galleries by uploading images and videos. Powered by Sia Skynet.
Stars: ✭ 23 (-83.8%)
Mutual labels:  web3
frontend-v2
Frontend app for the Balancer protocol
Stars: ✭ 127 (-10.56%)
Mutual labels:  web3
ethereum-php
Ethereum Client for PHP.
Stars: ✭ 50 (-64.79%)
Mutual labels:  web3
react-use-downloader
Creates a download handler function and gives progress information
Stars: ✭ 65 (-54.23%)
Mutual labels:  anchor
geth-connector
This repository served as an experiment playground for the alpha version of AKASHA desktop application. Now it is considered deprecated and seen as a stepping stone in the R&D of the AKASHA world framework. 🚀🌍🚀
Stars: ✭ 52 (-63.38%)
Mutual labels:  web3
web3-token
Web3 Token is a new way to authenticate users in a hybrid dApps using signed messages. Implementation of EIP-4361.
Stars: ✭ 356 (+150.7%)
Mutual labels:  web3

Anchor Example: Escrow Program

See this doc for more implementation details

Overview

Since this program is extended from the original Escrow Program, I assumed you have gone through the original blog post at least once.

However, there is one major difference between this exmaple and the original Escrow program: Instead of letting initializer create a token account to be reset to a PDA authority, we create a token account Vault that has both a PDA key and a PDA authority.

Initialize

Initializer can send a transaction to the escrow program to initialize the Vault. In this transaction, two new accounts: Vault and EscrowState, will be created and tokens (Token A) to be exchanged will be transfered from Initializer to Vault.

Cancel

Initializer can also send a transaction to the escrow program to cancel the demand of escrow. The tokens will be transfered back to the Initialzer and both Vault and EscrowState will be closed in this case.

Exchange

Taker can send a transaction to the escrow to exchange Token B for Token A. First, tokens (Token B) will be transfered from Taker to Initializer. Afterward, the tokens (Token A) kept in the Vault will be transfered to Taker. Finally, both Vault and EscrowState will be closed.

Install, Build, Deploy and Test

Let's run the test once to see what happens.

Install anchor

First, make sure that anchor is installed:

Install avm:

$ cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
...

Install latest anchor version:

$ avm install 0.26.0
...
$ avm use 0.26.0
...

If you haven't installed cargo, please refer to this doc for installation steps.

Extra Dependencies on Linux (Optional)

You may have to install some extra dependencies on Linux (ex. Ubuntu):

$ sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev
...

Verify the Installation

Check if Anchor is successfully installed:

$ anchor --version
anchor-cli 0.26.0

Install Dependencies

Next, install dependencies:

$ yarn

Build anchor-escrow

Update program_id

Get the public key of the deploy key. This keypair is generated automatically so a different key is exptected:

$ anchor keys list
anchor_escrow: GW65RiuuG2zU27S39FW83Yug1t13RxWWwHSCWRwSaybC

Replace the default value of program_id with this new value:

# Anchor.toml

[programs.localnet]
anchor_escrow = "GW65RiuuG2zU27S39FW83Yug1t13RxWWwHSCWRwSaybC"

...
// lib.rs

...

declare_id!("GW65RiuuG2zU27S39FW83Yug1t13RxWWwHSCWRwSaybC");

...

Build the program:

$ anchor build

Deploy anchor-escrow

Let's deploy the program. Notice that anchor-escrow will be deployed on a mainnet-fork test validator run by Dappio:

$ solana config set --url https://rpc-mainnet-fork.epochs.studio
...
$ solana config set --ws wss://rpc-mainnet-fork.epochs.studio/ws
...
$ anchor deploy
...

Program Id: GW65RiuuG2zU27S39FW83Yug1t13RxWWwHSCWRwSaybC

Deploy success

Finally, run the test:

$ anchor test --skip-build --skip-deploy
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].