# Smart Contract Design Pattern for Processing Logically Coherent Transaction Types
## 3 The Pattern Design and Implementation
### Concrete Layer
Each test has been repeated 50 times to obtain the mean value of \(E_{n}^{sc}\). Tests were conducted for the smart contracts with 3, 4, and 5 verification rules. A total of 450 tests were run. Figure 7 depicts test results for the number of transactions in the following range, \(n\in\langle 100,000;10,000,000\rangle\). The results in the figure are presented on a logarithmic scale. \begin{table}
\begin{tabular}{c c} \hline \hline
**No of Transactions** & \(O_{T}^{sc}\) \\ \hline
1 & 6 \\
100 & 0.06 \\
10,000 & 0.0006 \\
1,000,000 & 0.000006 \\
100,000,000 & 0.0000006 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Values of \(O_{T}^{sc}\) for the considered smart contract. ```
packagetests; importadapT.AbstractSmartContract; importadapT.AbstractTransaction; publicclassTestContract[ privatestaticint[]numberTransactions=newint[][100000,1000000, 10000000]; privatestaticlongconductTest(AbstractSmartContractSC, AbstractTransactiontR,intnumberTransactions,intrepetitions){ booleancorrect=false; longsum=0; longstartTime=0,endTime=0; for(intj=0;j<=repetitions;j++){ startTime=System.nanoTime(); for(inti=0;i<numberTransactions;i++)correct=sC.checkSC(tR); endTime=System.nanoTime(); if(j>0)sum=sum+(endTime-startTime); } returnsum/repetitions; } publicstaticvoidrunTests(AbstractSmartContractsSC,AbstractTransactiontR,intrepetitions){ longexecutionTime=0; //smartcontractevaluationtime System.out.println(''Evaluationtimeoftransaction:''+tR.getClass()); for(intnumberTransaction:numberTransactions){ System.out.println(''Numberofprocessedtransactions:''+numberTransaction); executionTime=conducttTest(sC,tR,numberTransaction,repetitions); System.out.println(''Executiontime:''+executionTime); } }
```

Figure 7: Smart contract evaluation time, \(n\in\langle 100,000;10,000,000\rangle\). One of the facts that stem from the results presented in Figure 7 deserves to be emphasized. The evaluation time of 10,000,000 transactions is below 0.25 s, regardless of the considered number of verification rules in the smart contract. Currently, the Solana blockchain framework is regarded as one of the quickest offering a throughput of up to several dozen thousand transactions per second [44]. The results obtained illustrate the performance potential of smart contacts designed according to the pattern. It is also worth visualizing the mean evaluation time of a single transaction. Figure 8 shows the values for this measure calculated from the results obtained when evaluating the considered transaction volumes. Results are shown on a linear scale and are expressed in nanoseconds. The average time to check a single transaction is practically constant and is approximately 25 nanoseconds. This means that the smart contract validation mechanism in the pattern has been designed correctly. The increase in evaluation time is directly proportional to the number of transactions evaluated. ## 6 Discussion and Limitations

In the construction of the pattern, two layers have been distinguished: abstract and specific to a particular smart contract. The use of an abstract layer is a recommended software design practice. Recently, Spray et al. [45] have shown the positive impact of the Abstraction Layered Architecture on software reusability and testability. The abstract layer of the _AdapT_ pattern is free of implementation-specific classes or interfaces. The layer consists of two abstract classes and uses only interfaces from Java Standard Edition packages, i.e., _List_ and _Predicate_. The _VerificationRule_ interface is not needed anymore. Instead, verification rules are handled by the _Predicate_ functional interface. Additionally, the abstract smart contract class is independent of any specific transaction class. Generally, both abstract classes in the abstract layer are in this version of the pattern completely independent of the implementation of a specific smart contract. Thanks to this, those abstract classes are reusable without the need for any changes. The construction of the concrete layer has also been simplified.