Skip to content

Blended App template SDK for Solidity and Rust WASM contracts with Javascript ethers.js test scripts.

Notifications You must be signed in to change notification settings

fluentlabs-xyz/blended-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blended-sdk

Blended App template SDK for Solidity and Rust WASM contracts with Javascript ethers.js test scripts.

Documentation

https://docs.fluent.xyz/developer-guides/building-a-blended-app/

Deploy Blended Contracts

Step 1 - Deploy Rust Contract

Change directory to rust contract folder

cd rust

Compile Rust contract for WASM binary

gblend build rust -r

Deploy Rust contract with WASM binary

gblend deploy \
--private-key $devTestnetPrivateKey \
--dev lib.wasm \
--gas-limit 3000000

Copy this deployed Rust contract address, since this will be used for the Solidity contract communication.

⚠️ Note: to update Rust crate fluentbase-sdk if there are issues: ⚠️

cargo clean
cargo update -p fluentbase-sdk

Step 2 - Deploy Solidity Contract

Switch back to the root of this repo, then switch to the solidity contract folder

cd ../
cd solidity

Deploy the Solidity contract with the Rust contract address with the Forge flag which defines path to constructor input text file --constructor-args-path

forge create src/FluentSdkRustTypesTest.sol:FluentSdkRustTypesTest \
--constructor-args-path src/deployConstructor/FluentSdkRustTypesTest.txt \
--private-key $devTestnetPrivateKey \
--rpc-url https://rpc.dev.gblend.xyz/ \
--broadcast \
--verify \
--verifier blockscout \
--verifier-url https://blockscout.dev.gblend.xyz/api/

Foundry test fork deployed contracts on Fluent testnet

forge coverage --fork-url https://rpc.dev.gblend.xyz/

Step 3 - Test Javascript ethers.js Interaction

Switch back to the root of this repo, then switch to the javascript folder

cd ../
cd javascript

Install packages such as ethers.js with package.json with

npm i

Run the ethers.js test script to have the Solidity contract call the Rust contract

node solidity.js

Run the ethers.js test script to call the Rust contract directly (using Solidity interface ABI)

node rust.js

This ethers.js Javascript example can be modified from node.js to a frontend application for users to interact with.

About

Blended App template SDK for Solidity and Rust WASM contracts with Javascript ethers.js test scripts.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published