All Projects → vgrichina → web4

vgrichina / web4

Licence: other
Web4 is a new way to distribute decentralized apps. You only need to deploy one smart contract using WebAssembly to deploy whole web app.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to web4

juice-interface
🧃 An app for using the JBX protocol.
Stars: ✭ 132 (+312.5%)
Mutual labels:  web3
wagmi
React Hooks for Ethereum
Stars: ✭ 1,691 (+5184.38%)
Mutual labels:  web3
near-cli
General purpose command line tools for interacting with NEAR Protocol
Stars: ✭ 130 (+306.25%)
Mutual labels:  nearprotocol
eth-sdk
Type-safe, lightweight SDKs for Ethereum smart contracts
Stars: ✭ 283 (+784.38%)
Mutual labels:  web3
TypeChain
🔌 TypeScript bindings for Ethereum smart contracts
Stars: ✭ 1,881 (+5778.13%)
Mutual labels:  web3
exw3
High level Ethereum RPC Client for Elixir
Stars: ✭ 127 (+296.88%)
Mutual labels:  web3
solidity-cli
Compile solidity-code faster, easier and more reliable
Stars: ✭ 49 (+53.13%)
Mutual labels:  web3
augmented-finance-protocol
High-yield lending and low-rate borrowing DeFi protocol
Stars: ✭ 28 (-12.5%)
Mutual labels:  web3
awesome-web3-security
🕶 A high-level overview of the EVM security ecosystem
Stars: ✭ 42 (+31.25%)
Mutual labels:  web3
dApp-Builder
No description or website provided.
Stars: ✭ 108 (+237.5%)
Mutual labels:  web3
quorum.js
Quorum.js is an extension to web3.js providing support for JP Morgan's Quorum API
Stars: ✭ 37 (+15.63%)
Mutual labels:  web3
Astar
The dApp hub for blockchains of the future
Stars: ✭ 533 (+1565.63%)
Mutual labels:  web3
react-nft-gallery
🖼️ React component to display your NFTs as a gallery
Stars: ✭ 50 (+56.25%)
Mutual labels:  web3
ethernal-cli
CLI to sync transactions and Truffle artifacts with Ethernal.
Stars: ✭ 14 (-56.25%)
Mutual labels:  web3
web3
⚡️ Web3 PHP is a supercharged PHP API client that allows you to interact with a generic Ethereum RPC.
Stars: ✭ 609 (+1803.13%)
Mutual labels:  web3
www-react-postgres
A complete template for 2022 focused on around React, Postgres and various web3 integrations. You can use the template to make a website, a web application, a hybrid decentralized web application, or even a DAO.
Stars: ✭ 36 (+12.5%)
Mutual labels:  web3
web3-gear
Proxy Thor's RESTful API to Eth JSON-RPC, to support Remix, Truffle and more.
Stars: ✭ 27 (-15.62%)
Mutual labels:  web3
webflow-nft-components
Connect web3 to Webflow without coding skills
Stars: ✭ 69 (+115.63%)
Mutual labels:  web3
blockhead
Crypto portfolio tracker, DeFi dashboard, NFT viewer and data explorer for the Ethereum/EVM-based blockchain ecosystem and the web 3.0-powered metaverse https://gitcoin.co/grants/2966/blockhead
Stars: ✭ 41 (+28.13%)
Mutual labels:  web3
web3-starter
An opinionated web3 starter for building dApps
Stars: ✭ 67 (+109.38%)
Mutual labels:  web3

web4

Web4 is a new way to distribute decentralized apps. You only need to deploy one smart contract using WebAssembly to host your app HTTP backend, static resources and blockchain logic.

How it works?

There is an HTTP gateway to NEAR blockchain which allows smart contract to handle arbitrary GET requests. Every smart contract on NEAR also gets corresponding API endpoint which can be accessed through regular HTTP requests.

Example contract

export function web4_get(request: Web4Request): Web4Response {
    if (request.path == '/test') {
        // Render HTML with form to submit a message
        return htmlResponse(form({ action: "/web4/contract/guest-book.testnet/addMessage" }, [
            textarea({ name: "text" }),
            button({ name: "submit" }, ["Post"])
        ]));
    }


    if (request.path == '/messages') {
        const getMessagesUrl = '/web4/contract/guest-book.testnet/getMessages';
        // Request preload of dependency URLs
        if (!request.preloads) {
            return preloadUrls([getMessagesUrl]);
        }

        // Render HTML with messages
        return htmlResponse('messages: ' + util.bytesToString(request.preloads.get(getMessagesUrl).body)!);
    }

    if (request.accountId) {
        // User is logged in, we can welcome them
        return htmlResponse('Hello to <b>' +  request.accountId! + '</b> from <code>' + request.path + '</code>');
    }

    // Demonstrate serving content from IPFS
    if (request.path == "/") {
        return bodyUrl('ipfs://bafybeib72whzo2qiore4q6sumdteh6akewakrvukvqmx4n6kk7nwzinpaa/')
    }

    // By default return 404 Not Found
    return status(404);
}

Basically smart contract just needs to implement web4_get method to take in and return data in specific format.

Request

@nearBindgen
class Web4Request {
    accountId: string | null;
    path: string;
    params: Map<string, string>;
    query: Map<string, Array<string>>;
    preloads: Map<string, Web4Response>;
}

Response

@nearBindgen
class Web4Response {
    contentType: string;
    status: u32;
    body: Uint8Array;
    bodyUrl: string;
    preloadUrls: string[] = [];
}

Loading data

You can load any required data in web4_get by returning list of URLs to preload in preloadUrls field.

E.g. contract above preloads /web4/contract/guest-book.testnet/getMessages. This class getMessages view method on guest-book.testnet contract.

After data is preloaded web4_get gets called again with loaded data injected into preloads.

Posting transactions

You can post transaction by making a POST request to corresponding URL.

E.g contract above preloads has form that gets posted to /web4/contract/guest-book.testnet/addMessage URL. This URL submits transacion which calls addMessage method on guest-book.testnet contract.

Note that both JSON and form data are supported. When transaction is processed by server user gets redirected to wallet for signing this transaction.

In future there is a plan to allow sending app-specific key as a cookie to sign limited subset of transactions without confirmation in wallet.

near.page

You can access your deployed smart contract on https://near.page. This is hosted web4 gateway provided to all .near accounts. For now it's free, but in future you might have to pay depending on how much traffic you get.

Every contract gets corresponding domain, e.g. check out https://web4.near.page rendered by web4.near contract.

testnet.page

This works same as near.page but for contracts deployed on testnet. Every account.testnet gets corresponding account.testnet.page domain.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].