Skip to content
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

🔥 Add readme #9

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License

Copyright (c) 2023-present Coinbase

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 change: 1 addition & 0 deletions README.md
102 changes: 102 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<br/>

<p align="center">
<h1>Bytecode Caller</h1>
</a>
</p>

<p align="center">
Simple yet powerful multicall successor
<p>

<br>

## About

- 💡 **Lightweight** - 0 external dependencies
- 🧹 **Clean use** - create your queries with a smart-contract language of choice
- ⛓️ **Interdependent queries** - get data dependent on other call results in a single call
- 🚀 **No limits** - works on every EVM based chain, on every block in time

## Overview

Contract that you want to read:

```solidity
contract Array {
uint256[] arr;

constructor() {
arr.push(1);
arr.push(2);
arr.push(3);
}

function get(uint256 _index) public view returns (uint256) {
return arr[_index];
}

function length() public view returns (uint256) {
return arr.length;
}
}
```

Query contract to use:

```solidity
contract ArrayReader {
function read(IArray array) public view returns (uint256[] memory) {
uint256[] memory result = new uint256[](array.length());
for (uint256 i = 0; i < array.length(); i++) {
result[i] = array.get(i);
}
return result;
}
}
```

### Use with ethers 6

```typescript
const ArrayReaderInterface = new Interface([
'function read(address) view returns (uint256[])',
])

const callData = ArrayReaderInterface.encodeFunctionData('read', [Array.address])
const bytecodeCallerData = createDataForBytecode(ArrayReader.bytecode, callData)

const result = await provider.call({
to: null,
data: bytecodeCallerData,
})

const decodedResult = ArrayReaderInterface.decodeFunctionResult('read', result)
```

### Use with viem

```typescript
const abi = parseAbi(['function read(address) external view returns (uint256[])'])
const callData = encodeFunctionData({
abi,
functionName: 'read',
args: [client.contracts.Array.address],
})

const byteCodeCallerData = createDataForBytecode(contract.bytecode, callData)
const result = await client.call({
to: null,
data: byteCodeCallerData,
})

const decodedResult = decodeFunctionResult({
abi,
functionName: 'read',
data: result.data!,
})
```

## License

[MIT](LICENSE.md) License
Loading