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, with the added option of exporting private keys for direct use in other EVM wallets.
Instructions for development.
Create secrets.json
file in root folder and insert private keys used to deploy.
Run npm test
.
Run 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
,password
inscripts/registration.ts
- Run
npx hardhat run --network sapphireTestnet ./scripts/registration.ts
- Set
accountManagerAddress
,usernamePlain
,password
inscripts/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
,usernamePlain
inscripts/user-exists.ts
- Run
npx hardhat run --network sapphireTestnet ./scripts/user-exists.ts
- Set
accountManagerAddress
,newSigner
inscripts/set-signer.ts
- Run
npx hardhat run --network sapphireTestnet ./scripts/set-signer.ts
- Set
accountManagerAddress
inscripts/account-manager-data.ts
- Run
npx hardhat run --network sapphireTestnet ./scripts/account-manager-data.ts
- Run
npx hardhat run ./scripts/helper/convert-abi.ts
- Set
gasPrice
,gasLimit
,timestamp
,gaslessData
inscripts/helper/generate-signature-for-register.ts
- Run
npx hardhat run ./scripts/helper/generate-signature-for-register.ts
- Set
accountManagerAddress
,usernamePlain
,password
,receiverAddress
inscripts/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
,erc20Amount
inscripts/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
,txRequest
inscripts/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)