Substrate Runtime and Contract Interactions for Polkadot

A Substrate node demonstrating two-way interactions between the runtime and Ink! smart contracts.

Introduction

This Substrate project demonstrates through example how to interact between Substrate runtimes and ink! smart contracts through extrinsic calls and ink! chain extensions.

Motivation

Sharing Substrate runtime functionality with ink! smart contracts is a powerful feature. Chains with unique runtime functionality can create rich application developer ecosystems by exposing choice pieces of their runtime. The inverse interaction of runtime to ink! smart contract calls may be similarly valuable. Runtime logic can query or set important context information at the smart contracts level.

Both of the types of interactions described above are asked about in the context of support, and a recent example demonstrating how to perform these interactions has not been developed.

Prerequisites

If you have not already, it is recommended to go through the ink! smart contracts tutorial or otherwise have written and compiled smart contracts according to the ink! docs. It is also recommended to have some experience with Substrate runtime development.

Ensure you have

  1. Installed Substrate according to the instructions
  2. Run:
rustup component add rust-src --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly

3.   Installed Cargo Contracts

# For Ubuntu or Debian users
sudo apt install binaryen
# For MacOS users
brew install binaryen

cargo install cargo-contract --vers ^0.15 --force --locked

Contract-to-Runtime Interactions

The project demonstrates contract-to-runtime interactions through the use of Chain extensions. Chain Extensions allow a runtime developer to extend runtime functions to smart contracts. In the case of this example, the functions being extended are a custom pallet extrinsic, and the pallet_balances::transfer extrinsic.

See also the rand-extension chain extension code example, which is one example that this project extended.

Runtime-to-Contract Interactions

Runtime-to-contract interactions are enabled through invocations of the pallet-contract's own bare_call method, invoked from a custom pallet extrinsic. The example extrinsic is called call_smart_contract and is meant to demonstrate calling an existing(uploaded and instantiated) smart-contract generically. The caller specifies the account id of the smart contract to be called, the selector of the smart contract function(found in the metadata.json in the compiled contract), and one argument to be passed to the smart contract function.

Build

Node

The cargo run command will perform an initial build. Use the following command to build the node without launching it:

cargo build --release

Smart contracts

To build the included smart contract example, first cd into smart-contracts/example-extension. then run:

cargo +nightly contracts build

Run

Use Rust's native cargo command to build and launch the template node:

cargo run --release -- --dev --tmp

Local Contract Deployment

Once the smart contract is compiled, you may use the hosted Canvas UI. Please follow the Deploy Your Contract guide for specific instructions. This contract uses a default constructor, so there is no need to specify values for its constructor.

You may also use the Polkadotjs Apps UI to upload and instantiate the contract.

Example Usage

Ensure you have uploaded and instantiated the example contract.

Pallet-to-contract

Call the set_value smart contract function from a generic pallet extrinsic

  1. Browse to extrinsics in the Polkadotjs apps UI.
  2. Supply the necessary arguments to instruct our extrinsic to call the smart contract function. Enter the following values in the Submission tab:
    • dest: AccountId of the desired contract.
    • submit the following extrinsic : templateModule
    • selector: 0x00abcdef (note: this denotes the function to call, and is found in smart-contracts/example-extension/target/ink/metadata.json. See more here on the ink! selector macro)
    • arg: some u32 of your choice
    • gasLimit: 10000000000
  3. Submit Transaction -> Sign and Submit.

This extrinsic passed these arguments to the pallet_contracts::bare_call function, which resulted in our set_value smart contract function being called with the new u32 value. This value can now be verified by calling the get_value, and checking whether the new value is returned.

Contract-to-pallet

Call the insert_number extrinsic from the smart contract

  1. Browse to the Execute page in the hosted Canvas UI
  2. Under chain-extension-example, click Execute.
  3. Under Message to Send, select store_in_runtime.
  4. Enter some u32 to be stored.
  5. Ensure send as transaction is selected.
  6. Click Call

The smart contract function is less generic than the extrinsic used above, and so aready knows how to call our custom runtime extrinsic through the chain extension that is set up. You can verify that the contract called the extrinsic by checking the contractEntry storage in the Polkadotjs UI.

Testing

To run the tests for the included example pallet, run cargo test in the root.

Benchmarks

Build node with benchmarks enabled:

cargo build --release --features runtime-benchmarks

Then, to generate the weights into the pallet template's weights.rs file:

./target/release/node-template benchmark \
 --chain dev \
 --pallet=pallet_template \
 --extrinsic='*' \
 --repeat=20 \
 --steps=50 \
 --execution wasm \
 --wasm-execution compiled \
 --raw \
 --output pallets/template/src/weights.rs \
 --template=./weight-template.hbs

Download Details:
Author: paritytech
Source Code: https://github.com/paritytech/Runtime-Contract-Interactions
License: Unlicense License

#blockchain  #polkadot  #smartcontract  #substrate #rust 

What is GEEK

Buddha Community

Substrate Runtime and Contract Interactions for Polkadot

Substrate Runtime and Contract Interactions for Polkadot

A Substrate node demonstrating two-way interactions between the runtime and Ink! smart contracts.

Introduction

This Substrate project demonstrates through example how to interact between Substrate runtimes and ink! smart contracts through extrinsic calls and ink! chain extensions.

Motivation

Sharing Substrate runtime functionality with ink! smart contracts is a powerful feature. Chains with unique runtime functionality can create rich application developer ecosystems by exposing choice pieces of their runtime. The inverse interaction of runtime to ink! smart contract calls may be similarly valuable. Runtime logic can query or set important context information at the smart contracts level.

Both of the types of interactions described above are asked about in the context of support, and a recent example demonstrating how to perform these interactions has not been developed.

Prerequisites

If you have not already, it is recommended to go through the ink! smart contracts tutorial or otherwise have written and compiled smart contracts according to the ink! docs. It is also recommended to have some experience with Substrate runtime development.

Ensure you have

  1. Installed Substrate according to the instructions
  2. Run:
rustup component add rust-src --toolchain nightly
rustup target add wasm32-unknown-unknown --toolchain nightly

3.   Installed Cargo Contracts

# For Ubuntu or Debian users
sudo apt install binaryen
# For MacOS users
brew install binaryen

cargo install cargo-contract --vers ^0.15 --force --locked

Contract-to-Runtime Interactions

The project demonstrates contract-to-runtime interactions through the use of Chain extensions. Chain Extensions allow a runtime developer to extend runtime functions to smart contracts. In the case of this example, the functions being extended are a custom pallet extrinsic, and the pallet_balances::transfer extrinsic.

See also the rand-extension chain extension code example, which is one example that this project extended.

Runtime-to-Contract Interactions

Runtime-to-contract interactions are enabled through invocations of the pallet-contract's own bare_call method, invoked from a custom pallet extrinsic. The example extrinsic is called call_smart_contract and is meant to demonstrate calling an existing(uploaded and instantiated) smart-contract generically. The caller specifies the account id of the smart contract to be called, the selector of the smart contract function(found in the metadata.json in the compiled contract), and one argument to be passed to the smart contract function.

Build

Node

The cargo run command will perform an initial build. Use the following command to build the node without launching it:

cargo build --release

Smart contracts

To build the included smart contract example, first cd into smart-contracts/example-extension. then run:

cargo +nightly contracts build

Run

Use Rust's native cargo command to build and launch the template node:

cargo run --release -- --dev --tmp

Local Contract Deployment

Once the smart contract is compiled, you may use the hosted Canvas UI. Please follow the Deploy Your Contract guide for specific instructions. This contract uses a default constructor, so there is no need to specify values for its constructor.

You may also use the Polkadotjs Apps UI to upload and instantiate the contract.

Example Usage

Ensure you have uploaded and instantiated the example contract.

Pallet-to-contract

Call the set_value smart contract function from a generic pallet extrinsic

  1. Browse to extrinsics in the Polkadotjs apps UI.
  2. Supply the necessary arguments to instruct our extrinsic to call the smart contract function. Enter the following values in the Submission tab:
    • dest: AccountId of the desired contract.
    • submit the following extrinsic : templateModule
    • selector: 0x00abcdef (note: this denotes the function to call, and is found in smart-contracts/example-extension/target/ink/metadata.json. See more here on the ink! selector macro)
    • arg: some u32 of your choice
    • gasLimit: 10000000000
  3. Submit Transaction -> Sign and Submit.

This extrinsic passed these arguments to the pallet_contracts::bare_call function, which resulted in our set_value smart contract function being called with the new u32 value. This value can now be verified by calling the get_value, and checking whether the new value is returned.

Contract-to-pallet

Call the insert_number extrinsic from the smart contract

  1. Browse to the Execute page in the hosted Canvas UI
  2. Under chain-extension-example, click Execute.
  3. Under Message to Send, select store_in_runtime.
  4. Enter some u32 to be stored.
  5. Ensure send as transaction is selected.
  6. Click Call

The smart contract function is less generic than the extrinsic used above, and so aready knows how to call our custom runtime extrinsic through the chain extension that is set up. You can verify that the contract called the extrinsic by checking the contractEntry storage in the Polkadotjs UI.

Testing

To run the tests for the included example pallet, run cargo test in the root.

Benchmarks

Build node with benchmarks enabled:

cargo build --release --features runtime-benchmarks

Then, to generate the weights into the pallet template's weights.rs file:

./target/release/node-template benchmark \
 --chain dev \
 --pallet=pallet_template \
 --extrinsic='*' \
 --repeat=20 \
 --steps=50 \
 --execution wasm \
 --wasm-execution compiled \
 --raw \
 --output pallets/template/src/weights.rs \
 --template=./weight-template.hbs

Download Details:
Author: paritytech
Source Code: https://github.com/paritytech/Runtime-Contract-Interactions
License: Unlicense License

#blockchain  #polkadot  #smartcontract  #substrate #rust 

david harper

1610429951

Hire Smart Contract Developers | Smart Contract Development Company India

What are smart contracts?

Smart contracts is a digital code stored in a blockchain and automatically executes when predetermined terms and conditions are met. In Simple terms, they are programs that run by the setup of the people who developed them.They are designed to facilitate, verify, and execute a digital contract between two parties without the involvement of third parties.

Benefits of Smart Contracts

Greater efficiency and speed
Accuracy and transparency
Trust
Robust Security
Independent verification
Advanced data safety
Distributed ledger
Ease of use
Open source technology
Better flexibility
Easy integration
Improved tractability

Where could smart contracts be used?

Today Smart contracts are used in various platforms such as supply-chain management,cross-border financial transactions,document management,enforceability and more. Here are the Sectors where smart contracts plays a huge role ,

  • Supply chain management
  • Insurance
  • Mortgage loans
  • Financial industry
  • Trade Finance
  • Government
  • IT Sector
  • Records
  • Property ownership
  • Medical Research
  • Voting
  • Peer-to-Peer transactions
  • Product development
  • Stocktaking

Steps For Successful Smart Contract Development

There are a few Important things that you need to consider before you develop a Smart Contract,

Ask Yourself -

  • Do You Need A Smart Contract In Your Project?
  • How can i Implement Smart Contract in My Business?
  • If yes, Find out Your Business Requirements
  • Plan your Requirements
  • Find a Trustworthy Smart Contract Developer
  • Develop , Test Your Smart Contract

Ready to develop your smart contract?

I hope this blog was helpful. We think this is the right time for companies to invest in building a blockchain powered Smart Contracts as Blockchain technology and the ecosystem around it is changing fast. If you’re thinking about building a Smart Contract but not sure where to start, contact us, we’re happy to provide free suggestions about how blockchain’s Smart Contracts may fit into your business.

We Employcoder Leading IT Outsourcing Company with a team of Smart Contract Experts. Hire Smart Contract Developers from us who can code bug-free, scalable, innovative, fully-functional smart contracts for your business and make your business or enterprise eye-catchy & trutworthy among the people in the digital globe.

#hire smart contract developers #smart contract developer #smart contract development #smart contract development services, #smart contract development company, #smart contract programmers

Smart Contract Development Company in Washington

We (Codezeros) are Smart Contract Development Company in Washington. We provide the complete solution for smart contracts like smart contract architecture, design & development, auditing & optimization. We have experienced developers who are expert in developing smart contracts as well as DApp development, pitch deck development, and many other services related to Blockchain Technology.

#smart contract creation #smart contract company #blockchain smart contract #smart contract development #smart contract service provider #smart contract development company

james right

james right

1606811633

Smart Contract Development Company, Hire Smart Contract Developer

With the advent of smart contracts, it has become possible for every business to secure its data and to determine success. It is a decentralized solution that enables you to do many tasks while executing in the most optimal manner. All the entrepreneurs and business owners who have adopted this mechanism have received great results. In order to access this service for your company, you need to team up with a smart contract development company. By doing this, you enhance the power of your solution and make things very seamless.

Smart Contract Development Company

What makes a smart contract a perfect solution for my business?

A smart contract enables you to achieve various feats that seem unfathomable. Also, you get to protect the information of your enterprise in the best possible manner. When you have the power to expand your operation, you should be wise enough to choose the most appropriate solution. There are times when you have to think of something exemplary, it also gives you more about the perfection of the tools. At such a time, you need to have a proper understanding of the features and get things planned in a permanent fashion.

It does not matter which domain you are related to, you get to think about the possible solutions from every domain. Also, you get to manage various other tasks that seem very difficult otherwise. Before you introduce this ledger-based framework in your firm, you need to ready for the outcomes. Every time you come across a decentralized network, you start to pave way for something more dynamic. This gives you the power to react on time and with more efficacy for the long term. Also, you get to review the overall working with a set of proficient developers.

Whether you directly connect with the blockchain or not, your business draws a large number of benefits from the smart contracts. The very core of this solution enables you to create a fitting structure around every company. Also, you get to come with a prominent fix that empowers the proponents of your project. The vision of your investors gets broadened and you get the insights to envision things properly. Every time you do it, you get things worked up properly, you get to maintain a proper flux of funds. In this way, your business gets whatever you want in a very short duration.

How should I develop and implement smart contracts in my business?

By introducing this solution, you prepare your startup to scale up the steps of success. Also, it helps your business overcome all types of issues whether they are temporary in nature or permanent. You need to understand the predilection of every course of action so there is never any obstacle in the way. Moreover, it becomes very easy for your organization to spread its wings because it has befitting tools to support its working. This may also happen in with support structures that ease the expansion of business in a very lesser time.

In every industry, there is a scope of decentralization and you can make it even easier through a string of services. All the crypto-based programs help you get closer to the customers with a reliable method of payment. With this structure, it is possible for every business to do something exceptional. Whether you want it or not, you get to work on many expeditionary campaigns. Also, you help others expand the work and things can get more explicable flawlessly. The working of this solution gives you a high quantum of accuracy in every possible manner.

The prospects of your company can get much better and promising because you have a lesser number of agents deployed. You might find these differences odd, but they can highly impact the development as well as transactions. When you want to touch base with your team or some consultants, you get a better idea about the entire thing. Also, that happens without having you wasting your time. There could be subtle errors in the initial phases of the development of tokens or any other distributed ledger. If decentralization is at the core, you need to have more potential to conceptualize new methods.

How should I find professionals who could develop custom-built smart contracts?

You can certainly get such experts but the search has to be very thorough in nature. Also, the whole thing has to be planned to the hilt and things could be working seamlessly. When you get things working at an impressive pace, you might lack clear objects. Even if there is a projected solution for some problems, you must not employ them before proper rounds of review. This approach gives you satisfactory results in every domain and keeps you one step ahead when it comes to getting what you precisely need.

It is vital that you work with people who have an idea about what’s happening in your firm. By working with such people, you get more certainty in every step sans wasting a large quantum of resources or time. You might be able to find some other options but they all resort to decentralization in the end. The best way to implement this solution is to give more time to every single process through many methods. Also, you need to get things aligned with a proper solution and help the developers give shape to their visions.

Upshot

With the experts of Coin Developer India, it is possible for every startup to get a bespoke smart contract. We make this solution so adaptable that you don’t think about making any changes in the existing structure of the business. Our seasoned professionals help you get over all the problems that you might face in the planning or the execution stage. We make every single task absolutely flawless and help you get familiar with pragmatic fixes that are cost-effective too. If you want to make the most of this blockchain-based service, you must work with us.

Want an efficient smart contract for your business? Associate with us!

Contact Details:
Call and Whatsapp : +91-7014607737
Email: cryptodeveloperjaipur@gmail.com
Telegram : @vipinshar

#smart contract development company #smart contract #mlm smart contract #mlm #smart contract development #hire smart contract developer

aaron silva

aaron silva

1620795530

Polkadot Development | Polkadot Development Services | Polkadot Development Platform |

The Polkadot Blockchain Development has stormed online recently for its efficiency in transacting funds continuously without any loss. Investors can generate more revenue by investing in the Polkadot development protocol. The Polkadot is considered a protocol that initiates transfer across various blockchain platforms for users to experience safe transactions at high speed. Polkadot protocol is trending for its shared multi-chain network that performs multiple transactions simultaneously.

The Polkadot protocol is highly efficient for interconnecting with various platforms for better transactions. It eliminates the need for intermediaries to overcome traditional banking systems since each transaction is executed one by one since it is tedious for users. The Polkadot protocol inherited with parachain enables users to experience the power of multiprocessing for parallel transactions. The integration of Polkadot protocol enables high security over a complete network for communicating better with other parachains using XCMP.

Reasons to invest in Polkadot blockchain development platform :

  • The Polkadot protocol is inherited with parachain for experiencing various services like identity management, service for finance on several blockchains. The Polkadot Protocol is entirely decentralized, scalable and securitized for efficient multi-transactions.
  • The speed of transactions is increased in Blockchains for integrating Polkadot protocol, and entire data is processed and supported for increasing the volume of trade. The Polkadot protocol comes with high-end security systems that prevent various hacks and vulnerable activities.
  • It has improved the user interface for better interaction over blockchain for efficient transactions. It enables the exchange of data on various platforms without any loss in the transaction. The Polkadot network with parachain enables creating new blockchains or parachains connected with the main Polkadot chain.
  • Parachains on the Polkadot network can adopt a suitable governance model for accessing pre-built modules implemented on various on-chain governance systems. The on-chain governance maintains significant transparency over para communities.
  • It is highly interoperable on the Polkadot network for experiencing complete control over their fund transactions. It enables users to engage with continuous trade with other parachains and external networks. The Polkadots cross-chain model enables traders to exchange tokens and verify credentials.
  • The Polkadot protocol is highly flexible in that each parachain can have a unique design, token and governance process for optimized use cases. The parachains are specialized in several blockchains to experience a wide range of varieties such as service for finance and identity management.

The Polkadot blockchain development is ruling the entire blockchain world with unique features that benefit users to experience fast transactions. The Polkadot network is highly scalable for transactions to spread out for it to be processed parallely over a specialized layer of blockchain. The investors can reach out to Infinite Block Tech for gaining assistance towards Polkadot development on the blockchain platform cost-effectively.

#polkadot development #polkadot development services #polkadot development platform #polkadot blockchain development