GithubHelp home page GithubHelp logo

t33m-n0-5l33p / custom-dashboard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thirdweb-example/custom-dashboard

1.0 0.0 0.0 759 KB

Use thirdweb's sdk.deployer to deploy any pre-built contract dynamically with no private keys!

Home Page: https://custom-dashboard.thirdweb-example.com

License: Other

JavaScript 0.54% TypeScript 50.76% CSS 48.70%

custom-dashboard's Introduction

Custom Dashboard

This example demonstrates the thirdweb SDK's capability to deploy any of our pre-built smart contracts!

We use the ContractDeployer class and the deployBuiltInContract function to deploy the contracts, and use the sdk.getContractList to view all the contracts we deployed so far!

This example can be utilized in projects that you want users to deploy smart contracts via your application dynamically, rather than the thirdweb dashboard.

Tools

Using This Repo

  • Create a project using this example by running:
npx thirdweb create --template custom-dashboard

Guide

We'll explore the details of how this repository works below.

Viewing Deployed Contracts

On the index.tsx page, we use the .getContractList function to view all the contracts we deployed so far:

// Get the signer of the currently connected wallet
const signer = useSigner();

// Instantiate the SDK with the signer
const thirdweb = new ThirdwebSDK(signer);

// Fetch the contracts for this address and set them in state using the SDK
thirdweb.getContractList(address).then((contracts) => {
  // set the contracts in state
  setExistingContracts(contracts);
});

Deploying Contracts

On the deploy.tsx page, we use the [.deployBuiltInContract] function to deploy a contract, which is a generic function to deploy any pre-built contract.

Typically, you know which contract you want your users to deploy, so it's more helpful to use one of the methods exposed on the ContractDeployer class.

Such as:

On each of these pages, you can find code examples to help you deploy the contract.

To make the code generic for this example project, we used the internal function from the SDK deployBuiltInContract, which calls each of these functions under the hood, depending on which contract you pass in as a parameter.

Here's how it looks:

const signer = useSigner();

const thirdweb = new ThirdwebSDK(signer);

const contractAddress = await thirdweb.deployer.deployBuiltInContract(
  contractSelected,
  {
    name: `My ${contractSelected}`,
    primary_sale_recipient: address,
    voting_token_address: address,
    description: `My awesome ${contractSelected} contract`,
    // Recipients are required when trying to deploy a split contract
    recipients: [
      {
        address,
        sharesBps: 100 * 100,
      },
    ],
  }
);

Join our Discord!

For any questions, suggestions, join our discord at https://discord.gg/thirdweb.

custom-dashboard's People

Contributors

avneesh0612 avatar hashbrownkazang avatar jarrodwatts avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.