diff --git a/dotnet/Examples/README.md b/dotnet/Examples/README.md index 7130b034a..be28588d4 100644 --- a/dotnet/Examples/README.md +++ b/dotnet/Examples/README.md @@ -1,17 +1,212 @@ # Examples -- [CallSmartContractFunction](./CallSmartContractFunction/Program.cs) +- [CallSmartContractFunction](./CallSmartContractFunction//CallSmartContractFunction/Program.cs) +using System; +using System.Numerics; +using System.Threading.Tasks; +using In3; +using In3.Configuration; +using In3.Eth1; +using In3.Utils; -- [ConnectToEthereum](./ConnectToEthereum/Program.cs) +namespace CallSmartContractFunction +{ + public class Program + { + public static async Task Main() + { + IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); + ClientConfiguration cfg = mainnetClient.Configuration; + cfg.Proof = Proof.Standard; -- [EnsResolver](./EnsResolver/Program.cs) + string contractAddress = "0x2736D225f85740f42D17987100dc8d58e9e16252"; -- [Ipfs](./Ipfs/Program.cs) + TransactionRequest serverCountQuery = new TransactionRequest(); + serverCountQuery.To = contractAddress; -- [Logs](./Logs/Program.cs) + serverCountQuery.Function = "totalServers():uint256"; + serverCountQuery.Params = new object[0]; -- [SendTransaction](./SendTransaction/Program.cs) + string[] serverCountResult = (string[])await mainnetClient.Eth1.Call(serverCountQuery, BlockParameter.Latest); + BigInteger servers = DataTypeConverter.HexStringToBigint(serverCountResult[0]); + + for (int i = 0; i < servers; i++) + { + TransactionRequest serverDetailQuery = new TransactionRequest(); + serverDetailQuery.To = contractAddress; + + serverDetailQuery.Function = "servers(uint256):(string,address,uint32,uint256,uint256,address)"; + + string[] serverDetailResult = (string[])await mainnetClient.Eth1.Call(serverDetailQuery, BlockParameter.Latest); + Console.Out.WriteLine($"Server url: {serverDetailResult[0]}"); + } + } + } +} + +- [ConnectToEthereum](./ConnectToEthereum//ConnectToEthereum/Program.cs) +using System; +using System.Numerics; +using System.Threading.Tasks; +using In3; + +namespace ConnectToEthereum +{ + class Program + { + static async Task Main() + { + Console.Out.WriteLine("Ethereum Main Network"); + IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); + BigInteger mainnetLatest = await mainnetClient.Eth1.BlockNumber(); + BigInteger mainnetCurrentGasPrice = await mainnetClient.Eth1.GetGasPrice(); + Console.Out.WriteLine($"Latest Block Number: {mainnetLatest}"); + Console.Out.WriteLine($"Gas Price: {mainnetCurrentGasPrice} Wei"); + + Console.Out.WriteLine("Ethereum Kovan Test Network"); + IN3 kovanClient = IN3.ForChain(Chain.Kovan); + BigInteger kovanLatest = await kovanClient.Eth1.BlockNumber(); + BigInteger kovanCurrentGasPrice = await kovanClient.Eth1.GetGasPrice(); + Console.Out.WriteLine($"Latest Block Number: {kovanLatest}"); + Console.Out.WriteLine($"Gas Price: {kovanCurrentGasPrice} Wei"); + + Console.Out.WriteLine("Ethereum Goerli Test Network"); + IN3 goerliClient = IN3.ForChain(Chain.Goerli); + BigInteger goerliLatest = await goerliClient.Eth1.BlockNumber(); + BigInteger clientCurrentGasPrice = await goerliClient.Eth1.GetGasPrice(); + Console.Out.WriteLine($"Latest Block Number: {goerliLatest}"); + Console.Out.WriteLine($"Gas Price: {clientCurrentGasPrice} Wei"); + } + } +} + +- [EnsResolver](./EnsResolver//EnsResolver/Program.cs) +using System; +using System.Threading.Tasks; +using In3; + +namespace EnsResolver +{ + public class Program + { + static async Task Main() + { + IN3 in3 = IN3.ForChain(Chain.Mainnet); + + string cryptoKittiesDomain = "cryptokitties.eth"; + string resolver = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Resolver); + string owner = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Owner); + + Console.Out.WriteLine($"The owner of {cryptoKittiesDomain} is {owner}, resolver is {resolver}."); + } + } +} + +- [Ipfs](./Ipfs//Ipfs/Program.cs) +using System; +using System.Text; +using System.Threading.Tasks; +using In3; + +namespace Ipfs +{ + class Program + { + static async Task Main() + { + string toStore = "LOREM_IPSUM"; + + IN3 ipfsClient = IN3.ForChain(Chain.Ipfs); + + string hash = await ipfsClient.Ipfs.Put(toStore); + + byte[] storedBytes = await ipfsClient.Ipfs.Get(hash); + string storedStging = Encoding.UTF8.GetString(storedBytes, 0, storedBytes.Length); + Console.Out.WriteLine($"The stored string is: {storedStging}"); + } + } +} + +- [Logs](./Logs//Logs/Program.cs) +using System; +using System.Threading; +using System.Threading.Tasks; +using In3; +using In3.Eth1; + +namespace Logs +{ + class Program + { + static async Task Main() + { + int maxIterations = 500; + + IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); + + LogFilter tetherUsFilter = new LogFilter {Address = "0xdAC17F958D2ee523a2206206994597C13D831ec7"}; + + long filterId = await mainnetClient.Eth1.NewLogFilter(tetherUsFilter); + + for (int i = 0; i < maxIterations; i++) + { + Log[] tetherLogs = await mainnetClient.Eth1.GetFilterChangesFromLogs(filterId); + if (tetherLogs.Length > 0) + { + Console.Out.WriteLine("Logs found: " + tetherLogs.Length); + break; + } + + Thread.Sleep(oneSecond); + } + } + } +} + +- [SendTransaction](./SendTransaction//SendTransaction/Program.cs) +using System; +using System.Threading; +using System.Threading.Tasks; +using In3; +using In3.Crypto; +using In3.Eth1; + +namespace SendTransaction +{ + public class Program + { + static async Task Main() + { + IN3 goerliClient = IN3.ForChain(Chain.Goerli); + + string myPrivateKey = "0x0829B3C639A3A8F2226C8057F100128D4F7AE8102C92048BA6DE38CF4D3BC6F1"; + string receivingAddress = "0x6FA33809667A99A805b610C49EE2042863b1bb83"; + + SimpleWallet myAccountWallet = (SimpleWallet)goerliClient.Signer; + + string myAccount = myAccountWallet.AddRawKey(myPrivateKey); + + TransactionRequest transferWei = new TransactionRequest(); + transferWei.To = receivingAddress; + transferWei.From = myAccount; + transferWei.Value = 300; + + long currentGasPrice = await goerliClient.Eth1.GetGasPrice(); + transferWei.GasPrice = currentGasPrice; + + long estimatedSpentGas = await goerliClient.Eth1.EstimateGas(transferWei, BlockParameter.Latest); + Console.Out.WriteLine($"Estimated gas to spend: {estimatedSpentGas}"); + + string transactionHash = await goerliClient.Eth1.SendTransaction(transferWei); + Console.Out.WriteLine($"Transaction {transactionHash} sent."); + Thread.Sleep(30000); + + TransactionReceipt receipt = await goerliClient.Eth1.GetTransactionReceipt(transactionHash); + Console.Out.WriteLine($"Transaction {transactionHash} mined on block {receipt.BlockNumber}."); + } + } +} ### Build Examples diff --git a/dotnet/docs/examples.md b/dotnet/docs/examples.md index 964b7cd83..150e20bc5 100644 --- a/dotnet/docs/examples.md +++ b/dotnet/docs/examples.md @@ -2,26 +2,29 @@ ### CallSmartContractFunction -source : [in3-c/dotnet/Examples/CallSmartContractFunction](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/CallSmartContractFunction/Program.cs) +source : [in3-c/dotnet/Examples/CallSmartContractFunction//CallSmartContractFunction](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/CallSmartContractFunction//CallSmartContractFunction/Program.cs) ```c# using System; using System.Numerics; +using System.Threading.Tasks; using In3; +using In3.Configuration; using In3.Eth1; +using In3.Utils; namespace CallSmartContractFunction { public class Program { - public static void Main() + public static async Task Main() { // Set it to mainnet IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); ClientConfiguration cfg = mainnetClient.Configuration; - cfg.Proof = Proof.None; + cfg.Proof = Proof.Standard; string contractAddress = "0x2736D225f85740f42D17987100dc8d58e9e16252"; @@ -33,7 +36,7 @@ namespace CallSmartContractFunction serverCountQuery.Function = "totalServers():uint256"; serverCountQuery.Params = new object[0]; - string[] serverCountResult = (string[])mainnetClient.Eth1.Call(serverCountQuery, BlockParameter.Latest); + string[] serverCountResult = (string[])await mainnetClient.Eth1.Call(serverCountQuery, BlockParameter.Latest); BigInteger servers = DataTypeConverter.HexStringToBigint(serverCountResult[0]); for (int i = 0; i < servers; i++) @@ -45,48 +48,51 @@ namespace CallSmartContractFunction serverDetailQuery.Function = "servers(uint256):(string,address,uint32,uint256,uint256,address)"; serverDetailQuery.Params = new object[] { i }; // index of the server (uint256) as per solidity function signature - string[] serverDetailResult = (string[])mainnetClient.Eth1.Call(serverDetailQuery, BlockParameter.Latest); + string[] serverDetailResult = (string[])await mainnetClient.Eth1.Call(serverDetailQuery, BlockParameter.Latest); Console.Out.WriteLine($"Server url: {serverDetailResult[0]}"); } } } +} + ``` ### ConnectToEthereum -source : [in3-c/dotnet/Examples/ConnectToEthereum](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/ConnectToEthereum/Program.cs) +source : [in3-c/dotnet/Examples/ConnectToEthereum//ConnectToEthereum](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/ConnectToEthereum//ConnectToEthereum/Program.cs) ```c# using System; using System.Numerics; +using System.Threading.Tasks; using In3; namespace ConnectToEthereum { class Program { - static void Main() + static async Task Main() { Console.Out.WriteLine("Ethereum Main Network"); IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); - BigInteger mainnetLatest = mainnetClient.Eth1.BlockNumber(); - BigInteger mainnetCurrentGasPrice = mainnetClient.Eth1.GetGasPrice(); + BigInteger mainnetLatest = await mainnetClient.Eth1.BlockNumber(); + BigInteger mainnetCurrentGasPrice = await mainnetClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {mainnetLatest}"); Console.Out.WriteLine($"Gas Price: {mainnetCurrentGasPrice} Wei"); Console.Out.WriteLine("Ethereum Kovan Test Network"); IN3 kovanClient = IN3.ForChain(Chain.Kovan); - BigInteger kovanLatest = kovanClient.Eth1.BlockNumber(); - BigInteger kovanCurrentGasPrice = kovanClient.Eth1.GetGasPrice(); + BigInteger kovanLatest = await kovanClient.Eth1.BlockNumber(); + BigInteger kovanCurrentGasPrice = await kovanClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {kovanLatest}"); Console.Out.WriteLine($"Gas Price: {kovanCurrentGasPrice} Wei"); Console.Out.WriteLine("Ethereum Goerli Test Network"); IN3 goerliClient = IN3.ForChain(Chain.Goerli); - BigInteger goerliLatest = goerliClient.Eth1.BlockNumber(); - BigInteger clientCurrentGasPrice = goerliClient.Eth1.GetGasPrice(); + BigInteger goerliLatest = await goerliClient.Eth1.BlockNumber(); + BigInteger clientCurrentGasPrice = await goerliClient.Eth1.GetGasPrice(); Console.Out.WriteLine($"Latest Block Number: {goerliLatest}"); Console.Out.WriteLine($"Gas Price: {clientCurrentGasPrice} Wei"); } @@ -96,25 +102,26 @@ namespace ConnectToEthereum ### EnsResolver -source : [in3-c/dotnet/Examples/EnsResolver](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/EnsResolver/Program.cs) +source : [in3-c/dotnet/Examples/EnsResolver//EnsResolver](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/EnsResolver//EnsResolver/Program.cs) ```c# using System; +using System.Threading.Tasks; using In3; namespace EnsResolver { public class Program { - static void Main() + static async Task Main() { IN3 in3 = IN3.ForChain(Chain.Mainnet); string cryptoKittiesDomain = "cryptokitties.eth"; - string resolver = in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Resolver); - string owner = in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Owner); + string resolver = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Resolver); + string owner = await in3.Eth1.Ens(cryptoKittiesDomain, ENSParameter.Owner); Console.Out.WriteLine($"The owner of {cryptoKittiesDomain} is {owner}, resolver is {resolver}."); } @@ -122,15 +129,105 @@ namespace EnsResolver } ``` +### Ipfs + +source : [in3-c/dotnet/Examples/Ipfs//Ipfs](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/Ipfs//Ipfs/Program.cs) + + + +```c# +using System; +using System.Text; +using System.Threading.Tasks; +using In3; + +namespace Ipfs +{ + class Program + { + static async Task Main() + { + // Content to be stored + string toStore = "LOREM_IPSUM"; + + // Connect to ipfs. + IN3 ipfsClient = IN3.ForChain(Chain.Ipfs); + + // Store the hash since it will be needed to fetch the content back. + string hash = await ipfsClient.Ipfs.Put(toStore); + + // + byte[] storedBytes = await ipfsClient.Ipfs.Get(hash); + string storedStging = Encoding.UTF8.GetString(storedBytes, 0, storedBytes.Length); + Console.Out.WriteLine($"The stored string is: {storedStging}"); + } + } +} + +``` + +### Logs + +source : [in3-c/dotnet/Examples/Logs//Logs](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/Logs//Logs/Program.cs) + + + +```c# +using System; +using System.Threading; +using System.Threading.Tasks; +using In3; +using In3.Eth1; + +namespace Logs +{ + class Program + { + static async Task Main() + { + // Define an upper limit for poll since we dont want our application potentially running forever. + int maxIterations = 500; + int oneSecond = 1000; // in ms + + // Connect to mainnet. + IN3 mainnetClient = IN3.ForChain(Chain.Mainnet); + + // Create a filter object pointing, in this case, to an "eventful" contract address. + LogFilter tetherUsFilter = new LogFilter {Address = "0xdAC17F958D2ee523a2206206994597C13D831ec7"}; + + // Create the filter to be polled for logs. + long filterId = await mainnetClient.Eth1.NewLogFilter(tetherUsFilter); + + // Loop to initiate the poll for the logs. + for (int i = 0; i < maxIterations; i++) + { + // Query for the log events since the creation of the filter or the previous poll (this method in NOT idempotent as it retrieves a diff). + Log[] tetherLogs = await mainnetClient.Eth1.GetFilterChangesFromLogs(filterId); + if (tetherLogs.Length > 0) + { + Console.Out.WriteLine("Logs found: " + tetherLogs.Length); + break; + } + + // Wait before next query. + Thread.Sleep(oneSecond); + } + } + } +} + +``` + ### SendTransaction -source : [in3-c/dotnet/Examples/SendTransaction](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/SendTransaction/Program.cs) +source : [in3-c/dotnet/Examples/SendTransaction//SendTransaction](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/SendTransaction//SendTransaction/Program.cs) ```c# using System; using System.Threading; +using System.Threading.Tasks; using In3; using In3.Crypto; using In3.Eth1; @@ -139,7 +236,7 @@ namespace SendTransaction { public class Program { - static void Main() + static async Task Main() { IN3 goerliClient = IN3.ForChain(Chain.Goerli); @@ -158,17 +255,17 @@ namespace SendTransaction transferWei.Value = 300; // Get the current gas prices - long currentGasPrice = goerliClient.Eth1.GetGasPrice(); + long currentGasPrice = await goerliClient.Eth1.GetGasPrice(); transferWei.GasPrice = currentGasPrice; - long estimatedSpentGas = goerliClient.Eth1.EstimateGas(transferWei, BlockParameter.Latest); + long estimatedSpentGas = await goerliClient.Eth1.EstimateGas(transferWei, BlockParameter.Latest); Console.Out.WriteLine($"Estimated gas to spend: {estimatedSpentGas}"); - string transactionHash = goerliClient.Eth1.SendTransaction(transferWei); + string transactionHash = await goerliClient.Eth1.SendTransaction(transferWei); Console.Out.WriteLine($"Transaction {transactionHash} sent."); Thread.Sleep(30000); - TransactionReceipt receipt = goerliClient.Eth1.GetTransactionReceipt(transactionHash); + TransactionReceipt receipt = await goerliClient.Eth1.GetTransactionReceipt(transactionHash); Console.Out.WriteLine($"Transaction {transactionHash} mined on block {receipt.BlockNumber}."); } } diff --git a/python/docs/documentation.md b/python/docs/documentation.md index dfb94927d..7384d956c 100644 --- a/python/docs/documentation.md +++ b/python/docs/documentation.md @@ -56,7 +56,7 @@ Explanation of this source code architecture and how it is organized. For more o - **in3.eth.api**: Ethereum API. - **in3.eth.account**: Ethereum accounts. - **in3.eth.contract**: Ethereum smart-contracts API. -- **in3.eth.model**: MVC Model classes for the Ethereum client module domain. Manages serializaation. +- **in3.eth.model**: MVC Model classes for the Ethereum client module domain. Manages serialization. - **in3.eth.factory**: Ethereum Object Factory. Manages deserialization. - **in3.libin3**: Module for the libin3 runtime. Libin3 is written in C and can be found [here](https://github.com/slockit/in3-c). - **in3.libin3.shared**: Native shared libraries for multiple operating systems and platforms. @@ -402,72 +402,6 @@ To address: ``` -### smart_meter_write - -source : [in3-c/python/examples/smart_meter_write.py](https://github.com/slockit/in3-c/blob/master/python/examples/smart_meter_write.py) - - - -```python -""" -[{"type":"event","name":"NewReadStored","inputs":[{"type":"address","name":"meter","internalType":"address","indexed":true},{"type":"uint256","name":"bucket","internalType":"uint256","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":false},{"type":"uint256","name":"timestamp","internalType":"uint256","indexed":false},{"type":"bytes","name":"data","internalType":"bytes","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","payable":false,"outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"DAILY_BUCKET","inputs":[],"constant":true},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"store","inputs":[{"type":"address","name":"meter","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"bucket","internalType":"uint256"}],"constant":false},{"type":"function","stateMutability":"nonpayable","payable":false,"outputs":[],"name":"storeWithDailyBucket","inputs":[{"type":"address","name":"meter","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"},{"type":"uint256","name":"timestamp","internalType":"uint256"}],"constant":false}] - -0xf23FF7472FC62C6bEe2F960f5b4170Ab3C1C26d2 -""" -import base64 -import json - -import in3 -import hashlib -import random -import time - -if __name__ == '__main__': - - c = in3.Client(chain='ewc', in3_config=in3.ClientConfig(transport_binary_format=True)) - - smart_meter_registry_addr = '0xf23FF7472FC62C6bEe2F960f5b4170Ab3C1C26d2' - # meter, bucket, operator, timestamp, data - NewReadStoredEvent = 'NewReadStored(address,uint,address,uint,bytes))' - try: - # meter, data, timestamp - storeWithDailyBucket = 'storeWithDailyBucket(address,bytes,uint256)' - meter_addr = '0xb11469A59dF65312737053c4785FA7Ff28660013' - salt = hex(random.getrandbits(64)) - secret_read = hashlib.sha512(b'1101101') - secret_read.update(salt.encode('utf8')) - secret_read = secret_read.hexdigest() - # secret_read = base64.b64encode(secret_read.digest()) - timestamp = int(time.time()) - sender_secret = input("Sender secret: ") - sender = c.eth.account.recover(sender_secret) - encoded_contract_call = c.eth.contract.encode(storeWithDailyBucket, meter_addr, secret_read, timestamp) - tx = in3.eth.NewTransaction(to=smart_meter_registry_addr, - data=encoded_contract_call) - tx.gasLimit = c.eth.account.estimate_gas(tx) - tx_hash = c.eth.account.send_transaction(sender=sender, transaction=tx) - print('https://explorer.energyweb.org/tx/{}'.format(tx_hash)) - confirmation_wait_time_in_seconds = 60 - while True: - try: - print('\n[.] Waiting {} seconds for confirmation.\n'.format(confirmation_wait_time_in_seconds)) - time.sleep(confirmation_wait_time_in_seconds) - receipt: in3.eth.TransactionReceipt = c.eth.transaction_receipt(tx_hash) - print('[.] Transaction was sent successfully!\n') - print(json.dumps(receipt.to_dict(), indent=4, sort_keys=True)) - print('[.] Mined on block {} used {} GWei.'.format(receipt.blockNumber, receipt.gasUsed)) - break - except Exception: - print('[!] Transaction not mined yet, check https://etherscan.io/gasTracker.') - print('[!] Just wait some minutes longer than the average for the price paid!') - except in3.PrivateKeyNotFoundException as e: - print(str(e)) - except in3.ClientException as e: - print('Client returned error: ', str(e)) - print('Please try again.') - -``` - ### Running the examples @@ -498,7 +432,7 @@ Client(self, chain: str = 'mainnet', in3_config: ClientConfig = None, cache_enabled: bool = True, -transport=) +transport=) ``` Incubed network client. Connect to the blockchain via a list of bootnodes, then gets the latest list of nodes in @@ -622,8 +556,6 @@ response_includes_code: bool = None, response_keep_proof: bool = None, transport_binary_format: bool = None, transport_ignore_tls: bool = None, -cached_blocks: int = None, -cached_code_bytes: int = None, boot_weights: bool = None, in3_registry: dict = None) ``` @@ -657,8 +589,6 @@ The verification policy enforces an extra step of security, adding a financial s - `response_keep_proof` _bool_ - If true, proof data will be kept in every rpc response. False will remove this data after using it to verify the responses. Useful for debugging and manually verifying the proofs. - `transport_binary_format` - If true, the client will communicate with the server using a binary payload instead of json. - `transport_ignore_tls` - The client usually verify https tls certificates. To communicate over insecure http, turn this on. -- `cached_blocks` _int_ - Maximum blocks kept in memory. example: 100 last requested blocks -- `cached_code_bytes` _int_ - Maximum number of bytes used to cache EVM code in memory. example: 100000 bytes - `boot_weights` _bool_ - if true, the first request (updating the nodelist) will also fetch the current health status and use it for blacklisting unhealthy nodes. This is used only if no nodelist is availabkle from cache. - `in3_registry` _dict_ - In3 Registry Smart Contract configuration data @@ -1298,7 +1228,7 @@ Load libin3 shared library for the current system, map function ABI, sets in3 ne #### libin3_new ```python libin3_new(chain_id: int, cache_enabled: bool, -transport_fn: ) +transport_fn: ) ``` Instantiate new In3 Client instance. diff --git a/python/examples/README.md b/python/examples/README.md index 6dcb7d55e..609fb74cb 100644 --- a/python/examples/README.md +++ b/python/examples/README.md @@ -11,8 +11,6 @@ - [smart_contract](./smart_contract.py) -- [smart_meter_write](./smart_meter_write.py) - ### Running the examples To run an example, you need to install in3 first: diff --git a/scripts/update_examples.sh b/scripts/update_examples.sh index aae640361..aeda4801d 100755 --- a/scripts/update_examples.sh +++ b/scripts/update_examples.sh @@ -68,13 +68,13 @@ printf "# Examples\n\n" > $README for f in */; do - printf "### ${f%/*}\n\nsource : [in3-c/dotnet/Examples/${f%/*}](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/${f%/*}/Program.cs)\n\n" >> $DOC + printf "### ${f%/*}\n\nsource : [in3-c/dotnet/Examples/$f/${f%/*}](https://github.com/slockit/in3-c/blob/master/dotnet/Examples/$f/${f%/*}/Program.cs)\n\n" >> $DOC printf "\n\n\`\`\`c#\n" >> $DOC - cat ${f%/*}/Program.cs >> $DOC + cat $f/${f%/*}/Program.cs >> $DOC printf "\n\`\`\`\n\n" >> $DOC - printf "\n- [${f%/*}](./${f%/*}/Program.cs)\n" >> $README - cat ${f%/*}/Program.cs | grep -v // | sed "s/\/\/\/ //g" >> $README + printf "\n- [${f%/*}](./$f/${f%/*}/Program.cs)\n" >> $README + cat $f/${f%/*}/Program.cs | grep -v // | sed "s/\/\/\/ //g" >> $README done cat ../../dotnet/docs/build_examples.md_ >> $DOC