Octover 31, 2023: Sneks v Apes 🐍🦍
Comparing and contrasting Ape Framework with Vyper's Titanoboa
As Brownie grows increasingly dated, devs are migrating towards other solutions.
Ape Framework forked Brownie, so it naturally comes to people minds as devs decide where to move their infrastructure. Titanoboa is not a framework, but nonetheless so useful that it can serve as an overpowered engine that also substitutes for enough common functions as to be practical. Lately several devs have asked me whether they should learn Ape or Boa.
The answer is both! Both are great. Trying to frame it as a conflict is asinine, the two projects are not in competition. Ape is a comprehensive web3 framework, Titanoboa is a Python-native Vyper interpreter. Both are extremely useful and very applicable within their specific niches.
Depending on your skill set and your particular needs, usually one of these tools will prove to be clearly preferable for your use case. It will likely be quite obvious depending on your particular circumstances.
Therefore, this article will compare and contrast the two, to give people less familiar with these tools some background on the key similarities and differences between Titanoboa and Ape.
1. Features
Titanoboa and Ape are intentionally different in their feature sets.
Titanoboa focuses on providing an advanced integrated development experience with features like tracebacks, forking, and opcode patching, allowing Vyper smart contracts to be interpreted directly in Python.
Ape Framework, on the other hand, presents a more comprehensive Web3 development tool, focusing on a broader array of features such as compiling, testing, and interacting with smart contracts, along with a plugin system for enhanced functionality.
Generally, we’ll point beginners towards Ape. Ape looks to extend Brownie’s ambitions of creating an all-encompassing web3 framework. Ape builds upon Brownie’s core of creating an environment for creating smart contracts, testing them, and interacting them via scripts and a built-in console.
Much of its functionality for Ape comes from its system of plugins, giving it the ability to utilize nearly every web3 technology with a simple install:
> ape plugins list --all
Core Plugins
accounts
cache
compile
console
ethereum
geth
init
networks
plugins
pm
run
test
Available Plugins
addressbook
alchemy
arbitrum
avalanche
base
bsc
cairo
chainstack
ens
etherscan
fantom
flashbots
foundry
frame
ganache
hardhat
infura
ledger
notebook
optimism
polygon
polygon-zkevm
safe
solidity
starknet
template
tenderly
titanoboa
tokens
trezor
vyper
There’s even a Titanoboa plugin for Ape! The quality of these plugins of course varies, and the Ape experience notably suffers when the plugins are themselves incomplete or poorly documented.
Still, if you have a deeply held desire or need to use any of these particular plugins, then you may find Ape may be the best choice for you.
In contrast, Titanoboa is extremely powerful and has some outstanding advanced features, but does not aspire to the same breadth of coverage. Titanoboa is seeing more ecosystem adoption, but it is primarily focused on its niche of deep Vyper engineering using native Python.
If you like Vyper and Python, Titanoboa is the clear choice. Being able to compile and work against smart contracts natively in Python is an incredible advantage for developers. However, if you prefer Solidity and JavaScript, you may be advised to steer clear.
Titanoboa is outstanding for advanced devs because it is fast and powerful. The learning curve may be intimidating for newer programmers, but it was built out in particular to give advanced users access to several cutting-edge features that make advanced development work easier.
Some highlights include line-by-line gas profiling:
Opcode patching:
Custom precompiles
Another key benefit of Titanoboa is speed. Titanoboa is not executing against a mock EVM, but works as a native Python interpreter, which is an order of magnitude faster. This may not matter to inexperienced users, but for users who need to run complex tests against advanced applications, the speed boost from Titanoboa can become a major productivity saver.
The advanced features of Titanoboa are incredibly powerful, and thus highly useful for superior smart contract developers. If you are mildly experienced and looking to level up your skills, Titanoboa would be a great addition to your repertoire.
2. Testing
In the oft-hacked world of web3, unit testing is a critical feature to assist auditors and protect users.
Both Ape and Titanoboa offer comprehensive testing via pytest and can be used to create comprehensive tests. On this front, the differences between the two technologies is more cosmetic.
Ape’s interface will be familiar to anybody who has used Brownie. Testing is integrated into the core ape command, so developers can test directly using variants of the basic command
ape test
As a comprehensive framework, writing tests pulls in ape’s library of helper tools. Smart contracts you’ve been working on in your contracts folder are natively imported into ape’s project
library.
@pytest.fixture(scope="session")
def token(owner, project):
return owner.deploy(project.Token)
As a native Python interpreter, Titanoboa integrates directly with pytest and hypothesis, which offers some advantages.
The experience may be less familiar to users of Brownie. Here is an example of how contracts are loaded using Boa:
@pytest.fixture
def empty_factory(self, deployer, fee_receiver, owner):
with boa.env.prank(deployer):
_factory = boa.load(
"contracts/main/CurveStableSwapFactoryNG.vy",
fee_receiver,
owner,
)
return _factory
This example comes from StableSwap-NG, which built out its entire test suite using boa. Boa has fewer resources to walk you through setting up testing, so this repository is a great example to illustrate the process for users.
If you are able to set up testing in boa, the aforementioned speed is a great benefit. Thanks to this speed, it’s quick enough to reinitialize the environment for each test. Therefore, Titanoboa can isolate these by default. It’s one of several nice little “quality of life” features that make life easier on the margins.
Another inspiration is providing the ability to directly test and access internal functions.
When you get down and dirty with debugging, accessing some of boa’s advanced capabilities built into tracebacks and accessing storage slots can become a dream toolset for power users.
3. Documentation and Support
The best thing about both Ape and Titanoboa is the developer community. Both projects are supported by top notch developers. Being able to directly access 100x-tier talent directly in their Discord channels is a key advantage of both ecosystems, and a reason we recommend learning both projects.
That said, if a wide variety of documentation and tutorials are important to you, Ape Framework has the clear edge. This is another reason we believe Ape is a great choice for beginners.
Ape has a retro-themed docs which links to resources throughout its growing ecosystem.
The Ape Academy also provides several helpful tutorials.
Of course, we’ll also take a moment to shamelessly self-promote that we’re putting together an Ape tutorial, particularly focused on users of Brownie who are interested in migrating to ape.
We’re working on a similar quickstart video tutorial for Titanoboa as well, but it’s not finished just yet. Please don’t hurl hostile wens at us! <ducks>
Such a tutorial would definitely be useful, because the documentation for Titanoboa is sufficient, but far more spartan. Tutorials are also less common. To get up to speed with boa, we simply recommend looking at examples of Titanoboa in the wild on Github, and otherwise lurking in the Vyper Discord. Advanced developers are already accustomed to this ad-hoc workflow at the bleeding edge, but it may intimidate beginners.
One nice facet of Titanoboa is that, as a native python library, it works seamlessly within the popular Jupyter notebook. The ability to load and deploy a contract from directly in your browser in a sample notebook can in fact be very beginner friendly in some instances. You can play with this yourself by loading https://try.vyperlang.org/ and pulling in some example notebooks from the boa repo.
A lot of the difference here boils down to the structure of the two organizations. Boa is project within Vyper, an open source project that is underfunded and survives by begging for grants. Ape is working to build a viable business around its open source framework. Both these approaches have their own pros and cons which we will leave for the reader to compare.
4. User Experience
If a comfortable user experience is important to you, then we’d probably give the edge to Ape. In working to build out a comprehensive set of web3 tools under a single umbrella, Ape has more interest in abstracting the entire feature set into a unified framework. In contrast, Boa does not intend to build an all-encompassing framework, so it focuses on going deep within its niche.
One example of the difference in how the experience between the protocols manifests itself here is in the process of working on a new network. If you want to work within, say, Polygon on ape, you would turn to installing the built-in ape plugin
ape plugins install polygon
From here you would manipulate the config.yaml file and get to work
ape console --network polygon:mainnet
In contrast, Titanoboa does not handle network management internally. Within boa, you’ll hunt down an endpoint (or spin one up on your local machine,) then connect to it.
boa.set_env(NetworkEnv("<rpc server address, e.g. an alchemy endpoint>"))
The former approach may be easier for beginners since it integrates the experience. However, this can also be a double-edged sword. If you’re working against a new chain that doesn’t have an ape plugin already built, you may find yourself stuck.
Similarly for address management. Ape works to integrate live network accounts and test accounts into a unified experience, with management possible through the command-line tool and a native accounts
object accessible throughout ape.
from ape import accounts
my_contract.function_call(sender=accounts.test_accounts[0])
Boa also provides the features you need to work with accounts, but makes no attempt to abstract this within a unified framework. A new address may be generated:
test_addr = boa.env.generate_address()
Or an existing address may be loaded:
>>> with boa.env.prank("0x00000000000000000000000000000000000000ff"):
... boa.env.eoa
...
'0x00000000000000000000000000000000000000ff'
So it’s a different workflow to get used to, but functional all the same. Again, boa doesn’t attempt to bring in external account management directly, but this can be accomplished by connecting via your browser.
boa.env.add_account(BrowserSigner())
You can also pull in accounts from your Frame Wallet, or any RPC node that provides an eth_sendTransaction endpoint.
Conclusion
We tend to recommend that Ape is probably a better choice for beginners, while we’d suggest Titanoboa is better for advanced users looking to level up their game. Boa is clearly the best choice if you are using Vyper and Python, if you prefer towards Solidity, then Ape may be to your liking.
Again, we ultimately recommend learning both frameworks. They play well together, so if you learn both you’ll have a diverse set of tools to handle whatever challenges you need to overcome. For example, you can check the crvUSD repo to see examples of where both ape and boa were used in different parts of testing.
Whichever you choose to pursue, note that you’ll get the opportunity to connect with top tier blockchain engineers. It’s one of the best facets of the small and growing cryptocurrency space, and we recommend you utilize that opportunity.
Additional Resources
Compile a list of essential resources, tutorials, community forums, and documentation for both Ape Framework and Titanoboa to aid readers in their exploration and learning journey.
Ape:
Titanoboa: