Skip to content

A repository with Smart Accounts contracts that can utilize ERC20 and ERC721 tokens, and a web API that allows to create smart accounts and call methods on them

Notifications You must be signed in to change notification settings

alastria/Smart-Accounts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Smart Accounts API

This project has the solidity contracts for smart accounts in hardhat/contracts/.
In here you will find the Account contract, which is an implementation of both ERC20Account and ERC721Account with Ownable so that only the user that created that smart account can call non-view methods on that smart account.
Additionally, there is an interface for IERC20Account and IERC721Account for the exposed methods from both account types. Finally, AccountFactory allows for Smart Accounts to be deployed diretly from a smart contract, and holds the addresses of all the smart accounts it has currently created.

Compiling and using

This repository already has the AccountFactory deployed on Alastria's Red B node.
You can find the address for this deployment in hardhat/addresses-redB.json.
You can chose to deploy on a different node or network if you wish, so if you do, please follow the instructions in hardhat/README.md for how to compile and deploy the contracts.
Additionally, I'll provide further instructions here to modify the API so that it uses the new deployment:

Once you have compiled the contracts and deployed the AccountFactory, grab first the ABIs for AccountFactory and Account and update api/contracts.json with the new ABIs.
After this, grab the address for the deployed AccountFactory from hardhat/addresses-NETWORK.json (where NETWORK is the network you deployed the smart contract to) and replace address in api/contracts.json for AccountFactory with that new address.
Once this is done, make sure to update the .env file in api/.env (if it doesn't exist, create it using .env-sample as a template) so that the api connects to the blockchain network you deployed the contract to.

And that's it, you can then start up the API either with docker or node and start using the endpoints.

Startup with node

npm i
npm start

Startup with docker

docker build . -t smart-accounts
docker run -d -p 3000:3000 smart-accounts

The endpoints exposed by the API at http://localhost:3000 can be used with Postman, or directly with some other program that can make HTTP requests.
We have included a postman collection in api/docs/Smart Accounts API.postman_collection.json which already has all the calls prepared.
You will just have to configure the variables for the collection to add the correct API Key for the collection in the current value field.
You can find the API key if you compile this locally in api/src/exposition/middleware/apiKey.middleware.ts, or if you are using a version we deployed, you will have to get the API key directly from us.

About

A repository with Smart Accounts contracts that can utilize ERC20 and ERC721 tokens, and a web API that allows to create smart accounts and call methods on them

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published