Example of a SC coded in RUST that can safely perform any swaps of tokens (NFT, SFT, ESDT, MetaESDT)

Overview

Elrond-NFT-Trading

Example of a Smart Contract (SC) coded in RUST, that can perform any swaps of tokens (NFT, SFT, ESDT, MetaESDT)

The idea

P2P swaps are very tempting, we sometimes want an NFT and we are willing to give 2 NFTs, or 1 NFT plus some tokens in exchange. If feels like trading pokemon cards. However this is not safe as we never know if both parties are trustful. This is why having an escrow SC as an intermediary helps us feeling more safe with those special trades. To understand the logic of the code, here is the process :

_ The transaction is initiated by a "Buyer". He sets the desired tokens/NFTs he'd like to have, and locks in the SC the amount of tokens/NFTs the "Seller" wants. Once the tokens are locked, he will receive a transaction id that is necessary for the "Seller".

_ With this transaction id, the "Seller" can check the details of the transaction ("Buyer" address, tokens locked, tokens desired). If he agrees, he can proceed to the swap and sends the desired tokens to SC.

If everything is correct and agreed upon, the transaction occurs. If not, the "Seller" gets automatically his tokens back and the "Buyer" can unlock his.

image

Note that our code doesn't allow EGLD swaps, only ESDTs/NFTs. Therefore the user needs to first wrap EGLD to be able to swap WEGLD (as it is an ESDT).

The code

You'll find the SC code in the src/ directory. In order to compile/deploy/interact with the SC, you'll need erdpy.

Compile : In the root directory erdpy contract build

Deploy : In the root directory ./deploy_contract.sh (You may need to do chmod +x deploy_contract.sh, and you need to specify a pem file)

Interact : More details soon, meanwhile you can check the code.

More

The code is ready to perform NFT/ESDT swaps, however this is a V1 and lots of improvement can be made in the future. Feel free to use the code, and improve it as well :)

If you have any questions you can also contact me on twitter

Also if you like this repo and you'd like to donate : thank you!

You might also like...
Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;
Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens;

Metaplex is a protocol built on top of Solana that allows: Creating/Minting non-fungible tokens; Starting a variety of auctions for primary/secondary

A contract to lock fungible tokens with a given vesting schedule including cliffs.

Fungible Token Lockup contract Features A reusable lockup contract for a select fungible token. Lockup schedule can be set as a list of checkpoints wi

Helper library for interacting with Terra assets (SDK coins and CW20 tokens)

terra-asset Helpers for interacting with Terra assets, including native coins and CW20 tokens Usage This crate contains two struct types: AssetInfo st

Simple PoC to issue JSON Web Tokens (JWTs) with a canister on the Internet Computer.

JWT Issuer Proof of Concept Overview Simple PoC to issue JSON Web Tokens (JWTs) with a canister on the Internet Computer. It allows the issuance of tw

Uniswap V2 / constant-product AMM implemented in Solana's Anchor -- add and remove liquidity, swap tokens, earn fees

Uniswap V2 AMM implemented in Anchor programs/ammv2/src/draft.rs: outline of program with comments -- drafted before implementation Supported Instruct

⚡️ NFT Snapshot script written in Rust for blazingly fast speeds ⚡️

⚡️ NFT SNAPSHOT ⚡️ This project uses rust's blazingly fast performance along with the ethers-rs library to read blockchain state. Setup You will have

Simple rust library for NFT metadata w/ an easy server

NFT Server Simple rust lib for NFT Metadata, and a basic axum server for delivering it $ cargo build $ cargo clippy $ cargo run --bin example Usage I

A Simple Rust NFT API + Smart Contract

Rust NFT API Purpose Rust NFT API is a simple RESTful API developed in Rust that offers functionalities for creating, retrieving, and listing Non-Fung

C++ `std::unique_ptr` that represents each object as an NFT on the Ethereum blockchain
C++ `std::unique_ptr` that represents each object as an NFT on the Ethereum blockchain

C++ `std::unique_ptr` that represents each object as an NFT on the Ethereum blockchain

Owner
Sia
Love doing DIY projects and playing with Machine and Deep learning algorithms
Sia
Custom p2p swaps powered by Solana blockchain

Peer to peer, decentralized protocol which allow direct swaps between 2 network participants for custom tokens without liquidity pools on Solana blockchain.

Ilia 3 Mar 18, 2022
Biddi Network enables custom p2p swaps in Solana ocean 🌊.

Peer to peer, decentralized protocol which allow direct swaps between 2 network participants for custom tokens without liquidity pools on Solana blockchain.

Biddi Network 2 Nov 1, 2022
A basic contract to facilitate multi-hop FIN swaps

Fin Multi A basic contract designed to support consolidation of staking "dust" into a single asset, via FIN Market Swaps. ExecuteMsg requires a Vec<Ve

Kujira 2 Oct 11, 2022
Example NFT marketplace project using ink! smart contract.

NFT Marketplace project This contract is an example for the NFT marketplace implementation. License Apache 2.0 ??️ How to use - Contracts ?? Build Use

Swanky dApps 8 Jan 18, 2023
Using flashbots to mint Otherside metaverse land safely with purchased KYC'd wallets.

Work in progress. Hardcoded to mint 2 lands for 610 APE and approves 100k ape for spending atm, will be updated. Building Install rust, https://rustup

cc 6 May 5, 2022
ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot network.

ARYA Network ARYA Network is a polkadot/substrate based chain for Non-fungible Token platform on which we can own sell and buy the NFT's on polkadot n

Pankaj Chaudhary 6 Dec 20, 2022
Tool written in Rust to perform Password Spraying attacks against Azure/Office 365 accounts

AzurePasswordSprayer Tool written in Rust to perform Password Spraying attacks against Azure/Office 365 accounts. It is multi threaded and makes no co

Pierre 7 Feb 27, 2024
A password manager coded in rust

pasman A password manager coded in rust Install Dependency rust Shell git clone https://github.com/AMTitan/pasman.git cd pasman cargo build --release

Arthur Melton 4 Nov 8, 2021
A blazingly fast, ShareX uploader coded in Rust (using actix web) which utilizes AES-256-GCM-SIV to securely store uploaded content.

Magnesium Oxide ❔ What is this? Magnesium-Oxide (MGO) is a secure file uploader with support for ShareX. ?? Features ?? Blazingly fast uploads and enc

Nitrogen Development 26 Nov 25, 2022
Ore Pool Miner coded in Rust for the Ore v2 program on Solana!

Ore Pool Miner Ore Pool Miner coded in Rust for the Ore v2 program on Solana Default Ore Mining Pool Alvarium Mining Pool is operated by Bifrost and i

Bifrost Inc 11 Oct 7, 2024