{"id":19145394,"url":"https://github.com/paradigmxyz/forge-alphanet","last_synced_at":"2025-06-13T21:37:39.266Z","repository":{"id":235569730,"uuid":"783248259","full_name":"paradigmxyz/forge-alphanet","owner":"paradigmxyz","description":"Foundry tools for interfacing with Reth Alphanet's bleeding-edge EVM extensions.","archived":false,"fork":false,"pushed_at":"2024-10-09T10:56:09.000Z","size":69,"stargazers_count":46,"open_issues_count":2,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-11T21:51:03.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paradigmxyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-07T11:05:21.000Z","updated_at":"2024-11-16T12:56:21.000Z","dependencies_parsed_at":"2024-11-09T07:51:34.221Z","dependency_job_id":null,"html_url":"https://github.com/paradigmxyz/forge-alphanet","commit_stats":null,"previous_names":["paradigmxyz/forge-alphanet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradigmxyz%2Fforge-alphanet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradigmxyz%2Fforge-alphanet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradigmxyz%2Fforge-alphanet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paradigmxyz%2Fforge-alphanet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paradigmxyz","download_url":"https://codeload.github.com/paradigmxyz/forge-alphanet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230431100,"owners_count":18224655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T07:40:00.711Z","updated_at":"2025-06-13T21:37:39.251Z","avatar_url":"https://github.com/paradigmxyz.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# forge-alphanet\n\nSet of solidity utilities to ease deployment and usage of applications on\n[AlphaNet].\n\n## EOF support\n\nForge has built-in support for [EOF]. This is done by using solc binary from [forge-eof] repository distributed as a docker image. To be able to compile contracts you will need to have [Docker] installed. Once it's installed, and forge version is up to date (run `foundryup` if needed), you can add `--eof` flag to any forge command to try out EOF compilation.\n\nThis repository is configured to compile contracts for [EOF] by default by setting `eof = true` in the `foundry.toml` file.\n\n## EIP-7702 support\n\n### cast\n\n`cast send` accepts a `--auth` argument which can accept either an address or an encoded authorization which can be obtained through `cast wallet sign-auth`:\n\n```shell\n# sign delegation via delegator-pk and broadcast via sender-pk\ncast send $(cast az) --private-key \u003csender-pk\u003e --auth $(cast wallet sign-auth \u003caddress\u003e --private-key \u003cdelegator-pk\u003e)\n```\n\n### forge\n\nTo test EIP-7702 features in forge tests, you can use `vm.etch` cheatcode:\n```solidity\nimport {Test} from \"forge-std/Test.sol\";\nimport {P256Delegation} from \"../src/P256Delegation.sol\";\n\ncontract DelegationTest is Test {\n    function test() public {\n        P256Delegation delegation = new P256Delegation();\n        // this sets ALICE's EOA code to the deployed contract code\n        vm.etch(ALICE, address(delegation).code);\n    }\n}\n```\n\n## BLS library\n\nFunctions and data structures to allow calling each of the BLS precompiles defined in [EIP-2537]\nwithout the low level details.\n\nWe've prepared a simple test demonstrating BLS signing and verification in [test/BLS.t.sol](test/BLS.t.sol).\n\n## Secp256r1 library\n\nProvides functionality to call the `P256VERIFY` precompile defined in [EIP-7212]\nto verify Secp256r1 signatures.\n\nIt can be used in a solidity smart contract like this:\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.25;\n\nimport {Secp256r1} from \"/path/to/forge-alphanet/src/sign/Secp256r1.sol\";\n\ncontract Secp256r1Example {\n    event OperationResult(bool success);\n\n    // Function to perform a Secp256r1 signature verification with error handling\n    function performP256Verify(bytes32 digest, bytes32 r, bytes32 s, uint256 publicKeyX, uint256 publicKeyY) public {\n        bool result = Secp256r1.verify(digest, r, s, publicKeyX, publicKeyY);\n        emit OperationResult(result);\n    }\n}\n```\n\nSee an example of how to test secp256r1 signatures with foundry cheatcodes in [test/P256.t.sol](test/P256.t.sol).\n\n## Account controlled by a P256 key\n\nWith EIP-7702 and EIP-7212 it is possible to delegate control over an EOA to a P256 key. This has large potential for UX improvement as P256 keys are adopted by commonly used protocols like [Apple Secure Enclave] and [WebAuthn].\n\nWe are demonstrating a simple implementation of an account that can be controlled by a P256 key. EOAs can delegate to this contract and configure an authorized P256 key, which can then be used to perform actions on behalf of the EOA.\n\nTo run the commands below, you will need to have [Python] and `openssl` CLI tool installed.\n\n1. Run anvil in Alphanet mode to enable support for EIP-7702 and P256 precompile:\n```shell\nanvil --alphanet\n```\nWe will be using dev account with address `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` and private key `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`.\n\n2. Generate a P256 private and public key pair:\n```shell\npython examples/p256.py gen\n```\n\nThis command will generate a private and public key pair, save them to `private.pem` and `public.pem` respectively, and print the public key in hex format.\n\n3. Deploy [P256Delegation](src/P256Delegation.sol) contract which we will be delegating to:\n```shell\nforge create P256Delegation --private-key \"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\" --rpc-url \"http://127.0.0.1:8545\"\n```\n\n4. Configure delegation contract:\nSend EIP-7702 transaction, delegating to our newly deployed contract.\nThis transaction will both authorize the delegation and set it to use our P256 public key:\n```shell\ncast send 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 'authorize(uint256,uint256)' '\u003cpublic key X\u003e' '\u003cpublic key Y\u003e' --auth \"\u003caddress of P256Delegation\u003e\" --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80\n```\nNote that we are transacting with our EOA account which already includes the updated code.\n\nVerify that new code at our EOA account contains the [delegation designation]:\n```shell\n$ cast code 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266\n0xef0100...\n```\n\n5. After that, you should be able to transact on behalf of the EOA account by using the `transact` function of the delegation contract.\nLet's generate a signature for sending 1 ether to zero address by using our P256 private key:\n```shell\npython examples/p256.py sign $(cast abi-encode 'f(uint256,address,bytes,uint256)' $(cast call 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 'nonce()(uint256)') '0x0000000000000000000000000000000000000000' '0x' '1000000000000000000')\n```\n\nNote that it uses `cast call` to get internal nonce of our EOA used to protect against replay attacks.\nIt also abi-encodes the payload expected by the `P256Delegation` contract, and passes it to our Python script to sign with openssl.\n\nCommand output will contain the signature r and s values, which we then should pass to the `transact` function of the delegation contract:\n```shell\ncast send 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 'transact(address to,bytes data,uint256 value,bytes32 r,bytes32 s)' '0x0000000000000000000000000000000000000000' '0x' '1000000000000000000' '\u003cr value\u003e' '\u003cs value\u003e' --private-key 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d\n```\n\nNote that we are using a different private key here, this transaction can be sent by anyone as it was authorized by our P256 key.\n\n\n[AlphaNet]: https://github.com/paradigmxyz/alphanet\n[EOF]: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3540.md\n[forge-eof]: https://github.com/paradigmxyz/forge-eof\n[Docker]: https://docs.docker.com/\n[EIP-2537]: https://eips.ethereum.org/EIPS/eip-2537\n[EIP-7212]: https://eips.ethereum.org/EIPS/eip-7212\n[EIP-3074]: https://eips.ethereum.org/EIPS/eip-3074\n[foundry-alphanet]: https://github.com/paradigmxyz/foundry-alphanet\n[Apple Secure Enclave]: https://support.apple.com/guide/security/secure-enclave-sec59b0b31ff/web\n[WebAuthn]: https://webauthn.io/\n[Python]: https://www.python.org/\n[delegation designation]: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md#delegation-designation\n[EIP-7702]: https://eips.ethereum.org/EIPS/eip-7702\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadigmxyz%2Fforge-alphanet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparadigmxyz%2Fforge-alphanet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparadigmxyz%2Fforge-alphanet/lists"}