Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jac18281828/transfervault
Example Solidity TimeLock and TransferVault
https://github.com/jac18281828/transfervault
Last synced: about 2 months ago
JSON representation
Example Solidity TimeLock and TransferVault
- Host: GitHub
- URL: https://github.com/jac18281828/transfervault
- Owner: jac18281828
- Created: 2022-09-30T23:44:43.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-13T20:11:30.000Z (over 2 years ago)
- Last Synced: 2024-10-15T19:13:59.157Z (3 months ago)
- Language: Solidity
- Size: 120 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# TransferVault Smart Contract Example
A simple vault smart contract example.
| Contract | Ethereum Address | Version |
| ----------------- | ------------------------------------------ | ------- |
| TransferVault | 0xc0B89372454898a9Db24F21BC99BB35A5110F0E6 | 0.0.8 |
| ERC20 VaultXTransferToken | 0x800Bb943eF526B752a38473be3b3929454460222 | 0.0.8 |View it on [Etherscan](https://goerli.etherscan.io/address/0xc0B89372454898a9Db24F21BC99BB35A5110F0E6)
Things to try:
1. Deploy the smart contract
```
$ forge create --contracts contracts/TransferVault.sol --rpc-url ${DEVNET_RPC_URL} --private-key ${ETH_DEV_PRIVATE} --etherscan-api-key ${ETHERSCAN_API_KEY} --verify TransferVaultCompiler run successful
Deployer: 0xABCDEFG
Deployed to: 0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A
Transaction hash: 0x3d95a40fdda4fde192c99f48ee07689941948bc44d9f204b69114722a5f6e235
Starting contract verification...
Waiting for etherscan to detect contract deployment...Submitting verification for [contracts/TransferVault.sol:TransferVault] "0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A".
Submitting verification for [contracts/TransferVault.sol:TransferVault] "0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A".
Submitted contract for verification:
Response: `OK`
GUID: `t95warfinn3cv51uwtgcgc23cb7jsm5nnbpg2c5sh1rwn9kub1`
URL:
https://goerli.etherscan.io/address/0x1e593fc13ae2faa53ca6fb7f2d664478229c363a```
2. Deposit ETH
```
$ cast send 0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A "deposit()" --private-key ${ETH_DEV_PRIVATE} --rpc-url ${DEVNET_RPC_URL} --value "1 wei"blockHash 0x93d755bf908a8aa7e707bf50ff5cf50181377fae719ff4ee24c5341543bd8b1d
blockNumber 7746243
contractAddress
cumulativeGasUsed 1544774
effectiveGasPrice 6693637476
gasUsed 121026
logs [{"address":"0x8f6dfc7460ed703733de99721018709d0724b904","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x93d755bf908a8aa7e707bf50ff5cf50181377fae719ff4ee24c5341543bd8b1d","blockNumber":"0x7632c3","transactionHash":"0x659beb7737f9db6c15601dbedf1f6e9a5c7b4004476e50b95b0aaa68fbc410eb","transactionIndex":"0xb","logIndex":"0x2e","removed":false},{"address":"0x1e593fc13ae2faa53ca6fb7f2d664478229c363a","topics":["0x4d6ce1e535dbade1c23defba91e23b8f791ce5edc0cc320257a2b364e4e38426"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x93d755bf908a8aa7e707bf50ff5cf50181377fae719ff4ee24c5341543bd8b1d","blockNumber":"0x7632c3","transactionHash":"0x659beb7737f9db6c15601dbedf1f6e9a5c7b4004476e50b95b0aaa68fbc410eb","transactionIndex":"0xb","logIndex":"0x2f","removed":false}]
logsBloom 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000008000000000000000000000000002000000000000000000000020000000000000080000800000002000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000400000000000000000000002000002000000000000000000000000000000000000000000000020000000000000400080000000000000000000040000000000000000000000040002
root
status 1
transactionHash 0x659beb7737f9db6c15601dbedf1f6e9a5c7b4004476e50b95b0aaa68fbc410eb
transactionIndex 11
type 2
```Check the transaction on [Etherscan](https://goerli.etherscan.io/tx/0x659beb7737f9db6c15601dbedf1f6e9a5c7b4004476e50b95b0aaa68fbc410eb)
3. Approve the return of the tokens from the local wallet
This approves the ERC20 Token transfer from your wallet to the Vault Contract so the address being approved is that of the contract itself. This is sent to the address of the Token contract.
```
$ cast send 0x8f6DFC7460ed703733De99721018709d0724B904 "approve(address, uint256)" --private-key ${ETH_DEV_PRIVATE} --rpc-url 0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A 0x1
E593FC13aE2FAa53ca6fB7f2d664478229C363A "1 wei"blockHash 0x0a3eb35882b3b1d664ece2e7459f97932d180d0dd94aebe59a3968e2c2a25c44
blockNumber 7746360
contractAddress
cumulativeGasUsed 16278950
effectiveGasPrice 3169976030
gasUsed 46253
logs [{"address":"0x8f6dfc7460ed703733de99721018709d0724b904","topics":["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x0000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad","0x0000000000000000000000001e593fc13ae2faa53ca6fb7f2d664478229c363a"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x0a3eb35882b3b1d664ece2e7459f97932d180d0dd94aebe59a3968e2c2a25c44","blockNumber":"0x763338","transactionHash":"0x0868eb6bd397ba4e6270b1cf70dac391a6de0cd7fb617fec8c53bbc4e4c237e1","transactionIndex":"0x3d","logIndex":"0x79","removed":false}]
logsBloom 0x00000000000000000000000000000000000000000000000040000000000080000000000000000001000000000010000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000080000000000000000000000000400000000000000000000000000002000000000000000000000000000000000000000000000000000010000000400000000000000000000000000000000000000000000000000000
root
status 1
transactionHash 0x0868eb6bd397ba4e6270b1cf70dac391a6de0cd7fb617fec8c53bbc4e4c237e1
transactionIndex 61
type 2
```4. Withdraw eth and check your balance
```
$ cast send 0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A "withdraw(uint256)" --private-key ${ETH_DEV_PRIVATE} --rpc-url ${DEVNET_RPC_URL} "1 wei"
blockHash 0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3
blockNumber 7746367
contractAddress
cumulativeGasUsed 6920476
effectiveGasPrice 4111701172
gasUsed 136338
logs [{"address":"0x8f6dfc7460ed703733de99721018709d0724b904","topics":["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x0000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad","0x0000000000000000000000001e593fc13ae2faa53ca6fb7f2d664478229c363a"],"data":"0x0000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x1d","removed":false},{"address":"0x8f6dfc7460ed703733de99721018709d0724b904","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad","0x0000000000000000000000001e593fc13ae2faa53ca6fb7f2d664478229c363a"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x1e","removed":false},{"address":"0x8f6dfc7460ed703733de99721018709d0724b904","topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000001e593fc13ae2faa53ca6fb7f2d664478229c363a","0x0000000000000000000000000000000000000000000000000000000000000000"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x1f","removed":false},{"address":"0xc5ad25ea9137dfea98cc0d572effb2dc005604d6","topics":["0xefc0288202e432ade6bf71491d0001d7e389ad4f8e4e9c7aa038dd1a563efc60"],"data":"0x0000000000000000000000001e593fc13ae2faa53ca6fb7f2d664478229c363a0000000000000000000000000000000000000000000000000000000000000001","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x20","removed":false},{"address":"0xc5ad25ea9137dfea98cc0d572effb2dc005604d6","topics":["0x76e2796dc3a81d57b0e8504b647febcbeeb5f4af818e164f11eef8131a6a763f","0x2057b01692ec381fd3bc95ea9ac5c7592310c3150ad2bf0b0bfbc0e2361f73d1","0x0000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad"],"data":"0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000063446a6c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x21","removed":false},{"address":"0x1e593fc13ae2faa53ca6fb7f2d664478229c363a","topics":["0x8353ffcac0876ad14e226d9783c04540bfebf13871e868157d2a391cad98e918"],"data":"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000006ceb0bf1f28ca4165d5c0a04f61dc733987ed6ad","blockHash":"0x645f20716f5462d4f1960b9f7ec13e30b2aa6ef7a9a0c339afe97e48034c65b3","blockNumber":"0x76333f","transactionHash":"0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5","transactionIndex":"0xf","logIndex":"0x22","removed":false}]
logsBloom 0x00000000000000000000000000000000000000000000000040000000000081000000000000000001000800400010000000000000000400000000000000200000200000002000004000000008000000000000000000000000000000000008080000000000020000000000010080000800000000000000000000000010000000000000001000000000000000000000000000000000000000004000000000000000020000000000000000000080000000000000000000000000400000000000000000000042000002000000021000000000000000000000000000000000000020000010000000400080000000000000000000040000000000000000000000040000
root
status 1
transactionHash 0xdfbd4cda95887a93353e1ff9a7140fc634bf050c050721ad90a18f264ac77dd5
transactionIndex 15
type 2```
And the balance:
```
$ cast call 0x1E593FC13aE2FAa53ca6fB7f2d664478229C363A "balance(address)" --rpc-url ${DEVNET_RPC_URL} ${ETH_DEV_PUBLIC}
0x0000000000000000000000000000000000000000000000000000000000000001
```5. Wait for the timelock and then pay eth