ABCDEFGHIJKLMNOPQRSTUVWXY
1
StatusNameDescriptionRefRelated Patterns
2
Include fail-safe mechanismsIt is important to have some way to update the contract in the case some bugs will be discovered. Incorporate an emergency stop functionality into the SC that can be triggered by an authenticated party to disable sensitive functions. The fail-safe mechanism, if implemented using theProxy Delegate, could be also exploited for forwarding calls and data to another contract, which is an updated version of the current one (for instance, a version where the bug has been fixed).43SB, RL, TE, PD, OW
3
Never assume that a contract has zero balance
Be aware of coding an invariant that strictly checks the balance of a contract. An attacker can forcibly send ether to any account and this cannot be prevented.10CEI, MH, GC
4
State ChannelIn some contexts, transactions either have too high fee compared to their value, or must have low latency. In these cases, rather than performing each blockchain transaction, it is possible to firstly perform the operations outside the blockchain, and then register all the results batching the requests in a unique blockchain transaction.44, 33RL
5
Limit the amount of etherIf the code, the compiler or the platform has a bug, the funds stored inyour smart contract may be lost, so limit the maximum amount. Checkthat all money transfers are performed through explicit withdrawalsmade by the beneficiary.2RL, BL, AU
6
Beware of transaction orderingMiners have the power to alter the order of transactions arriving inshort times. Inconsistent transactions’ orders, with respect to the timeof invocations, can cause race conditions.35TC
7
Be careful with multiple inheritanceSolidity uses the "C3 linearization". This means that when a contract isdeployed, the compiler will linearize the inheritance from right to left.Multiple overrides of a function in complex inheritance hierarchiescould potentially interact in tricky ways.10PD, REU
8
Use trustworthy dependenciesUse audited and trustworthy dependencies to existing SCs and ensurethat newly written code is minimized by using libraries.10REU
9
Withdrawal from ContractsWhen you need to send Ethers or tokens to an address, don’t sendthem directly. Instead, authorize the address’ owner to withdraw thefunds, and let s/he perform the job.39, 13CEI
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100