• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions
Flyy Tech
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs
  • Camera
  • Audio
No Result
View All Result
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs
  • Camera
  • Audio
No Result
View All Result
Flyy Tech
No Result
View All Result

Programming in Rust when your skills are rusty 3/3 | by Vicente Aceituno Canal | Sep, 2022

flyytech by flyytech
September 14, 2022
Home Security
Share on FacebookShare on Twitter


Photo by Tanguy Sauvin on Unsplash

Third part of this series:

If you have an environment set up as per part 2 of this series, now it is time to start programming in Rust.

The project I chose requires the creation of affordable non-fungible tokens.

After a week long research for a blockchain where I can create smart contracts in Rust, I finally settle for NEAR Protocol, as other blockchains either don’t support Rust (Cardano), the NFT metadata is too complex to set up (Solana), you can do anything but I can’t figure out how to do one simple thing (Substrate), or the NFTs are too costly (Ethereum).

A surprise I had when chasing this affordable NFT solution is that you can’t just create NFTs, first you have to create your own “NFT minting machine”, a smart contract. So it is way more involved that I anticipated.

If you are up for learning to create a smart contract in Rust to mint non-fungible tokens, this is how to do it:

For testing purposes we need Node.js, we can install it using in the test environment with:

login YOURUSERACCOUNTIDsudo curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bashsudo apt-get install -y nodejs

We need to check that we have version 16 or above of Node.js

node -v

We also need yarn for building the smart contract

sudo apt-get update && sudo apt-get install yarncurl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/nullecho “deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main” | sudo tee /etc/apt/sources.list.d/yarn.list

The target is Webassembly so we need to install it for Rust

rustup target add wasm32-unknown-unknown

Next, create a test wallet in NEAR Protocol, choosing a name for your account; YOURNEARPROTOCOLACCOUNTID.testnet

Install NEAR-CLI in the test environment

sudo npm install -g npm@8.19.1sudo npm install -g near-clihttps://docs.near.org/tools/near-cli#setupwe can login to near

Log in to NEAR Protocol Testnet

Login to near testnet from the test environment using:

near login

Copy and paste the generated URL to a browser. You need to add the “s” and the IP of the computer where the browser is:

https://wallet.testnet.near.org/login/?referrer=NEAR+CLI&public_key=ed25519THISISSTRINGGENERATEDWHENYOURUNNEARLOGINsuccess_url=https%3A%2F%2FIPOFTHEBROWSERWHEREYOUVISITTHEURL%3A5000

Approve the log in from the browser.

Note: You will have to do this quite a few times. When running tests you will find that smart contracts keep their state in the blockchain. You could call the total opposite of idempotent, you can’t run for test purposes a smart contract more than once ignoring previous runs. So you may need a test account per set of tests.

Add to .bashrc the following:

export NEARID=YOURNEARPROTOCOLACCOUNTID.testnetexport NFT_CONTRACT_ID="YOURNEARPROTOCOLACCOUNTID.testnet"

logout and login (your computer session, not your NEAR session)

Code our smart contract

Next we need to download the NFT tutorial code with

git clone https://github.com/near-examples/nft-tutorial/

And switch to the branch used in the tutorial

cd ~/nft-tutorial 
sudo git switch 1.skeleton
git checkout 1.skeleton

Make changes and updates according to the following tutorial, adding any custom changes for your own purposes:

Iron out any compile warnings that you probably will find.

Build the smart contract

When ready from the directory where cargo.toml is run:

yarn build

Deploy the smart contract

From the directory where you can see there is a “out” subdirectory running the following command:

near deploy --wasmFile out/main.wasm --accountId $NFT_CONTRACT_ID

Verify that the correct account ID is printed in the terminal

Initialize the contract

near call $NFT_CONTRACT_ID new_default_meta '{"owner_id": "'$NFT_CONTRACT_ID'"}' --accountId $NFT_CONTRACT_ID

Mint the non-fungible token

near call $NFT_CONTRACT_ID nft_mint '{"token_id": "token-1", "metadata": {"title": "My Non Fungible Team Token", "description": "The Team Most Certainly Goes :)", "media": "https://bafybeiftczwrtyr3k7a2k4vutd3amkwsmaqyhrdzlhvpt33dyjivufqusq.ipfs.dweb.link/goteam-gif.gif"}, "receiver_id": "'$NFT_CONTRACT_ID'"}' --accountId $NFT_CONTRACT_ID --amount 0.1

View the non-fungible token

near view $NFT_CONTRACT_ID nft_token '{"token_id": "token-1"}'near view $NFT_CONTRACT_ID nft_metadata

Success! A smart contract written in Rust that can be used to mint affordable non-fungible tokens.

Next in this series: How to modify boringtun-cli to use a non-fungible token instead of a configuration file. Stay tuned!



Source_link

flyytech

flyytech

Next Post
Lockly Vision Elite review: this smart lock video doorbell combo costs $500

Lockly Vision Elite review: this smart lock video doorbell combo costs $500

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Evidence Shows AI-Driven Companies Are Buying up Gaming GPUs

Evidence Shows AI-Driven Companies Are Buying up Gaming GPUs

August 1, 2023
A Capable Contender for the ATX 3.0 Club

A Capable Contender for the ATX 3.0 Club

February 17, 2023

Trending.

Image Creator now live in select countries for Microsoft Bing and coming soon in Microsoft Edge

Image Creator now live in select countries for Microsoft Bing and coming soon in Microsoft Edge

October 23, 2022
Shop now. Pay later. on the App Store

Shop now. Pay later. on the App Store

February 25, 2023
How To Install Tiny11 for Arm64 on Raspberry Pi 4

How To Install Tiny11 for Arm64 on Raspberry Pi 4

February 19, 2023
Lian Li Galahad II Trinity Performance 240 AIO Review: Raising the Bar

Lian Li Galahad II Trinity Performance 240 AIO Review: Raising the Bar

September 19, 2023
Hackers behind MGM cyberattack thrash the casino’s incident response

Hackers behind MGM cyberattack thrash the casino’s incident response

September 16, 2023

Flyy Tech

Welcome to Flyy Tech The goal of Flyy Tech is to give you the absolute best news sources for any topic! Our topics are carefully curated and constantly updated as we know the web moves fast so we try to as well.

Follow Us

Categories

  • Apple
  • Applications
  • Audio
  • Camera
  • Computers
  • Cooking
  • Entertainment
  • Fitness
  • Gaming
  • Laptop
  • lifestyle
  • Literature
  • Microsoft
  • Music
  • Podcasts
  • Review
  • Security
  • Smartphone
  • Travel
  • Uncategorized
  • Vlogs

Site Links

  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

Recent News

Reducing Warehouse Disruptions with Cycle Counting

Reducing Warehouse Disruptions with Cycle Counting

September 30, 2023
EKWB Unveils $449 Waterblock For The Sony PlayStation 5

EKWB Unveils $449 Waterblock For The Sony PlayStation 5

September 30, 2023

Copyright © 2022 Flyytech.com | All Rights Reserved.

No Result
View All Result
  • Home
  • Apple
  • Applications
    • Computers
    • Laptop
    • Microsoft
  • Security
  • Smartphone
  • Gaming
  • Entertainment
    • Literature
    • Cooking
    • Fitness
    • lifestyle
    • Music
    • Nature
    • Podcasts
    • Travel
    • Vlogs

Copyright © 2022 Flyytech.com | All Rights Reserved.

What Are Cookies
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT