This repo contains smart contracts that [Oasis] use.
The Account Manager is a smart contract that handles account creation, credential management, simple message signing, and transaction signing. Its goal is to manage accounts for all EVM-compatible chains and substrate parachains, with the added option of exporting private keys for direct use in other wallet providers.
check EW-diagram.pdf
AccountManager.sol > AccountFactory.sol > (AccountEVM.sol or AccountSubstrate.sol)
AccountManager.sol > Account.sol > (AccountEVM.sol or AccountSubstrate.sol)
Instructions for development.
Create secrets.json file in root folder and insert private keys used to deploy.
For normal tests run.
Run npm test.
For tests regarding sapphire (e2e) functions make sure to run tests in you sapphire localnet.
First run the localnet:
docker run -it -p8545:8545 -p8546:8546 ghcr.io/oasisprotocol/sapphire-localnetThen run the tests
npx hardhat test ./pathtotest —-network sapphireLocalnetRun npm run build.
Run npm run flatten.
Smart contract deployment instructions.
- Set signer address in
scripts/deploy-account-manager.ts(this address provides signature for gasless transactions) - Set initial value to be transfered on gaspaying address
- Run
npx hardhat run --network sapphireTestnet ./scripts/deploy-account-manager.ts
Note: deployment should be executed with unwrapped ethers provider in order to be able to verify contract in next stage. All further transactions should be done using wrapped sapphire provider.
- Set
accountManagerAddress,usernamePlain,passwordinscripts/registration.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/registration.ts
- Set
accountManagerAddress,usernamePlain,passwordinscripts/registration-gasless.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/registration-gasless.ts
Note: usernamePlain has to be unique. If the transaction fails verify that signer address is the same on the AccountManager.sol & in the script
- Set
accountManagerAddress,usernamePlaininscripts/user-exists.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/user-exists.ts
- Set
accountManagerAddress,newSignerinscripts/set-signer.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/set-signer.ts
- Set
accountManagerAddressinscripts/account-manager-data.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/account-manager-data.ts
To verify on Sourcify.eth:
- Select: Import from solidity JSON
- Set compiler the same as hardhat.config
- choose file: leave blank
- In drag and drop section you select all JSON files inside embedded-wallet-contracts/artifacts/build-info
- You wait for it to load then under each contract you set address and chain
- Run
npx hardhat run ./scripts/helper/convert-abi.ts
- Set
gasPrice,gasLimit,timestamp,gaslessDatainscripts/helper/generate-signature-for-register.ts - Run
npx hardhat run ./scripts/helper/generate-signature-for-register.ts
- Set
accountManagerAddress,usernamePlain,password,receiverAddressinscripts/examples/proxy-call-transfer.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/examples/proxy-call-transfer.ts
Note: Make sure you have some ETH on the sender address (if you don't know your sender address, than you can get it by calling ./scripts/user-exists.ts)
- Set
accountManagerAddress,usernamePlain,password,receiverAddress,erc20Address,erc20Amountinscripts/examples/proxy-call-erc20-transfer.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/examples/proxy-call-erc20-transfer.ts
Note:
- Make sure you have some ETH on the sender address (if you don't know your sender address, than you can get it by calling
./scripts/user-exists.ts). - Make sure you have sufficient ERC20 token on the sender address too.
- You can either deploy your own erc20 token or use an existing one.
- Set
accountManagerAddress,usernamePlain,password,txRequestinscripts/examples/proxy-call-cross-chain.ts - Run
npx hardhat run --network sapphireTestnet ./scripts/examples/proxy-call-cross-chain.ts
Note:
- Make sure you have some ETH (Amoy) on the sender address (if you don't know your sender address, than you can get it by calling
./scripts/user-exists.ts). - Make sure you set the right nonce in
txRequest(nonce on Amoy chain)