Skip to content

Instantly share code, notes, and snippets.

View farukterzioglu's full-sized avatar
🎯
Focusing

Faruk Terzioğlu farukterzioglu

🎯
Focusing
View GitHub Profile
@farukterzioglu
farukterzioglu / call-then-sendtx-pattern.js
Created June 28, 2018 17:19 — forked from ethers/call-then-sendtx-pattern.js
call-then-sendtx pattern for Ethereum Dapps
/*
In Ethereum, a contract can be written so that it returns a value for eth_call.
A Dapp can then check for success or error value of eth_call, before calling eth_sendTransaction,
to take advantage of eth_call effectively being a "preview" of the code flow that the transaction
will take. In traditional client-server, clients can't ask servers beforehand what's going to
happen when the client makes a call; with Dapps contracts can be written so that clients can ask
for a "preview" of what is going to happen, before any funds/ethers are actually utilized
(eth_call does not cost any ethers).
Note: it is possible that in between eth_call and when eth_sendTransaction is actually mined,
@farukterzioglu
farukterzioglu / delete_git_submodule.md
Created February 4, 2021 10:16 — forked from myusuf3/delete_git_submodule.md
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@farukterzioglu
farukterzioglu / wallet-wallet.go
Created April 7, 2019 16:40
TransferTransaction note-9
func (w *Wallet) txTransferToOutputs(address string, txHash chainhash.Hash, account uint32,
minconf int32, feeSatPerKB btcutil.Amount) (tx *txauthor.AuthoredTx, err error) {
fmt.Printf("txTransferToOutputs... \n")
chainClient, err := w.requireChainClient()
if err != nil {
return nil, err
}
var txToBoTransferred wtxmgr.Credit
<ItemGroup>
<PackageReference Include="Nethereum.Web3" Version="3.8.0" />
<PackageReference Include="Nethereum.ABI" Version="3.8.0" />
<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="NBitcoin.Secp256k1" Version="1.0.1" />
<PackageReference Include="NBitcoin" Version="5.0.27" />
<PackageReference Include="RestSharp" Version="106.10.1" />
<PackageReference Include="Moq" Version="4.14.6" />
@farukterzioglu
farukterzioglu / Response.txt
Last active December 10, 2019 08:19
multisig-test
ScriptError [ScriptError]:EvalFalse
ScriptVerify : [ScriptVerify]:StrictEnc | MinimalData | DiscourageUpgradableNops | CleanStack | Consensus | DiscourageUpgradableWitnessProgram | MinimalIf | NullFail
var inputList = new List<UnspentCoin>();
var unspentResponse = await client.ListUnspentAsync();
var unspentList = unspentResponse.OrderByDescending( x => x.Amount).ToList();
var inputBtcSum = new Money(0, MoneyUnit.BTC);
foreach (var unspent in unspentList) {
if( inputBtcSum >= totalPaymentAmountBtc) break;
inputBtcSum += unspent.Amount;
inputList.Add(unspent);
}
@farukterzioglu
farukterzioglu / bitcoin.cs
Created October 19, 2019 21:11
bitcoin sample
Dictionary<string, int> salaries = GetSalaryList();
...
Dictionary<string, int> GetSalaryList()
{
return new Dictionary<string, int>(){
{ "2N2LGTF2XWA5png8mT2fbHRzY9P4XDLWvGc", 2500},
{ "2N94h5bWDAFNsd7SB1f3cQ6RUMmoMaA44tQ", 4500},
{ "2MsjZP4DJmZeV1fRpAw8NcJWiibYopWL7fg", 2250},
{ "2N1cHqXYLas7bnLoCtMppD1yKtrXjRSmB5M", 10000},
{ "2NA9di1yBdHiwgJJVB27nPxpAc8YDpmdSS1", 12500}
@farukterzioglu
farukterzioglu / bitcoin.cs
Created October 19, 2019 20:57
bitcoin sample
var network = Network.RegTest;
var client = new RPCClient(
credentials: new NetworkCredential(
userName: "myuser",
password: "SomeDecentp4ssw0rd"),
address: new Uri("http://127.0.0.1:443"),
network: network);
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageType>Template</PackageType>
<PackageId>Worker.Extended</PackageId>
<Title>Worker Service (Extended)</Title>
<Authors>Faruk Terzioğlu</Authors>
<Description>Pretty much full project template for creating a worker service.</Description>
...
</PropertyGroup>
{
"author": "Faruk Terzioglu",
"name": "Worker Service (Extended)",
"description": "Pretty much full project template for creating a worker service.",
"groupIdentity": "Microsoft.Worker.Extended",
"identity": "Microsoft.Worker.Extended.CSharp.3.1",
"shortName": "workerextended",
"sourceName": "Company.Application1",
"primaryOutputs": [
{