
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@bananapus/721-hook-v5
Advanced tools
nana-721-hook
is:
If you're having trouble understanding this contract, take a look at the core protocol contracts and the documentation first. If you have questions, reach out on Discord.
How to install nana-721-hook
in another project.
For projects using npm
to manage dependencies (recommended):
npm install @bananapus/721-hook
For projects using forge
to manage dependencies (not recommended):
forge install Bananapus/nana-721-hook
If you're using forge
to manage dependencies, add @bananapus/721-hook/=lib/nana-721-hook/
to remappings.txt
. You'll also need to install nana-721-hook
's dependencies and add similar remappings for them.
nana-721-hook
uses npm (version >=20.0.0) for package management and the Foundry development toolchain for builds, tests, and deployments. To get set up, install Node.js and install Foundry:
curl -L https://foundry.paradigm.xyz | sh
You can download and install dependencies with:
npm ci && forge install
If you run into trouble with forge install
, try using git submodule update --init --recursive
to ensure that nested submodules have been properly initialized.
Some useful commands:
Command | Description |
---|---|
forge build | Compile the contracts and write artifacts to out . |
forge fmt | Lint. |
forge test | Run the tests. |
forge build --sizes | Get contract sizes. |
forge coverage | Generate a test coverage report. |
foundryup | Update foundry. Run this periodically. |
forge clean | Remove the build artifacts and cache directories. |
To learn more, visit the Foundry Book docs.
For convenience, several utility commands are available in package.json
.
Command | Description |
---|---|
npm test | Run local tests. |
npm run coverage | Generate an LCOV test coverage report. |
npm run artifacts | Fetch Sphinx artifacts and write them to deployments/ |
nana-721-hook
manages deployments with Sphinx. To run the deployment scripts, install the npm devDependencies
with:
`npm ci --also=dev`
You'll also need to set up a .env
file based on .example.env
. Then run one of the following commands:
Command | Description |
---|---|
npm run deploy:mainnets | Propose mainnet deployments. |
npm run deploy:testnets | Propose testnet deployments. |
Your teammates can review and approve the proposed deployments in the Sphinx UI. Once approved, the deployments will be executed.
You can use the Sphinx CLI to run the deployment scripts without paying for Sphinx. First, install the npm devDependencies
with:
`npm ci --also=dev`
You can deploy the contracts like so:
PRIVATE_KEY="0x123..." RPC_ETHEREUM_SEPOLIA="https://rpc.ankr.com/eth_sepolia" npx sphinx deploy script/Deploy.s.sol --network ethereum_sepolia
This example deploys nana-721-hook
to the Sepolia testnet using the specified private key. You can configure new networks in foundry.toml
.
To view test coverage, run npm run coverage
to generate an LCOV test report. You can use an extension like Coverage Gutters to view coverage in your editor.
If you're using Nomic Foundation's Solidity extension in VSCode, you may run into LSP errors because the extension cannot find dependencies outside of lib
. You can often fix this by running:
forge remappings >> remappings.txt
This makes the extension aware of default remappings.
The root directory contains this README, an MIT license, and config files. The important source directories are:
nana-721-hook/
├── script/
│ ├── Deploy.s.sol - Deploys core contracts - the hook store, deployer, and project deployer.
│ ├── LaunchProjectFor.s.sol - (DEPRECATED) Deploys a project with a 721 tiers hook.
│ └── helpers/
│ └── Hook721DeploymentLib.sol - Internal helpers for deployment scripts.
├── src/ - Contract source code. Top level contains implementation contracts.
│ ├── JB721TiersHook.sol - The core tiered NFT pay/redeem hook.
│ ├── JB721TiersHookDeployer.sol - Deploys an NFT hook for a project.
│ ├── JB721TiersHookProjectDeployer.sol - Deploys a project with a tiered NFT hook.
│ ├── JB721TiersHookStore.sol - Stores and manages data for tiered NFT hooks.
│ ├── abstract/
│ │ ├── ERC721.sol - Abstract ERC-721 implementation.
│ │ └── JB721Hook.sol - Abstract NFT hook implementation.
│ ├── interfaces/ - Contract interfaces.
│ ├── libraries/ - Libraries.
│ └── structs/ - Structs.
└── test/ - Forge tests and testing utilities.
├── E2E/
│ └── Pay_Mint_Redeem_E2E.t.sol - End-to-end test for minting and redeeming NFTs.
├── unit/ - Unit tests for various components..
└── utils/ - Miscellaneous testing utilities.
Other directories:
nana-721-hook/
├── .github/
│ └── workflows/ - CI/CD workflows.
└── deployments/ - Sphinx deployment logs.
graph TD;
A[JB721TiersHookProjectDeployer] -->|Launches & queues rulesets for| B[Juicebox projects]
D[JB721TiersHookDeployer] -->|Adds NFT hooks to| B
A -->|Deploys| C[JB721TiersHook]
D -->|Deploys| C
B -->|Calls upon pay/redeem| C
C -->|Stores data in| E[JB721TiersHookStore]
B -->|Uses| F[Pay/redeem terminal]
C -->|Mints NFTs upon payment through| F
C -->|Burns NFTs to reclaim funds through| F
Contract | Description |
---|---|
JB721TiersHook.sol | The core tiered NFT pay/redeem hook implementation. |
JB721TiersHookDeployer.sol | Exposes a deployHookFor(…) function which allows deploys an NFT hook for a project. |
JB721TiersHookProjectDeployer.sol | Exposes a launchProjectFor(…) function which deploys a project with a tiered NFT hook already set up. |
JB721TiersHookStore.sol | Stores and manages data for tiered NFT hooks. |
This contract is a data hook, a pay hook, and a redeem hook. Data hooks receive information about a payment or a redemption, and put together a payload for the pay/redeem hook to execute.
Juicebox projects can specify a data hook in their JBRulesetMetadata
. When someone attempts to pay or redeem from the project, the project's terminal records the payment in the terminal store, passing information about the payment/redemption to the data hook in the process. The data hook responds with a list of payloads – each payload specifies the address of a pay/redeem hook, as well as some custom data and an amount of funds to send to that pay/redeem hook.
Each pay/redeem hook can then execute custom behavior based on the custom data (and funds) they receive.
A project using a 721 tiers hook can specify any number of NFT tiers.
flags
. The flags specify if newly added tiers can have votes (voting units), if new tiers can have non-zero reserve frequencies, if new tiers can allow on-demand minting by the project's owner, and if the tier can be removed.Each tier has the following optional properties:
Additional notes:
JBPrices
contract is used to normalize the values.useDataHookForRedeem
to true
in the project's JBRulesetMetadata
. If NFT redemptions are enabled, project token redemptions are disabled.ERC721Votes
). This increases the gas fees to interact with the NFTs, and should be disabled if not needed.To use a 721 tiers hook, a Juicebox project should be created by a JB721TiersHookProjectDeployer
instead of a JBController
. The deployer will create a JB721TiersHook
(through an associated JB721TiersHookDeployer
) and add it to the project's first ruleset. New rulesets can be queued with JB721TiersHookProjectDeployer.queueRulesetsOf(…)
if the project's owner gives the project deployer the permission JBPermissions.QUEUE_RULESETS
(ID 2
) in JBPermissions
.
It's also possible to add a 721 tiers hook to an existing project by calling JB721TiersHookDeployer.deployHookFor(…)
and adding the hook to the project's ruleset – specifically, the project must set their JBRulesetMetadata.dataHook
to the newly deployed hook, and enable JBRulesetMetadata.useDataHookForPay
and/or JBRulesetMetadata.useDataHookForRedeem
depending on the functionality they'd like to enable.
All JB721TiersHook
s store their data in the JB721TiersHookStore
contract.
FAQs
`nana-721-hook` is:
The npm package @bananapus/721-hook-v5 receives a total of 19 weekly downloads. As such, @bananapus/721-hook-v5 popularity was classified as not popular.
We found that @bananapus/721-hook-v5 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.