Calling a Dumb Contract

To call a Dumb Contract you send a specially formatted Ethereum transaction to the Facet Inbox Address (x00000000000000000000000000000000000face7). Specifically, you must encode your request as a dataURI using the Ethscriptions protocol.

Here is an example of a simple ERC20 mint transaction:

application/vnd.facet.tx;rule=esip6,{
    "op": "call",
    "data": {
        "to": "0x1234eccd1000898941bc19d3f356322783941fa6",
        "function": "mint",
        "args": {
            "amount": "1000000000000000000000"
        }
    }
}

And here is a more complicated UniswapV2-style swap:

application/vnd.facet.tx;rule=esip6,{
    "to": "0xcce2f1662d48863d57a973b95e1c49b485493511",
    "data": {
        "function": "swapExactTokensForTokens",
        "args": {
            "amountIn": "1000000000000000",
            "amountOutMin": "655554569872882432",
            "path": [
                "0xbff0ad0b619402df413b3f3420138b6db4d88ce8",
                "0xc0d04bb0beefc79159454b8cf8d7fc5e11f5d28a"
            ],
            "to": "0x9927e3e2e789497312c28D539D016b693CB2b622",
            "deadline": "1000000000000000000"
        }
    }
}

The Facet VM observes dataURIs with this mimetype being sent to the inbox address, and when it sees one it interprets it according to the logic in the contract at the provided address.

Note: though the "to" looks like an Ethereum address it is only meaningful if you're using the Facet Protocol.

Transaction Receipts

Just like on "normal Ethereum" you cannot know the result of your transaction synchronously. Instead you must wait and get a transaction receipt. Transaction receipts are available from the VM API and look like this:

{
    "transaction_hash": "0x7a262dacc8b1ec256eac19dd38cfbc512431af8f4ad3738e5442e71a4aecd6a6",
    "status": "success",
    "function": "mint",
    "args": {
        "amount": "1000000000000000000000"
    },
    "logs": [
        {
            "data": {
                "to": "0xc2172a6315c1d7f6855768f843c420ebb36eda97",
                "from": "0x0000000000000000000000000000000000000000",
                "amount": "1000000000000000000000"
            },
            "event": "Transfer",
            "contractAddress": "0x1234eccd1000898941bc19d3f356322783941fa6",
            "contractType": "PublicMintERC20"
        }
    ],
    "block_timestamp": 1700426346,
    "error": null,
    "block_number": 8,
    "transaction_index": 8,
    "block_blockhash": "0x7b22cad96a23a2df7e4284fc7a19113b4461245537f6b3f404ce4b0b9dbe3a63",
    "return_value": null,
    "call_type": "call",
    "to": "0x1234eccd1000898941bc19d3f356322783941fa6",
    "from": "0xc2172a6315c1d7f6855768f843c420ebb36eda97"
}

They include the same information as an Ethereum transaction receipt, such as status, event logs, etc.

Note that while this receipt refers to the same transaction_hash as the actual Ethereum transaction you used to mint, it is only meaningful if you are following the Facet Protocol. When this transaction appears in Etherscan or MetaMask, you will not see any of this information (until they start supporting Facet).

In particular, MetaMask and Etherscan will always report your Facet transactions as successful so you'll need to use Facet receipts to figure out the truth.

Last updated