Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Create a Smart Contract Example with Tutorial using Ink #104

Closed
Web3Foundation opened this issue Apr 23, 2019 · 15 comments
Closed

Create a Smart Contract Example with Tutorial using Ink #104

Web3Foundation opened this issue Apr 23, 2019 · 15 comments
Labels
Bounty This issue has a bounty to be won! Bounty-m

Comments

@Web3Foundation
Copy link
Contributor

Parity Ink is a smart contract tool which allows for WebAssembly based smart contracts to be written in the Rust programming language.

Create an example smart contract with documentation and a tutorial detailing how you made it. In the tutorial it would be helpful if you compared some of the syntax and methods to what developers may already be familiar with in other smart contract languages. Deploy the smart contract example to a Substrate chain and optionally create a UI to interact with it.

Requirements
A correct submission will:

  • Be open source.
  • Comes with a tutorial detailing how it was developed and comparing it to other smart contract languages.
  • The smart contract must be deployed to a Substrate chain.
@Web3Foundation Web3Foundation added Bounty This issue has a bounty to be won! Bounty-m labels Apr 23, 2019
@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 300.0 DAI (300.0 USD @ $1.0/DAI) attached to it as part of the W3F fund.

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Workers have applied to start work.

These users each claimed they can complete the work by 12 months from now.
Please review their action plans below:

1) kankan-0 has applied to start work (Funders only: approve worker | reject worker).

Create a basic smart contract which will have a initial supply of tokens and can transfer tokens from one address to another. Document all the basic steps through out the process to make it easy for other people to understand the development process. Compare with solidity wherever acceptable so that people having experience with solidity can easily relate to the process and migrate effortlessly if they want.

Learn more on the Gitcoin Issue Details page.

@gitcoinbot
Copy link

gitcoinbot commented Apr 23, 2019

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 11 months, 1 week from now.
Please review their action plans below:

1) kankan-0 has applied to start work (Funders only: approve worker | reject worker).

Create a basic smart contract which will have a initial supply of tokens and can transfer tokens from one address to another. Document all the basic steps through out the process to make it easy for other people to understand the development process. Compare with solidity wherever acceptable so that people having experience with solidity can easily relate to the process and migrate effortlessly if they want.

Learn more on the Gitcoin Issue Details page.

2) kankan-0 has applied to start work (Funders only: approve worker | reject worker).

Create a basic smart contract which will have a initial supply of tokens and can transfer tokens from one address to another. Document all the basic steps through out the process to make it easy for other people to understand the development process. Compare with solidity wherever acceptable so that people having experience with solidity can easily relate to the process and migrate effortlessly if they want.

Learn more on the Gitcoin Issue Details page.

3) rossbulat has been approved to start work.

I have been extensively studying Rust throughout the last month, having previously spent around 6 weeks contributing to the front-end Polkadot UI, and am looking to get my hands dirty so to speak with Rust and Substrate, this task appearing to be an ideal gateway into doing so.

Plan of action would be the following:

  1. Familiarise myself with the "Flipper" contract walkthrough at https://github.com/paritytech/ink/wiki/Deploying-Your-First-Contract and get working on a Substrate node

  2. Apply process to creating a smart contract of a popular use case - E.g. an intangible asset token, a referendum contract, or an auction / bidding contract. I'll make notes throughout the entire process, logging every step along the way.

  3. Code contract and verify it is working on node and within Polkadot JS UI.

  4. Write up the process in an easy-to-follow manor explaining key concepts along the way.

I am confident in my ability to produce this tutorial to a high standard, I have a strong following on Medium where I write development articles predominantly for React and Typescript based educational content. I have also started a blockchain based journal.

Personal blog: https://medium.com/@rossbulat
The Block Journal: https://medium.com/block-journal

Thank you for considering.

Learn more on the Gitcoin Issue Details page.

@Web3Foundation
Copy link
Contributor Author

Web3Foundation commented Apr 24, 2019

@rossbulat you've been approved, this same bounty will be available multiple times over the next while.

@hskang9 @Kankan-0 if you want to work on this and submit a proper contribution, we will honor this in a separate issue with the same body!

#105 For the new issue

@gitcoinbot
Copy link

@rossbulat Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@rossbulat
Copy link

Yes - at work.

@rossbulat
Copy link

rossbulat commented Apr 28, 2019

I have familiarised myself with the current documentation available - completed the Flipper tutorial and structure of smart contract, Ink! wiki, and read the examples in the various abstraction levels.

I would like to create a bare-bones erc721 contract on the "lang" level, that stores intangible tokens, and write the walkthrough outlining the concepts involved:

  • storing token IDs and mapping them to owners
  • the minting process when deploying the contract, which is instantiating an owner to a new token id, and updating the total supply.
  • ownership status, e.g. the owner of the contract is who instantiates it.
  • transferring of tokens, and an additional owner to token count mapping

Other possible areas to explore:

  • locking up tokens that are unable to be transferred, tokenToStatus mapping would suffice

[Update]

Have implemented the above apart from token status - all would be available at this stage in any case. Possible revisit after article write up.

[Next Steps]

Test function followed by article write up

@rossbulat
Copy link

Is it possible to store arrays or vectors in hashmaps? I'd like to use an u64 -> Vec hashmap to store approvals for a particular token ID.

Need some sort of linking from a token_id to a mutable list of accounts to get an approvals record working.

*Posted in ink! Riot chat and awaiting feedback.

@rossbulat
Copy link

rossbulat commented May 2, 2019

Part 1 of tutorial published at: https://medium.com/block-journal/introducing-substrate-smart-contracts-with-ink-d486289e2b59

Github repo of contract: https://github.com/rossbulat/ink-nft

I have reached out in the Ink Riot chat for feedback on the work so far.

[update]

Appears clear that the Medium format and PR format will be very different, the prior being a comprehensive documentation of the whole ink process, whereas the latter removing repetition and gearing content towards new concepts and syntax related to the token, curated to the official community-maintained docs.

@gitcoinbot
Copy link

@rossbulat Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • reminder (3 days)
  • escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

@rossbulat
Copy link

@rossbulat
Copy link

Preparing Post 3 detailing deployment process and Polkadot JS usage:

  • Added an is_approved function for approval test assertions. It is also a public function available to be called
  • Uploaded the latest contract on a Substrate dev chain, functions appear to be working

There is an issue attempting to add u64 values to Balance values. This was giving failures when making calls on the blockchain, but bypassed tests and compilation. I have moved all token counts to u64 for the time being to get a working contract.

I will look into re-introducing Balances and attempt to move u64 to Balance once part 3 is published.

@rossbulat
Copy link

Final part now published (and distributed in Blockchain and Javascript categories) on Medium:
https://medium.com/block-journal/deploying-an-ink-smart-contract-to-a-substrate-chain-f52a2a36efec

@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 300.0 DAI (300.0 USD @ $1.0/DAI) has been submitted by:

  1. @rossbulat
  2. @rossbulat

@Web3Foundation please take a look at the submitted work:


@gitcoinbot
Copy link

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 300.0 DAI (300.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @rossbulat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bounty This issue has a bounty to be won! Bounty-m
Projects
None yet
Development

No branches or pull requests

3 participants