Docs
Search…
Safe transfer
Many cryptocurrencies are plagued by the problem of users losing coins by making a mistake with the public key they are transferring to and discovering that the private key they thought would control the money doesn't work. Pact allows you to construct coin transfers in a way that guarantees that someone is in possession of the correct private key and it will work to access the coins. This transaction does this by doing two transfers in a single transaction, one from alice to bob for the desired amount plus a small amount extra coins for a test transfer, and one from bob to alice transferring back the extra amount.
This is most important when you are doing transfer-create because that is when you are defining the new account's keyset.

Signing

This transaction must be signed by both the alice and bob accounts and each signature must have the appropriate coin.TRANSFER capability. In this example, the public key for the account alice is 6be2f485a7af75fedb4b7f153a903f7e6000ca4aa501179c91a2450b777bd2a7 and the public key for bob is 368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca.

Transaction Template

1
code: |-
2
(coin.transfer-create "alice" "bob" (read-keyset "ks") 200.1)
3
(coin.transfer "bob" "alice" 0.1)
4
data:
5
ks:
6
keys: [368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca]
7
pred: "keys-all"
8
publicMeta:
9
chainId: "0"
10
sender: alice
11
gasLimit: 1200
12
gasPrice: 0.00001
13
ttl: 7200
14
networkId: "mainnet01"
15
signers:
16
- public: 6be2f485a7af75fedb4b7f153a903f7e6000ca4aa501179c91a2450b777bd2a7
17
caps:
18
- name: "coin.TRANSFER"
19
args: ["alice", "bob", 200.1]
20
- name: "coin.GAS"
21
args: []
22
- public: 368820f80c324bbc7c2b0610688a7da43e39f91d118732671cd9c7500ff43cca
23
caps:
24
- name: "coin.TRANSFER"
25
args: ["bob", "alice", 0.1]
26
type: exec
Copied!
Last modified 1mo ago