<!-- livebook:{"persist_outputs":true} -->
# Web3AptosEx
## Section
> Test Smart Contract Lists:
>
> * hello_blockchain: [0xcd6e69ff3c22db037584fb1650f7ca75df721fb0143690fb33f2f3bd0c1fe5bd](https://explorer.aptoslabs.com/account/0xcd6e69ff3c22db037584fb1650f7ca75df721fb0143690fb33f2f3bd0c1fe5bd/modules)
```elixir
Mix.install([:poison, :jason, {:web3_aptos_ex, "~> 1.0.1"}])
```
<!-- livebook:{"output":true} -->
```
Resolving Hex dependencies...
Resolution completed in 3.304s
New:
bcs 0.1.0
binary 0.0.5
certifi 2.9.0
decimal 2.0.0
ecto 3.4.6
ex_struct_translator 0.1.1
hackney 1.18.1
httpoison 1.8.2
idna 6.1.1
jason 1.4.0
metrics 1.0.1
mime 2.0.3
mimerl 1.2.0
nimble_parsec 1.2.3
parse_trans 3.3.1
poison 3.1.0
ssl_verify_fun 1.1.6
telemetry 0.4.3
tesla 1.5.0
unicode_util_compat 0.7.0
web3_aptos_ex 0.2.0
* Getting poison (Hex package)
* Getting jason (Hex package)
* Getting web3_aptos_ex (Hex package)
* Getting bcs (Hex package)
* Getting binary (Hex package)
* Getting ex_struct_translator (Hex package)
* Getting hackney (Hex package)
* Getting httpoison (Hex package)
* Getting nimble_parsec (Hex package)
* Getting tesla (Hex package)
* Getting mime (Hex package)
* Getting certifi (Hex package)
* Getting idna (Hex package)
* Getting metrics (Hex package)
* Getting mimerl (Hex package)
* Getting parse_trans (Hex package)
* Getting ssl_verify_fun (Hex package)
* Getting unicode_util_compat (Hex package)
* Getting ecto (Hex package)
* Getting decimal (Hex package)
* Getting telemetry (Hex package)
===> Analyzing applications...
===> Compiling parse_trans
===> Analyzing applications...
===> Compiling mimerl
==> nimble_parsec
Compiling 4 files (.ex)
Generated nimble_parsec app
===> Analyzing applications...
===> Compiling metrics
===> Analyzing applications...
===> Compiling unicode_util_compat
===> Analyzing applications...
===> Compiling idna
===> Analyzing applications...
===> Compiling telemetry
==> binary
Compiling 2 files (.ex)
Generated binary app
==> decimal
Compiling 4 files (.ex)
Generated decimal app
warning: String.strip/1 is deprecated. Use String.trim/1 instead
/Users/liaohua/Library/Caches/mix/installs/elixir-1.14.2-erts-11.2.2.3/e76e2beadba340d20f5f78500f2b5c84/deps/poison/mix.exs:4: Poison.Mixfile
==> poison
Compiling 4 files (.ex)
warning: Application.get_env/2 is discouraged in the module body, use Application.compile_env/3 instead
lib/poison/parser.ex:22: Poison.Parser
warning: use Bitwise is deprecated. import Bitwise instead
lib/poison/parser.ex:26: Poison.Parser
warning: use Bitwise is deprecated. import Bitwise instead
lib/poison/encoder.ex:83: Poison.Encoder.BitString
warning: Integer.to_char_list/2 is deprecated. Use Integer.to_charlist/2 instead
lib/poison/encoder.ex:173: Poison.Encoder.BitString.seq/1
Generated poison app
==> jason
Compiling 10 files (.ex)
Generated jason app
==> ssl_verify_fun
Compiling 7 files (.erl)
Generated ssl_verify_fun app
==> bcs
Compiling 4 files (.ex)
Generated bcs app
===> Analyzing applications...
===> Compiling certifi
===> Analyzing applications...
===> Compiling hackney
==> httpoison
Compiling 3 files (.ex)
Generated httpoison app
==> ecto
Compiling 55 files (.ex)
warning: atom ::: must be written between quotes, as in :"::", to avoid ambiguity
lib/ecto/query/builder.ex:246:8
warning: Decimal.cmp/2 is deprecated. Use compare/2 instead
lib/ecto/changeset.ex:2149: Ecto.Changeset.validate_number/6
warning: Macro.to_string/2 is deprecated. Use Macro.to_string/1 instead
lib/ecto/query/inspect.ex:225: Inspect.Ecto.Query.expr/3
Generated ecto app
==> ex_struct_translator
Compiling 1 file (.ex)
Generated ex_struct_translator app
==> mime
Compiling 1 file (.ex)
Generated mime app
==> tesla
Compiling 30 files (.ex)
warning: Application.get_env/3 is discouraged in the module body, use Application.compile_env/3 instead
lib/tesla/middleware/telemetry.ex:83: Tesla.Middleware.Telemetry
warning: Application.get_env/3 is discouraged in the module body, use Application.compile_env/3 instead
lib/tesla/middleware/logger.ex:185: Tesla.Middleware.Logger
warning: unused import Bitwise
lib/tesla/middleware/retry.ex:51
Generated tesla app
==> web3_aptos_ex
Compiling 39 files (.ex)
Generated web3_aptos_ex app
```
<!-- livebook:{"output":true} -->
```
:ok
```
## 0x01 Description
Aptos SDK impl in elixir!
See the using example in:
> https://github.com/NonceGeek/move_sdk_ex_liveview_example
## 0x02 Implementation
* [x] Aptos
* [x] RPC Implementation
* [x] Read Resource
* [x] Send Transaction
* [x] Chain Interactor
## 0x03 Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `web3_aptos_ex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:web3_aptos_ex, "~> 1.0.1"}
]
end
```
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/web3_aptos_ex](https://hexdocs.pm/web3_aptos_ex).
## 0x04 Aptos
**Namespace:** Web3AptosEx.Aptos
<!-- livebook:{"break_markdown":true} -->
### 4.1 Create a Connect
```elixir
import Web3AptosEx.Aptos
alias Web3AptosEx.Aptos
{:ok, client} = Aptos.RPC.connect("https://fullnode.testnet.aptoslabs.com/v1")
client
```
<!-- livebook:{"output":true} -->
```
%Web3AptosEx.Aptos.RPC{
endpoint: "https://fullnode.testnet.aptoslabs.com/v1",
client: %Tesla.Client{
fun: nil,
pre: [
{Tesla.Middleware.BaseUrl, :call, ["https://fullnode.testnet.aptoslabs.com/v1"]},
{Tesla.Middleware.JSON, :call, [[engine_opts: [keys: :atoms]]]}
],
post: [],
adapter: nil
},
chain_id: 2
}
```
### 4.2 Create Account
Aptos using the Ed25519 Algorithm for the Account.
```elixir
priv = Web3AptosEx.Crypto.generate_priv()
{:ok, account} = Aptos.Account.from_private_key(priv)
account
```
<!-- livebook:{"output":true} -->
```
#Account<0xff453c28b65311d7f16556817bc03e460dac808377af763585302b41d426d801>
```
```elixir
# {:ok, account_ol} = Aptos.load_account(client, account)
# account_ol
# it will works if account is actived(has any APT)
```
<!-- livebook:{"output":true} -->
```
nil
```
### 4.3 Read Resource of Acct
#### 4.3.1 Read the resources of the Acct
```elixir
Aptos.RPC.get_resources(client, "0x3")
```
<!-- livebook:{"output":true} -->
```
{:ok,
[
%{
data: %{
authentication_key: "0x0000000000000000000000000000000000000000000000000000000000000003",
coin_register_events: %{counter: "0", guid: %{id: %{addr: "0x3", creation_num: "0"}}},
guid_creation_num: "2",
key_rotation_events: %{counter: "0", guid: %{id: %{addr: "0x3", creation_num: "1"}}},
rotation_capability_offer: %{for: %{vec: []}},
sequence_number: "0",
signer_capability_offer: %{for: %{vec: []}}
},
type: "0x1::account::Account"
},
%{
data: %{
packages: [
%{
deps: [
%{account: "0x1", package_name: "AptosFramework"},
%{account: "0x1", package_name: "AptosStdlib"},
%{account: "0x1", package_name: "MoveStdlib"}
],
extension: %{vec: []},
manifest: "0x1f8b08000000000002ff5d8ebd0ac2301485f7fb14217b638bb3838b9b936ea5486cae529a2621375441faeee64610ed7a7ebe73daa0fb51dfb103a727143b21f721793afb119d8419230ddeb1dca85ad512a0d5c6442442ea809261ab7e361234d72eb798290f1fc7959e98f7d1b60c3118d01974fdc09ca39ff1948c1dae39f212d6f7da7258a9cd94ad8a8a27c502e5dce167e43f5dc6aaef09b9c01b586da59de0000000",
modules: [
%{
extension: %{vec: []},
name: "property_map",
source: "0x1f8b08000000000002ffed1a696fdb46f6bb7fc5540ba86496f5d53431643b58af2bb4c6c60762a5683608084a1ad9442892e0615b4dfddffbde1ce4cc70485376dcf64303b489876fde7d8fb7b6b6c84596a4342b56a7414ac29c04244fe92c0ca2f0b7a0089398240b72192ed38822c022c9c824f94ce37c73630b2e9f146419a478ebb2c8c2f88a7ca62b5224f0b344fb4b10959414d7414166499c87799123ca629552e2e4ec924b82784e6e18a073436745921d947b6f5c4921cd929b704e73320df2704692f8bbd97510c624a799ce679a85cbb0086f2843c8912337a9e045d0b80d8b6bce401883404b765f120ba23c217999a649069c0255410451197800735890240bafc2388818c6cd8d65322f2360202d92dc2f5055a391bce783aec8970d027fca9c0283f3d1683acbf7f513ae01e3906659e38c0b381a7db9a4d1c21316b8af81380f0c7491254b5f23a57ccc997991b91a97b4b81d1d8aeaa3f2c43fe36049f73718e4d696f88b1c83b98b202e72fd7c8b4cae2978cd5db804a5c5e5724a336e3ca15cee2b414ca6286792d139d8a9fe0c6c324ce84d05393dfad5bf78777e317e37f9e09f1e5df89727ff1f8f48f9ea2539243bdbdbdbfb6dc06747a763ffedf8eca7c9cf15fcee1e4861883146cd83bb5b84a87842af0fa28c06f315a177e8e30ad5f1ffc61ffca377e3a31f3ff8e35f4f2e27fec999c67345be5221476fd10dbd9b513acf41479444e8ec2a9d5ab4f7a7ff1dbf0362c7e3f18ffedb93d39389a4b16bd0a830cf139ac7df169c7d3bd6f309e75fe2fa5ec175a1a9a20ae75952c605e046cc1067b36b532fc7e7efcf260cf5e9d1e4f867ff97a3b7efc7fc549279d9458685f1da54261f2e0c223fd88830e452310dc40c498553227a651a11428338c0aecbd29eaa72c8b64592902889afac0a4777665e3a393ff7df9e9ffd2469bc6e7a29047f39ab438dfd9db3332dc15f07399049571e99c3a9c7e34ba424fc8339a00efe039e523c3d99bff118f8bd95084ff74886a1f6146a0a19e61c2352e77aaffa843a1f895ca6114acb6904d97f51c624a6b74e7501549b57a8f83d051da3547faf291a241b28d85777a469af1620a205fc175f412139141747237ee00c912377bf820d72a821c5378e803f38b4272d8fb01c3f1a8531301dcefd20bb2a97342e9ccec076db291d3659e3ea703b683d1094eb91639a5d975a1d9c484c53b9089d107a8143429769b1724c9010be6cd73cde5e87508d9d901c087bb98a15e51d4c2687e485e47e9a00bbb7dc8e1e09158955a965f555acee368cab14993ef66d44bc6b10574b75309f3bda47fc335c96aa9a3601d26b0001abcd433d82bfc8186d6885bb10eac513c1da0061664708885d9584210c9a2a24ffc6ba278feeeb7fd642a85900d3ea3114da826a1d019987193011ad08763a5575d01b364b1af1b117f401dc0770bfead318f823538c9e2bff4923ad69e46f17d97801e4b05da89dfe6f940c300118f1eeb1d84629be42ac29a1222cd2e6c7f6d3aaa150b3d68c056f4b67e1b87558ddb7b0025d5201d35f8e51eb30f443853c53001c71fcc0f034492285278d1515d3108e58b644046e0b6dd43827896a6f92955289dca909a7bae75fe63692f0373df4c0b8a9288af1c6e7e38df3e05063a3aa12e522b7f981e402b4d133cdc1a859d0fe39ce2ca4cca0aa0b08238a2b4d5710266b38a0cb9b74bbc7493b4be95a708bacf3b0730f8da2ade5cb054c4573087b3360b88737adc3e03ddbc0d7a237991cfb440e3a8fcfddbd875c6299f4a55122409c5a396d8220e0269bdda074c9102b8bc59e331d6cdfedd48b134e66e0b639933ee1a9ee23f729b0ff48a4588c2c779a2e25947b3d1450ee3d87f0e5de936505eefbcaf9ea651f41b558f97a92be7af9745141809eb24206c9689ef79057403e87cc02f593e596c2f4b5336ccdfa181ac09ec5d280f7e9a646197aca8b0dc5fa7dc7579317f13e595e26c3c3f2724ec534248723b3eab8ea1e4791f8c550ded8aca7af561a286d1789464550d0e3dd568b2d931b6592b3376feaa057d9504e6e8eb54571bf4eb115568c93c267278eadfab6945f215ba37371cd79f97d3ac77959df3dc6ec67d6cd694f1b72bd8e178fa228b925255e47980a18c7a76fc58617c76cc818384ce3f977fc340dc22c378dc110515f7d0d59c732cfb1e5e39f4d63e23e005ab58767723131b6008b29590707365ac0f9b2ace92a15378792565bf43f6277a720179cad83bc6355d73ead5b75da3ebcf79fddd1b17c3ec0b7f5c5c602ba6bb9d5b8f3d0b24bbf716fccdf0be2d873836b61cf8c149e81ebd1444a6a28e19ed028b7892be6568fbce8bcfef0caa025cddaf97d4cd6f5cc3702cd92d668fd9352afb2a55a092f6b0e433e0869c9c8359617060a2665db8cc97725865afd2c505e3f7abea4986b48332ebae28591d09d1b51b76c6ab06e70be49603e98b3ddec158de1497d261ed78222e825f501bcd4e153d21b07af80bb4c3aa44153b1773796d4f8f3f4c1e48da3d801e3511389c3b7b45be4f7df1b31d5720167ac75c0715059079eb5bb6b5ca8a68235ee5887e4eab299b0dabdb46a375705cdd100683be85d916c8dcf9ab5d6476ac85047c4c075edaefaaf8f80a1f093385a7d620736ef8ba0e7695f7c367e1703a9ef9bcd445e9531d9777c24d23c4511cc3e63432f0ee665164cc3282c56ca217af1c0fdd4683c4aaaa056ba9e8f643ad8d91e78f0d70fecffb734489378403e359a11dac15c1817f48a660a23cd13e91e2a6a7c9fe5655ad653dedb34955feb9d99029cb5d2fc9394ae3d27d84daa1406f321adb15417b246f486e2f0a501f76c35c02083b69ec254ae5e" <> ...,
source_map: "0x"
},
%{
extension: %{vec: []},
name: "token",
source: "0x1f8b08000000000002ffed7d7b531b57f2e8fff914b3de2a56caca18b0e32460bb2e0679c35e0c5e1eeb9fef566a32a011cccf9246ab1941888bef7efbbc5f7dce1c0961e358542a0669e63cfa74f7e9773f79f22439b92caa6458f6a6833c194fcaaba29757497d9927fd723aea6575518ee0d74972527ecc47d5ea774fe09d9dcbfcfc6339ad93723a497af9553e28c739fc569e27f034f9b0264f27559dc110935e7259d7e36af3c9936c5c97d52abcf1e4bc1c9de7e3ba825f8ad16378ec317d853dc17eff8eaf8a7e94d28f3637d9c09fbe4be0675ae530456f73339f4ccac996f95939264bdfdcfc749c0ffa9de490fe796b3d541517a3dc7eb3aa27c5e842be794cffb4dfbccacf6b32a7fc94adb23fc986f97539f9b8b9999d9f0304eb2dff1300b8512de7e992bf7e01480cf2dbc04b7531cc01aec3b1fd0c5d569d9d0d7239e409f9cb198c43120e1b0eadbe4987d958bef18e7ff8361bdff2cd3d79c2ff4976ca1139d1ba129fd37fcfc9a7c9c9e1ffed1ea46fb7ff277d7b7ab2fd7abf9bee1dec6e26d3e7cf9297c9da96f3e4e9d11ef6e4bafbe4d1e187edfd930fd8d31beed3bbdde39da3bd77277b8707d81b4fdd37de1d1dbeeb1ee1133c0b3cfeefedfdd32ef6d20f5b3a60760ef7f7bb3b743d0d6b33a0a4bd16032aed71cf196c18ab220f69ef1c6cbfeda6fbdd837f9cfc2287dff869cb7ae1e0cd49e49364c9e6433fac6f487c9258967ccc6f809cca49de4b8a1170927e361dd429c7cc0218110c594fcac1002830b9be2c93f36c949c4d2723caa12822af8a41c927e7e5649257e372d4232f080c4faeb2c1344f80cfbdde394eaa7c526483e20f98f3ac2c07abdad25f9f1e1d50b8bdfe90ee1c75b74f0e8f361346e92fa63fbd826d9c3d6258803cf968cb33d2e1fb836ecc38f4b947cd08ea19ca78ec049e7be4107097f0c9cafc90dc001c94c965562567d92003d69c002322d01e95757206b01b1535879ab6beeef63eec7df743facbf671fa7a7b7ffb60a7ab61b33ec384c07ff4b71ac6bd81b70703d802b95ae08e819ba32697106798faf80a458fd383c393f4dde9ebfdbde35fba3a11c85976d86afb0559b99a0110eb7c926700b0bf35cc814fb1616e441f3a1bc0c0bd9b24ffbda8385774071530eafecfdef1c9b1c688e4a8dddfcff3bc57710c16a3c36a87d9efc5301b24a3e9f00ca054f6d939a5702d67c66c0403bbe9fbc3d3fd5d9867a7dbdd4d4d8eb0f7f6f4adc6d4e4d47ba36adaef17e705dc3d1c093802e8e3ef1d1c9fbe79b3b7b3d73d38b1cff907f70486f9e42267147a5db251abe4baa82f935ed1ef032ac8b98a9e390df0d4bddd94df25dda37fc8599e3be0521c2021e090b0ca0683f2dac4d2b77bb06c0338f2b6d2e1f2a336c741c9d8cc7936cece8a4151dfe8031e1c52c24d77b6df6dbfdedbdf3bf920c6f8494716b2b85db2363f9ef04b6bfb64db83273fa30312288fa76783a2ba34b7aa8d87d3cb9a3dde3161bf20bae5943ae90add018f81bf753d232224588d0162fc70ea12483ec98684ec9241069841c81d3e2aea8a7f8cccf70e809a6ebf3d3c8593dbdf0644384a0f8fd2eebf4eb7f7e1f0f8f9b1efd53564116abfc8073dc2f5294e4ea968a44ff566af0b18413625192b1fe9a98109c0b3a6f56539a157066c870c55e7163e50a6db453062fd990d71ba9e42bbc2d815680dc8b6b877906a2720c7d489eeb422a277d123c70742ef6372911613e021493dc94615d09b3ef2e9318092ecf9f0dd09197d77ef08b8447a72b47d70fc865c537c86e7eea9120aee4db2eb648d2d5b1ff6fddec92fbb47dbefd3ffd73d3a9483fce8438d4c20c765068b1e0d6ee8d5b38ee003953960b914238c43fac924d76101f8e52557ca0290c3f9d9cfdc47207213eca9cb321994a30bdf9d4104a293c3c374fff0e01ff2cef8c11a17b6111c508a56ce48cfad9140b4f20d42a42ee77de40c7af9b8ace829307ca4ac790d03fe21c8acef0e8f811619169263a6476cd1dec64fee2c947faeb12930e6d930a27e32ef05e68144079760fefb1810bc42f10fa4a0c337c043df015e1fa383b13d73b6401649f84272769394d7239356a840065873401050ad595ee16b31a372d9c3b9ae0f4323eb3cf5280702bf02d643f959459571463d5438cece6b07f279321dc3a54824dc1ba2f899b3b3594fdfed12860550ea1efd1bae44213eca3518ec94accec413b157e4be6527cbe7f965fbdf5dec809fea4cf6a8bcc90620a8172310d50b60da7dca1d41eec927047a6432fdee205ff6f25109446f03570811426d3c38054182827b17500ff80093eaf9229e218b186737792e24457a33d28d3a57a398e1ddf6876e37ddded9a1b7d5ee6197c9aaf41e97131962926232e22c9508331dc20553d143d4775c4dc7e3c10db6514b8a79fa1cd1dbc90d4f6600d3c6f4bc9e02f15034ba2c07545162229afe167b906335e1cdf48ae27617f253f436d9b77bbd8efc906b611c4184b85aad268784c54b83c3553ea9c8e64149a00add6576052f712dedacb8909b5e5f9543b331e9268df9084bd4f4458aa2549bd09443fee8f525ec055b44475dc5baee994d98105b11be0d2040d453b86ba550d649ae891c45ae6106aca276a7afd572a9e1850b135507f63fcaafdde511bda8a2662a2a7b586a2ff9b1d7bda91b7118ac6e15ee5d0c4a10f041ed2afe4b546220a2ba00c642958b4cbbd77504d8eb2914e800fa8d6f3a490fe6d0d0819f7c2117795e0e87e54817d0abcb6cc23852ad6e1da510d83bb7f647864825d211785b8847104100adec1b8006c21a6f31f867497f3aba28086fae05c76647d0b38f20d18e803271583c518ad1e3a07261f6911c3a11" <> ...,
source_map: "0x"
},
%{
extension: %{vec: []},
name: "token_coin_swap",
source: "0x1f8b08000000000002ffcd575f6fdb36107fcfa7e0d3da0246b23f5d37a85d81cc515ba3891d24ceba3d11b444c74464d220a9a45e91efbee3919468496e83210be617593cdeffbbdf9d8e8e8ec809df685e30cb4bb256655df103ff206c6395a156dd709965f8a08512929a3bb6215f0e08fc6ac389b1659619ab85bcceb24b7cbede2572ad956ecfbc5ca458b6a87896cddd63f8c276c3a9904b0597e0ef04fe75ef2d355bf33ba56f40d12d9736cb72f7f8c064d9179a7a93655fe6ee3922f89894f7af0ff0fad1517890dc596e0ee369781e7906c22acd59b9259530103d24164a1a4bf2f9ec633ea5c7a717f9f1c95ff4747239cf4f3252bf7a497e233fbceeca71fc10352215a994bce69af0cf7064fa129da4c9f43d9dcee634ff135ea2d01f7b42850179960849b829b4baeb0b734226539a5f8e2f669fa2a09f7a820a269da00587f2b8852251b5256a19a4c2f152694eec8a83edc54dbd2156ac795fd9f878eaf49dcdfec8e9ec6a4e67ef8262fa7bfe6e7691d3d3d9f8e3d5399d4fcef268cbcb9e2d8b7a4b365a149c948a1bf9cc9235b3c5aa8920d2facacfc0cdf38bc938479fcf8ee7e30f51c7cf833ad85ad5d2ee51e28903e93e9b5d4de77d15af121553882497aabe5e11d74bc42ad487f5984ac4044f6757ef3fd0f16c328da27e4944f5fb36e13fc9cf2ff2f131941d84fce4eab489e9af5d7fc760c6a5eb6810a674690823d8e0ccdc10482dbe6c9cdb1e014264ee845d11c7eabad2bf31b21652ac591532b4813a6efd0280a80bbbabf2cd66c5a455eb46d05bb26206ae42458d48a9558419f74bd5a333a386047a29eaa4a033b4787be33e71d85569c8229430ab2a2fd6ec7a8a069484594f25ea4e72fd0c2253144de6537f4ebd48b3c79f1bbe4dfc0033dc01b4a7eb19af4094bb060074915b56d53c5e030f4354c16ccbf435b7a17e40cb61233bf866328288fa26e0daa813f6c6bcb7a32e2b450805010986be499dc4f384cfd9bc9fc9a94b39ee3bc5977b1059a9aa4ce2e1fe42f05be071f5556a7607a9809ad24c9a25cc9400b96926a2bc5845ddfac9fcb5519a0dc8a8a81a0083bc3b0023ba063300ea4648c10a880639184c9217f0d01d24481b84bbd3922f595dd936a3df933567127b2a95dd0ac6d43ab94c6e1b38c52ca185144da68617664f9d63ec5d0076020c1d0a8ded6c8d5507f003fa4468d4bc353f0dea8ea05e3dfbbef49eef293ccfbb5b0203fd8385821a5ceb8f8633484599c579dda6f1ebb0d039ff5a103d840263bb7890b878ecb5bfa9f27f67bc27c118e03a23ac2c353766f410dc4343f753bee5c2a65e54a220cb5ae2a0a30d04b8e5a30589e78d540fad140b76c052daf311492f32b250aa4a62c1164ac31874bb559609097d214a0aa056af2186cffbb3eb45b7bec7d81fd837111a9a718ac30b0752c012bf9d7500d6a60d1ce1dd3b74d80d0eff5c00ae5f73bffd821cefe86084f04a08d077465cc39f51873a98b06f85b6804d132acad0401abca3aa8a1756288039bf872744094bf2c0f1068a956bbba5b75c1be41c32ab67f28bc7cce6bccd0226cba498b493b73433205c6f313f8e2718ea92637646dcbeea1d48ceff2bc4487310864533b4d8e08d61307bfc244da4b0c0f4773af9e22ae552c4d266422e971a5808ad40b6e0666049f233989647363dd890989e4cea413b11bec3547b0213cfeb1490042c91f1fbaab30925cb8fdb8522fac1db62db6e133d082bf9461911bbc4aae8d9839be32be3cbd34c6fb57ab2d23cd7e2163e839ca3d89a588fcd5c880bbe86bd9cc5c4c7151f47468b3ea1e19bb2884222ba808c103998ab966bc9aae11022863c684426b40402e2e0f4d0f888b1fa3414966e5b1c9289259273ff3188a5e0262babed4a69e8916e75ed0fd3e314d8530466cc64c1ab41605b8acfee6bb0fdea4f5c2f906d2fb83d5e7ffd3733f8fee01fc8dd27dd02140000",
source_map: "0x"
},
%{
extension: %{vec: []},
name: "token_transfers",
source: "0x1f8b08000000000002ffd5596d6fdb3610fe9e5fc17a80270d422d752f2894261850a46831a019d6001b1004822cd18e1059f448caa957e4bf8f6f92488a929dc6495a7f88c297e31def9e7b789466b319b8b82e0858a1bc2e215863b429724800bd866081ea2a4f69812af62f0614a71559408c8b6a09d0025ca01b5891232599ae292209e57d712c1e492340c09723c07e358180d03c8e49b1ac203eb63a295f388e3f89a735c8b4224d402a1323349d97308ebf7c82e5220017bc75674fd4adeaa6f2967a7cc87b320b9caee02dc237719c6619f3041d990137b0a2edca67bcf53ead72618a909acdd4039cf19d90974daf7acea41dccadcc5f204790543f52003f17848a1919aa08056717e77f9c7d4ccedfbd3bfb2bf9787e919cfdf3e1d3450ceadf7e01272052ba9823eb8c823f61953347be2dd36245c0754ac00ddcaa48f0df5a8e279998104bd7bd11669c732b3ee4ca39a7412b23cc4bc46e9984b64f4d4ef46a32595a65b04c7688be15b3dc0b70034724f9b02e7367b841df90f04286d6db00e418ad03360761a8f984a224cd731c03fe17121268231cd1451e378019d725ec11ea46153115fbebe2bf74c59128223e6880edcae732a38dcb131ab0a82b5054052dd2b2f80f26160f792a9363309514e46ba6acd0860b786d87d0230502a3d3ccac2fc6982bb3144555f0d6995e9e1ff49630b3a5319b2f213b936b77da353b742ce9ccc31d2bf7b2726c7d234d772ddc25edc092776dcbb7039c6198d226b8723f45eef572b78f1f3f36e9a00bdd40b706d1c0ea944b1f99e62a23d7f5bc2c32c07687b7c2626924c970b1a61dc008c30964064b2c760a30cc60b1812e1a125b47ce11549630e387750ce411da8d55eca0eaf7b2b37e0d31dd264c1511726d363953cc6741fdb72e98dac10c28216d5dc34e2475e01af12af204a7b79eda48a0d91d083b839e5dfeb179fe7853e9b8a0755417ea4099ad64cc78b491e887607a8f18dc8796f6f4993443e08cb94ddac2ea0ea99941dc9313344f140be0bd10f5017963ac7cea698bf9be05e6116e542a3a44ab72a2b1d164357062ac3b5dd514cc11ab6d6e936589e66999b09e31cb5e9aeb1d3b30d4a43673893be5fbf1f71deb7440bc2de875ced027d7f11a180d80a775b3e26f5683d1b4a888675a1e58d6f67caec4d9ae7748aab6a6fe0ec092406b3dbeb19cd0a4dd9c5c5f799fb97d9781c77d2a8be315c44be8b5eb3a6cd1f0a0ea5db82aa824f7fe41f45078e8e794c9bd7695d53f80f5aaa2c58863960a7b6f44c2c03a8fbaa6935c3ab29707a14df61da1d854d370d07391fd37c0ebc265deb4cb673b3507f95c4a3abc3cdddbcd037cbea75b0e468b076144c7d1d1b8c477b2644a088bc90bef9e1c1700712367e51da289784fe0b92fa7be8b9149c75a18f2ba7b7fc6e26bc8f4ec70b8848ab41239e24da5164d4ccdcce11a9142cdb68f0f3e7f17c3e975eb0322add7ca0e72d3ae4ee3e4361aeea7233cfd66f1fd14b9df02ef699e1b2b6bcd00f0b7489f59e1061618ad00aab14d42eca2c516a135aed80a6099328bf0b6c79cbaeec728881fadf63d6485f8e455ed9350df2ee6338ed77d68aff71ee0a17e72bc8d7011a1fd2aeb996bbd1f2e2924b449761686dfc3cf5100d02dc3ac6cbdf2afec44e32249b568c55a2e94724df3fe74a443de9bb60c14f9d6cd4d8d8ca458236ca14dd837262626e8d5c4c0abf39633559b950c3811aeec54f4aff9ed8eba49fa652dea17906262606cd8c8fc235bc5a880a5c2e0ea5d9af6044da850a39a916cfe3c00229817fc60215effa8b4e95aae3ed01f99fd0743deabc3222fdc09bdf0e1d80b6df0b5eaa39deaa387ab8f1af5e3e00f47a1e914899c22fdc25f9e0f8cb339bec5793b12250de3e0e40484c35918ee488efbdba0226e99100d9b103d8e09d180094e6e0947a33160b533e4431aa2fde8eb2b449455e3b072715d82aa727b357059d0a9a3a5afa6dcd4dfa0fa6d3da91151ef73b1fae62aeb7efb9d65578c27bc16e7b9acc46aba78edcd27ef6159a200fc8d70994f2c12d084593523be83270452ca3f7f9f800d1b42f8cd1ca1f2f47291b2d77401d01f570fa10607f69a0cd46160de473a7bcdeaac899fd1f9d3d4f28d396cb9e9ad76ef325d362a764de99ac4b39970c0cb1c6eecf991d91cf1b85191398ea5af8850fb601f2df57089f7ab7091d6254dd82773d22d2541767a696d33a534cd6ed8deecfd57f58a852e61989df8030a36cc844e817ad4af4f4f2fe793289c04603ef97532204bb76bb8dbbaa2a27009b1c3bc76e4ea780052d2b7f695fe40a012c9dde249b476e0696caaab8e77f5dd17a223a96861390ccd8ed0f5c97018d7fca7c3ce3dc2f1e21e1168e85d5c8662aa5e5b7cdd560f1ee7b0f7b1f7eee87f7b3e96f49b240000",
source_map: "0x"
}
],
name: "AptosToken",
source_digest: "FFBEF1C9EE50AF0580D24B04432CFDE16B416E82D08782A2F0976939C50D1FFF",
upgrade_number: "4",
upgrade_policy: %{policy: 1}
}
]
},
type: "0x1::code::PackageRegistry"
}
]}
```
#### 4.3.2 Read resource by resource_type
```elixir
Web3AptosEx.Aptos.RPC.get_resource(client, "0x3", "0x1::account::Account")
```
<!-- livebook:{"output":true} -->
```
{:ok,
%{
data: %{
authentication_key: "0x0000000000000000000000000000000000000000000000000000000000000003",
coin_register_events: %{counter: "0", guid: %{id: %{addr: "0x3", creation_num: "0"}}},
guid_creation_num: "2",
key_rotation_events: %{counter: "0", guid: %{id: %{addr: "0x3", creation_num: "1"}}},
rotation_capability_offer: %{for: %{vec: []}},
sequence_number: "0",
signer_capability_offer: %{for: %{vec: []}}
},
type: "0x1::account::Account"
}}
```
#### 4.3.2 Read the item in Table
💡 You could get handle in Explorer:
> https://explorer.aptoslabs.com/account/0x2df41622c0c1baabaa73b2c24360d205e23e803959ebbcb0e5b80462165893ed/resources
```elixir
Web3AptosEx.Aptos.RPC.get_table_item(
client,
"0xe30b2ff6a515aa04729522512d50147d5cdd52ee3741c26ff1b97306b0b2b148",
"0x1::string::String",
"0x65f4a0954aa6e68d2381ff98b7676df2fe57beee3ca37a4a8a57fa621c1db872::addr_info::AddrInfo",
"0x73c7448760517E3E6e416b2c130E3c6dB2026A1d"
)
```
<!-- livebook:{"output":true} -->
```
{:ok,
%{
addr: "0x73c7448760517E3E6e416b2c130E3c6dB2026A1d",
addr_type: "0",
chains: ["ethereum"],
created_at: "1673525423",
description: "A Test Addr",
expired_at: "1705061423",
id: "1",
msg: "50789538.1.nonce_geek",
pubkey: "",
signature: "0x",
updated_at: "0"
}}
```
### 4.4 Send Tx
```elixir
# Call function
f = ~A"0x1::coin::transfer<CoinType>(address,u64)"f
payload = Aptos.call_function(f, ["0x1::aptos_coin::AptosCoin"], [account.address, 100])
Aptos.submit_txn(client, account, payload)
```
<!-- livebook:{"output":true} -->
```
<<255, 69, 60, 40, 182, 83, 17, 215, 241, 101, 86, 129, 123, 192, 62, 70, 13, 172, 128, 131, 119,
175, 118, 53, 133, 48, 43, 65, 212, 38, 216, 1>>
```
## 0x06 Contributing
Bug report or pull request are welcome.
## 0x07 Make a pull request
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
Please write unit test with your code if necessary.
## 0x08 License
web3_aptos_ex is available as open source under the terms of the [MIT License](./LICENSE.md).