Skip to content

Commit

Permalink
Merge branch 'master' into nakul/feat_contract_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nud3l authored Dec 21, 2023
2 parents 6d14140 + 93c9a9c commit 8566870
Show file tree
Hide file tree
Showing 69 changed files with 4,651 additions and 987 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
[submodule "lib/bitcoin-spv"]
path = lib/bitcoin-spv
url = https://github.com/bob-collective/bitcoin-spv
[submodule "lib/account-abstraction"]
path = lib/account-abstraction
url = https://github.com/eth-infinitism/account-abstraction
[submodule "lib/gsn"]
path = lib/gsn
url = https://github.com/opengsn/gsn
105 changes: 105 additions & 0 deletions deploy-all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Steps to deploy all required contracts

The steps below use various variables. In the latest deployments, these were set to:

```sh
export PRIVATE_KEY=<private-key-of-0x09Af4E864b84706fbCFE8679BF696e8c0B472201>
export ENTRYPOINT_ADDRESS=0x8b57d6ec08e09078Db50F265729440713E024C6a
export RELAY_ADDRESS=0x7B72bA8c9f3Ba4A94E6d8fA07c822228034d2e61
export ERC_ADDRESS=0x2868d708e442A6a940670d26100036d426F1e16b # wbtc
export ORACLE_ADDRESS=0x9AfBdFF0434acD4F325e3c35b739a62365099BCE # wbtc oracle
export ERC_DECIMALS=8
export FORWARDER_ADDRESS=0xFd0042D3d05c82acb937aC86F23247a2D77785f2
export RPC_URL=https://l2-puff-bob-jznbxtoq7h.t.conduit.xyz
export VERIFIER_URL='https://explorerl2new-puff-bob-jznbxtoq7h.t.conduit.xyz/api?'
export OWNER_ADDRESS='0x09Af4E864b84706fbCFE8679BF696e8c0B472201'
export BITCOIN_PRICE=3761500000000
```

## GSN standard infrastructure

Use the `gsn` tool to deploy the standard gsn infrasturcture. I believe the beta.10 version was used for the most recent deployment.

```sh
npx gsn deploy --network https://l2-puff-bob-jznbxtoq7h.t.conduit.xyz --privateKeyHex $PRIVATE_KEY --testToken --burnAddress 0x09Af4E864b84706fbCFE8679BF696e8c0B472201 --devAddress 0x09Af4E864b84706fbCFE8679BF696e8c0B472201
# Output:
#
# info: Setting minimum stake of 1 TestWeth on Hub
# info: Setting minimum stake of 0.000000000000000001 wnTok (0x14d8...446)
# Deployed GSN to network: https://l2-puff-bob-jznbxtoq7h.t.conduit.xyz
#
# RelayHub: 0x7B72bA8c9f3Ba4A94E6d8fA07c822228034d2e61
# RelayRegistrar: 0x6Ff484e7530C4ab20aEa1B19E5b33FE7415dB9Fd
# StakeManager: 0xE5a27E68bE43A69dfd3A26be7DaE9Feac236C826
# Penalizer: 0x1C36129916E3EA2ACcD516Ae92C8f91deF7c4146
# Forwarder: 0xFd0042D3d05c82acb937aC86F23247a2D77785f2
# TestToken (test only): 0x14d8b98c9f685FB3e13F5BB24B8016BD709A5446
# Paymaster (Default): 0x0000000000000000000000000000000000000000
```

## Miscelaneous deployments

### Tokens

```sh
# wbtc oracle: 0x9AfBdFF0434acD4F325e3c35b739a62365099BCE
# wbtc: 0x2868d708e442A6a940670d26100036d426F1e16b

export ERC_PRICE=$BITCOIN_PRICE && forge script script/TestingWbtc.sol --rpc-url=$RPC_URL --broadcast --verify --verifier=blockscout --verifier-url=$VERIFIER_URL
```

### Marketplace
```sh
# btc marketplace: 0x0cfd830a59e94b6957609fFd85CcDD742C521F34
# marketplace: 0x69F14d077Fcc88e70F4737a48fE09C0FD32506FB
# dummy relay: 0x077c5ed60fABb260784891786c6573373fDa8A3E
forge script script/Marketplace.sol --rpc-url=$RPC_URL --broadcast --verify --verifier blockscout --verifier-url=$VERIFIER_URL
```

### GSN Paymaster

```sh
# paymaster: 0x25Aa86d188E37A47dd2011535534E53Cf994559d
forge script script/OracleTokenPaymaster.sol --rpc-url=$RPC_URL --broadcast --verify --verifier=blockscout --verifier-url=$VERIFIER_URL
```

# ERC-4337

## Entrypoint

Clone [our fork](https://github.com/bob-collective/account-abstraction/tree/sepolia-bob) of the account-abstraction repo, set the `PRIVATE_KEY` environment variable, and deploy:

```sh
yarn hardhat deploy --network sepoliaBob
```

The command above will output an address. Specify that address to verify the contract:
```sh
yarn hardhat verify --network sepoliaBob 0x8b57d6ec08e09078Db50F265729440713E024C6a
```


## Deterministic deployer

Clone [our fork](https://github.com/bob-collective/deterministic-deployment-proxy) of deterministic-deployment-proxy. This contract is used by the account abstraction wallets to deploy wallets to deterministic addresses. Edit the `chainIdNum` in the `scripts/compile.ts` file and then run `ts-node scripts/compile.ts`. Check the output as follows:


```sh
❯ cat output/deployment.json
{
"gasPrice": 100000000000,
"gasLimit": 100000,
"signerAddress": "3760847f009a294e07309e80514ac0a7ee194269",
"transaction": "f8a78085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3820101a02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",
"address": "250f60877f1397002ae79528b218be925b6b4c79"
}
```

Then, in the front-end code, update `DeterministicDeployer.ts` using the values from above. See https://github.com/bob-collective/demo-account-abstraction-transfer/pull/4 for an example.



# Dummy oracle: 0x31b36BB047f6D5e3B49E95c4c99Cce4591e82E3f
# Dummy oracle: 0x6669d0C53fCf30c00F5AbE5a32cFa2EaD2bc2d5a
# Paymaster: 0x777FA19ea9e771018678161ABf2f1E2879D3cA6C
# forge script script/AATokenPaymaster.sol --rpc-url=$RPC_URL --broadcast --verify --verifier blockscout --verifier-url=$VERIFIER_URL
2 changes: 1 addition & 1 deletion docs/docs/build/contracts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Deterministic deployer: `0x250f60877f1397002ae79528b218be925b6b4c79`
- WBTC Paymaster: `0x777FA19ea9e771018678161ABf2f1E2879D3cA6C`

### Meta Tranactions (OpenGSN)
### Meta Transactions (OpenGSN)

- RelayHub: `0x7B72bA8c9f3Ba4A94E6d8fA07c822228034d2e61`
- RelayRegistrar: `0x6Ff484e7530C4ab20aEa1B19E5b33FE7415dB9Fd`
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/build/examples/brc20-octopus/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The BRC20 Octopus example demonstrates how the BOB SDK can be used to inscribe Ordinals, both text and BRC20s are supported.

The demo uses the [UniSat Wallet](https://docs.unisat.io/dev/unisat-wallet-api) to interact with the Bitcoin network and sign transactions.
The demo uses the [UniSat Wallet](https://docs.unisat.io/dev/unisat-developer-service/unisat-wallet) to interact with the Bitcoin network and sign transactions.

:::info Example Code

Expand All @@ -16,6 +16,6 @@ With the app (and server) running locally you should see the following page:

:::tip BOB SDK

To add this functionality to your app use the `inscribeText` function and provide a custom `RemoteSigner` implementation for your wallet. This needs to be able to send Bitcoin to the commit address and sign the PSBT of the reveal transaction. Check the test in [`sdk/test/ordinals.test.ts`](https://github.com/bob-collective/bob/blob/master/sdk/test/ordinals.test.ts) for an example implementation.
To add this functionality to your app use the `inscribeData` function and provide a custom `RemoteSigner` implementation for your wallet. This needs to be able to send Bitcoin to the commit address and sign the PSBT of the reveal transaction. Check the test in [`sdk/test/ordinals.test.ts`](https://github.com/bob-collective/bob/blob/master/sdk/test/ordinals.test.ts) for an example implementation.

:::
8 changes: 7 additions & 1 deletion docs/docs/build/examples/unified-assets-tracker/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Unified EVM and Bitcoin Assets with the MetaMask Bitcoin Snap Extension

This app allows tracking and transfering both EVM and Bitcoin assets in a unified manner using the [Zion MetaMask Bitcoin snap extension](https://snaps.metamask.io/snap/npm/btcsnap/).
:::info MetaMask Flask

This demo uses [MetaMask Snaps](https://metamask.io/snaps/) and can only be used with [MetaMask Flask](https://metamask.io/flask/). MetaMask Snaps are not currently supported on mobile wallets, so this demo will only run in the desktop version of Chrome or Firefox.

:::

This app allows tracking and transferring both EVM and Bitcoin assets in a unified manner using the [BOB MetaMask snap extension](https://github.com/bob-collective/btcsnap).

![image](https://github.com/bob-collective/demo-unified-assets-tracker/assets/47864599/c13783e0-5cbe-4a30-89d7-3c12a39cb408)

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/build/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is alpha-stage software. We love to work closely with you to make BOB usefu

## Examples

- [P2P Swap BTC and ERC20](/docs/build/examples/btc-swap/): Learn how to build a P2P Bitcoin marketplace on BOB using a BTC light client to eliminate trusted thrid parties.
- [P2P Swap BTC and ERC20](/docs/build/examples/btc-swap/): Learn how to build a P2P Bitcoin marketplace on BOB using a BTC light client to eliminate trusted third parties.
- [Inscribing Ordinals With Unisat Wallet](/docs/build/examples/brc20-octopus/): Learn how to inscribe Ordinals (text, BRC20s, ...) with the UniSat wallet.
- [Use MetaMask to Inscribe and Transfer Ordinals](/docs/build/examples/metamask-ordinals/): Learn how to inscribe Ordinals (text, BRC20s, ...) with the UniSat wallet.
- [Unify BTC and EVM Assets](/docs/build/examples/unified-assets-tracker/): Learn how to unify BTC and EVM assets with a single wallet by using MetaMask snaps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ Before the first user operation can be made, the paymaster smart contract has to

## Limitations

Given that ERC-4337 is still relatively new, there is not a lot of support for this standard available yet on "traditiona" crypto wallets like MetaMask, Ledger, and others.
Given that ERC-4337 is still relatively new, there is not a lot of support for this standard available yet on "traditional" crypto wallets like MetaMask, Ledger, and others.

## Opportunities

There are a interesting use cases that account abstraction enables being pushed by several team. Some places to look for inspiration:

- [Privy](https://docs.privy.io/): Privy allows users to chose from traditional crypto wallets and social logins to create accounts.
- [Safe](https://docs.safe.global/getting-started/readme): Safe allows complex multi-sig setups, simple authetication, and onramping.
- [Safe](https://docs.safe.global/getting-started/readme): Safe allows complex multi-sig setups, simple authentication, and onramping.
- [Pimlico](https://pimlico.notion.site/Product-Directory-5d92fe60243b4c5aac6650de390e7cb3): Pimlico tracks several products around account abstraction and it is worthwhile checking out the rapid and new developments in this space.

## Local development
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/build/how-to/ordinals.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Check out the [documentation](../examples/metamask-ordinals/), the [BOB MetaMask
- [Unisat](https://unisat.io/download) (Browser)

### Inscribing data
If you're developing an app with Javascript or Typescript you can use the BOB SDK to create the commit and reveal transactions required to inscribe data to an ordinal. Refer to the `inscribeText` function and provide a custom `RemoteSigner` implementation for your wallet. The test in [`sdk/test/ordinals.test.ts`](https://github.com/bob-collective/bob/blob/master/sdk/test/ordinals.test.ts) provides an example implementation using [`bitcoinjs-lib`](https://github.com/bitcoinjs/bitcoinjs-lib) and [`tiny-secp256k1`](https://github.com/bitcoinjs/tiny-secp256k1).
If you're developing an app with Javascript or Typescript you can use the BOB SDK to create the commit and reveal transactions required to inscribe data to an ordinal. Refer to the `inscribeData` function and provide a custom `RemoteSigner` implementation for your wallet. The test in [`sdk/test/ordinals.test.ts`](https://github.com/bob-collective/bob/blob/master/sdk/test/ordinals.test.ts) provides an example implementation using [`bitcoinjs-lib`](https://github.com/bitcoinjs/bitcoinjs-lib) and [`tiny-secp256k1`](https://github.com/bitcoinjs/tiny-secp256k1).

#### Using an external service
There are other ways to create inscriptions, the following two are advised:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/build/how-to/relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This approach is still experimental and not yet fully supported by the SDK. To c

### Checking Output Amounts

To extract the output amount `BitcoinTx.getTxOutputValue` can be be used to extract the amount transfered to a specific address. See [`test/BitcoinTx.t.sol`](https://github.com/bob-collective/bob/blob/master/test/BitcoinTx.t.sol) for an example. The address is the `keccak256` hash of the expected `scriptPubKey`.
To extract the output amount `BitcoinTx.getTxOutputValue` can be be used to extract the amount transferred to a specific address. See [`test/BitcoinTx.t.sol`](https://github.com/bob-collective/bob/blob/master/test/BitcoinTx.t.sol) for an example. The address is the `keccak256` hash of the expected `scriptPubKey`.

:::tip BOB SDK

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/build/tools/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sidebar_position: 2

## Ordinals

### [UniSat API](https://docs.unisat.io/dev/open-api)
### [UniSat API](https://docs.unisat.io/dev/unisat-developer-service)

UniSat Open-API is open to community developers, allowing you to explore the world of Bitcoin and ordinals.

Getting an API key: [Contact the team](https://docs.unisat.io/dev/open-api#getting-an-api-key).
Getting an API key: [Contact the team](https://docs.unisat.io/dev/unisat-developer-service#getting-an-api-key).
4 changes: 2 additions & 2 deletions docs/docs/drafts/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The core things that need building is:

We already have key parts of the runtime built and live:

- Basic DeFi functions with a Uniswap v2, Curve v1, and Compound v2 are natively availabl ein the runtime.
- Basic DeFi functions with a Uniswap v2, Curve v1, and Compound v2 are natively available in the runtime.
- Most decentralized Bitcoin bridge is live since August 2022. This includes a Bitcoin light client that is capable of trustless transaction inclusion proofs of Bitcoin transaction.
- Access to native USDT, USDC (soon), and cross-chain assets via Wormhole (soon).
- Fully decentralized governance with upgradable runtimes.
Expand All @@ -40,7 +40,7 @@ We already have key parts of the runtime built and live:
- Hackathon templates
- OP Stack compatibility
- Data availability layer support/relayer
- Sequencing implmentation
- Sequencing implementation
- Execution layer
- Settlement layer
- Bitcoin compatibility
Expand Down
Loading

0 comments on commit 8566870

Please sign in to comment.