-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate development workflow of contract #52
Comments
Any update on the investigation of contract development workflow, tools, paradigms, and tricks? |
Integrate development workflow of contract1 Overview
2 Examples2.1 CompileUsing capsule: The
Where the
2.2 Deploy & UpgradeThere are several ways to deploy or upgrade contracts. capsuledeployWhen running Info: Info: There seems to be no way to deploy multiple contracts under the same Steps for using the capsule deploy contract:
After a successful deployment, a json file with a timestamp as the name is added to the migrattions folder, recording the contract's transaction information upgradeWhen upgrading the contract,
ckb-clireference: nervosnetwork/ckb-cli#515 deploy
upgradewrite your own tools using sdk
deploy & upgrade contract with lumos example: import { readFileSync } from "fs";
import {
generateDeployWithTypeIdTx,
generateUpgradeTypeIdDataTx,
} from "@ckb-lumos/common-scripts/lib/deploy";
import { Script, Indexer, RPC, hd, Address, commons } from "@ckb-lumos/lumos";
import { sealTransaction } from "@ckb-lumos/helpers";
const CKB_RPC_URL = "https://testnet.ckb.dev/rpc";
const CKB_INDEXER_URL = "https://testnet.ckb.dev/indexer";
const rpc = new RPC(CKB_RPC_URL);
const indexer = new Indexer(CKB_INDEXER_URL, CKB_RPC_URL);
// for example
const DEPLOYER_PK = '0x.....'
async function deploy(
deployer: Address,
contractBinPath: string,
) {
const contractBin = readFileSync(contractBinPath);
let { txSkeleton } = await generateDeployWithTypeIdTx({
cellProvider: indexer,
fromInfo: deployer,
scriptBinary: contractBin,
});
txSkeleton = await commons.common.payFee(txSkeleton, [deployer], 1000);
// sign transaction
txSkeleton = commons.common.prepareSigningEntries(txSkeleton);
const message = txSkeleton.get("signingEntries").get(0)?.message;
const Sig = hd.key.signRecoverable(message!, DEPLOYER_PK);
const tx = sealTransaction(txSkeleton, [Sig]);
// send transaction
const txHash = await rpc.sendTransaction(tx, "passthrough");
}
// upgrade
async function upgrade(
deployer: Address,
typeId: Script,
contractBinPath: string,
) {
const contractBin = readFileSync(contractBinPath);
let { txSkeleton } = await generateUpgradeTypeIdDataTx({
typeId: typeId,
cellProvider: indexer,
fromInfo: deployer,
scriptBinary: contractBin,
});
txSkeleton = await commons.common.payFee(txSkeleton, [deployer], 1000);
// sign transaction
txSkeleton = commons.common.prepareSigningEntries(txSkeleton);
const message = txSkeleton.get("signingEntries").get(0)?.message;
const Sig = hd.key.signRecoverable(message!, DEPLOYER_PK);
const tx = sealTransaction(txSkeleton, [Sig]);
// send transaction
const txHash = await rpc.sendTransaction(tx, "passthrough");
} 3 How to Integrate Contract to KuaiAdd Subcommand
|
1 Overview
Language
C, Rust
Compile
You can use any tool you like to compile the contract. However, capsule can make deployment easier.
Deploy & Upgrade
You can use tools such as capsule and ckb-cli to deploy / upgrade the contract. You can also write your own tools using sdk such as lumos, ckb-sdk-rust, etc.
2 Examples
2.1 Compile
Using capsule:
2.2 Deploy & Upgrade
There are several ways to deploy or upgrade contracts.
capsule [todo]
deploy
upgrade
ckb-cli [todo]
deploy
upgrade
write your own tools using sdk
using lumos
https://github.com/felicityin/ckbox/blob/main/examples/contract-client/contract.ts
using ckb-sdk-rust
https://github.com/felicityin/ckb-contract-rs
The text was updated successfully, but these errors were encountered: