Who i can create Developer and marketing fee with burn for my smart contract?
I did a lot of research and looked at different classes but could not create anything similar. Is there a project property that I can use?
do you know?
how many words do you know
See also questions close to this topic
-
Modify user input to use in exec call
I am trying to modify a user input string to call execvp in a future function. In my code I have a function which tokenises the user input such that if the user entered in: command a b c. It outputs
char** output = { "command", "a", "b", "c", NULL }
The length of the user input is unknown. My issue is that I want to modify the variable char** output to remove the user entered command, such that I getchar** output = {"a", "b", "c", NULL }
My current attempt at this is in the code below:char** exec_arg(char** output, int numTokens){ 143 char* argExec[numTokens]; 147 for(int k = 0; k < (numTokens-1); k++){ 148 argExec[k] = output[k+1]; 149 printf("%s", argExec[k]); 150 } 152 return argExec; 155 }
However I am finding that when I run this I am getting the output: {"a", "b", "c"}
-
Docker Registry Authentication/Authorization - signed by untrusted key with ID
Honestly, it this point im begging for help
So im trying to add protection for my docker registry ( i do not wanna use htpassword ) which is run like this:
docker compose file
version: '3' services: registry: restart: always image: registry:2 ports: - "5000:5000" environment: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data REGISTRY_HTTP_ADDR: 127.0.0.1:5000 REGISTRY_AUTH: token REGISTRY_AUTH_TOKEN_REALM: http://api.thechemicalworkshop.com/api/authorize_docker REGISTRY_AUTH_TOKEN_ISSUER: "The Chemical Workshop" REGISTRY_AUTH_TOKEN_SERVICE: "dockerhub.thechemicalworkshop.com" REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE: /ssl/cert.dockerhub.crt volumes: - ./data:/data - ./ssl:/ssl network_mode: host
how it should work is that REGISTRY_AUTH_TOKEN_REALM handles the protection i tired self signed cetfiticates in REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE but same result (more below)
im using nginx as reverse proxy and ssl (should be self explanatory) (and the reason why i host it on localhost)
server { client_max_body_size 2000m; proxy_pass_request_headers on; server_name dockerhub.thechemicalworkshop.com; location / { # Do not allow connections from docker 1.5 and earlier # docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) { return 404; } proxy_pass http://127.0.0.1:5000; proxy_set_header Host $http_host; # required for docker client's sake proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 900; proxy_pass_request_headers on; } listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/dockerhub.thechemicalworkshop.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/dockerhub.thechemicalworkshop.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
anyways every time i access the registry on server_name it should call REGISTRY_AUTH_TOKEN_REALM to accept/deny
the REGISTRY_AUTH_TOKEN_REALM on stuff is an API in python (quart) with following script:
raw_token = 'eyJ0eXAiOiJKV1Q' if matti_check(request.headers["X-Real-Ip"]): payload = {"expires_in": 360000,"issued_at": "2022-04-30T15:33:00Z"} payload['token'] = raw_token response = await make_response(payload) return response else: print(request.headers) return "ERROR", 500
token shortened due to space
ignore matti_check() it works fine basically im returning a token alongside some other stuff
to generate the token im using following script:
encoded = jwt.encode(\ {\ "iss": "The Chemical Workshop", \ "aud": "dockerhub.thechemicalworkshop.com",\ "exp": 1687927320000\ }, \ private_key, algorithm="RS256", headers={"kid": "MY4D:MNRW:GY2T:IZBS:HAZT:QZRS:MQ4G:IMBX:GA4D:AYJY:GBST:AMJX"}) print(encoded)
the kid header gets generated by me like this:
- first I convert the cerificate using
openssl x509 -in cert.dockerhub.crt -noout -outform der -pubkey
- I take the key and I sha256 it, for testing I use https://emn178.github.io/online-tools/sha256.html
- in the third step I take the first 30 characters and base32 encode it, again using https://emn178.github.io/online-tools/base32_encode.html for testing
- then I whack
:
between every 4 characters
Docker documentation says i should do this to get kid:
Take the DER encoded public key which the JWT token was signed against.
Create a SHA256 hash out of it and truncate to 240bits.
Split the result into 12 base32 encoded groups with : as delimiter.
so I think my approach is correct?
well, it does not work :/
I just get an error
docker-registry-registry-1 | time="2022-04-30T17:10:56.438672709Z" level=info msg="token signed by untrusted key with ID: "MY4T:KNRU:GJSW:ENRU:GFRW:CYZW:GNRW:CMLC:GVTG:KM3D:MRSW:CZTD""
Could someone ( i dont know go ) look into portus/docker registry source how they generate a working key?
here is what i tried:
- asking on docker forum <-- more info
- asking on lowendtalk
- asking on like 8 discords
- trying self signed keys, as well as certbot keys
- create github issue/ask questions (no anwsers/solutions)
- ask some random dude from this project on twitter (no anwser)
- googling, trying to read go code (no luck/anwsers)
- trying different keys (same result)
- creating a "bounty" (5$ if you ask, im broke) on fiverr (no capable people or way way overbudget)
Can you guys fix this or give me some lead on how to fix this? my "project" would be opensource as i dont see an implementation in python
- first I convert the cerificate using
-
Can't import openzeppelin library into smart contract in brownie framework
I can't import openzeppelin's ERC721 contract. I have installed it using brownie pm install and also added it to brownie-config.yaml
I appreciate any help -
Gas estimation failed: 'invalid opcode: INVALID'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually
I adapted the code from this tutorial for my needs. It works fine at rinkeby network, but I am getting an error when I try to run it on Mumbai network.
AdvancedCollectible.sol >>
pragma solidity 0.6.6; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol"; contract AdvancedCollectible is ERC721 { bytes32 internal keyHash; uint256 public fee; event requestedCollectible(address indexed senderAdd); uint256 public tokenCounter; struct Remedio { string nome_medicamento; uint256 dosagem; string farmaceutica; string posologia; } enum Breed{PUG, SHIBA_INU, ST_BERNARD} mapping(uint256 => address) public requestIdToSender; mapping(uint256 => Breed) public tokenIdToBreed; mapping(uint256 => Remedio) public tokenIdToRemedio; mapping(uint256 => uint256) public requestIdToTokenId; constructor() public ERC721("GeradorReceitasMedicas", "Receita") { tokenCounter = 0; } function createCollectible(string memory nomeMedicamento, uint256 dosagem, string memory farmaceutica, string memory posologia) public returns (bytes32) { uint256 newItemId = tokenCounter; tokenCounter = tokenCounter + 1; Remedio memory newRemedio = Remedio({ nome_medicamento: nomeMedicamento, dosagem: dosagem, farmaceutica: farmaceutica, posologia: 'posologia' }); requestIdToSender[newItemId] = msg.sender; address receitaOwner = requestIdToSender[newItemId]; _safeMint(receitaOwner, newItemId); tokenIdToRemedio[newItemId] = newRemedio; emit requestedCollectible(receitaOwner); } }
LinkTokenInterface.sol:
pragma solidity ^0.6.6; interface LinkTokenInterface { function allowance(address owner, address spender) external view returns (uint256 remaining); function approve(address spender, uint256 value) external returns (bool success); function balanceOf(address owner) external view returns (uint256 balance); function decimals() external view returns (uint8 decimalPlaces); function decreaseApproval(address spender, uint256 addedValue) external returns (bool success); function increaseApproval(address spender, uint256 subtractedValue) external; function name() external view returns (string memory tokenName); function symbol() external view returns (string memory tokenSymbol); function totalSupply() external view returns (uint256 totalTokensIssued); function transfer(address to, uint256 value) external returns (bool success); function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success); function transferFrom(address from, address to, uint256 value) external returns (bool success); }
DeployAdvanced.py:
from brownie import AdvancedCollectible, accounts, network, config from scripts.helpful_scripts import fund_advanced_collectible def main(): print(config['wallets']['from_key']) dev = accounts.add(config['wallets']['from_key']) print(network.show_active()) #print(config['networks'][network.show_active()]['host']) publish_source = False print(config['wallets']['from_key']) advanced_collectible = AdvancedCollectible.deploy( {"from": dev}, publish_source=publish_source, ) fund_advanced_collectible(advanced_collectible) return advanced_collectible
helpful_scripts.py:
from brownie import AdvancedCollectible, accounts, config, interface, network def fund_advanced_collectible(nft_contract): dev = accounts.add(config['wallets']['from_key']) link_token = interface.LinkTokenInterface( config['networks'][network.show_active()]['link_token'] ) link_token.transfer(nft_contract, 1000000000000000000, {"from": dev})
brownie-config.yaml:
exclude SafeMath when calculating test coverage
https://eth-brownie.readthedocs.io/en/v1.10.3/config.html#exclude_paths
reports: exclude_contracts: - SafeMath dependencies:
- smartcontractkit/chainlink-brownie-contracts@1.1.1
- OpenZeppelin/openzeppelin-contracts@3.4.0 compiler: solc:
remappings:
- '@chainlink=smartcontractkit/chainlink-brownie-contracts@1.1.1'
- '@openzeppelin=OpenZeppelin/openzeppelin-contracts@3.4.0'
automatically fetch contract sources from Etherscan autofetch_sources: True dotenv: .env
set a custom mnemonic for the development network networks: default: development kovan:
vrf_coordinator: '0xdD3782915140c8f3b190B5D67eAc6dc5760C46E9' link_token: '0xa36085F69e2889c224210F603D836748e7dC0088' keyhash: '0x6c3699283bda56ad74f6b855546325b68d482e983852a7a82979cc4807b641f4' fee: 100000000000000000 oracle: '0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e' jobId: '29fa9aa13bf1468788b7cc4a500a45b8' eth_usd_price_feed: '0x9326BFA02ADD2366b30bacB125260Af641031331' rinkeby: vrf_coordinator: '0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B' link_token: '0x01be23585060835e02b77ef475b0cc51aa1e0709' keyhash: '0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311' fee: 100000000000000000 oracle: '0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e' jobId: '6d1bfe27e7034b1d87b5270556b17277' eth_usd_price_feed: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e' host: 'https://rinkeby.infura.io/v3/${WEB3_INFURA_PROJECT_ID}' mumbai: link_token: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB' eth_usd_price_feed: '0x0715A7794a1dc8e42615F059dD6e406A6594651A' polygon-test: link_token: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB' eth_usd_price_feed: '0x0715A7794a1dc8e42615F059dD6e406A6594651A' binance: # link_token: ?? eth_usd_price_feed: '0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e' binance-fork: eth_usd_price_feed: '0x9ef1B8c0E4F7dc8bF5719Ea496883DC6401d5b2e' mainnet-fork: eth_usd_price_feed: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419' matic-fork: eth_usd_price_feed: '0xF9680D99D6C9589e2a93a78A04A279e509205945' wallets: from_key: ${PRIVATE_KEY} from_mnemonic: ${MNEMONIC}
settings: gas_limit: "100000000000"
When I run it on Rinkeby, I get (run command brownie run .\scripts\advancedCollectible\deploy_advanced.py --network rinkeby):
INFORMAÇÕES: não foi possível localizar arquivos para o(s) padrão(ões) especificado(s). Brownie v1.18.1 - Python development framework for Ethereum
ContratoNftProject is the active project.
Running 'scripts\advancedCollectible\deploy_advanced.py::main'... fdb0ee33d87a414d57235c1eb5df7b3cd15a69c3041214584e4eb2d2b220e2ef rinkeby fdb0ee33d87a414d57235c1eb5df7b3cd15a69c3041214584e4eb2d2b220e2ef Transaction sent: 0xf3cbcf650ab9b4408f8e795469ffa60a61f5943ab485ec133e3650fece7545db
Gas price: 1.499999222 gwei Gas limit: 2377218 Nonce: 67
AdvancedCollectible deployed at: 0x5D37fc76D54880F878a395755df5101B644B655aC:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\network\contract.py:1180: BrownieCompilerWarning: 0x5D37fc76D54880F878a395755df5101B644B655a: Locally compiled and on-chain bytecode do not match! warnings.warn( Transaction sent: 0x74a64ac1449a597584bbca8dc0947e80a6ad042ca68453da6e550a0dbbfe67da
Gas price: 1.499999221 gwei Gas limit: 56992 Nonce: 68
LinkToken.transfer confirmed Block: 10631644 Gas used: 51811 (90.91%)When I run it on Mumbai, I get (run command brownie run .\scripts\advancedCollectible\deploy_advanced.py --network polygon-test):
INFORMAÇÕES: não foi possível localizar arquivos para o(s) padrão(ões) especificado(s). Brownie v1.18.1 - Python development framework for Ethereum
ContratoNftProject is the active project.
Running 'scripts\advancedCollectible\deploy_advanced.py::main'... fdb0ee33d87a414d57235c1eb5df7b3cd15a69c3041214584e4eb2d2b220e2ef polygon-test fdb0ee33d87a414d57235c1eb5df7b3cd15a69c3041214584e4eb2d2b220e2ef Transaction sent: 0x6915605b9dfb985b8ef078e3268a6b6e6e2e0b95d3d25ce8e5912c7a71db84d7
Gas price: 1.759579396 gwei Gas limit: 2377218 Nonce: 13
AdvancedCollectible.constructor confirmed Block: 26234140 Gas used: 2161108 (90.91%) AdvancedCollectible deployed at: 0xdbae4544699a953f2b28AFfBA77008Fd9eb1B4CfFile "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie_cli\run.py", line 51, in main return_value, frame = run( File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\project\scripts.py", line 103, in run return_value = f_locals[method_name](*args, **kwargs) File ".\scripts\advancedCollectible\deploy_advanced.py", line 16, in main fund_advanced_collectible(advanced_collectible) File ".\scripts\helpful_scripts.py", line 10, in fund_advanced_collectible link_token.transfer(nft_contract, 1000000000000000000, {"from": dev}) File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\network\contract.py", line 1710, in call return self.transact(*args) File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\network\contract.py", line 1583, in transact return tx["from"].transfer( File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py", line 644, in transfer receipt, exc = self._make_transaction( File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\network\account.py", line 727, in _make_transaction
raise VirtualMachineError(e) from None File "C:\Users\p\AppData\Roaming\Python\Python39\site-packages\brownie\exceptions.py", line 93, in init raise ValueError(str(exc)) from None ValueError: Gas estimation failed: 'invalid opcode: INVALID'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.Why am I getting this error on Mumbai Network? Is it possible to fix the error above?
-
Sending ether from Contract A to Contract B
I'm trying to send ether from contract A to Contract B but it's currently not connecting to Metamask. I'm not sure if I need to add something else in order to inherit from another contract or if the problem is with the function. I want to send ether to the owner in Contract A and have tried looking at all solutions online but not having any luck. I wanted to do this all in one contract and although the transaction went through, it wasn't sent to the owner so I am now trying to send from another contract instead.
Any help on how to fix this so I can send ether to the owner would be appreciated.
Contract A:
struct Building { string name; address owner; int256 posX; int256 posY; int256 posZ; uint256 sizeX; uint256 sizeY; uint256 sizeZ; address tenant; } Building[] public buildings; buildings.push( Building('Plot 1', address(0x0), 0, 0, 0, 10, 10, 10, address(0x0)) );
Contract B:
contract B { uint public amount = 1 ether; function sendRentalPayment(address payable owner) payable public { require(msg.value >= amount); owner.transfer(msg.value); } }
App.js
await senderContract.methods.sendRentalPayment().send({from: account, value: '1000000000000000000' })
-
How to create ERC20 token that give 0.5% of tokens from all of transaction to developer?
How to create ERC20 token that give 0.5% of tokens from all of transaction to developer? For example, When someone send tokens from wallet1 to wallet2
-
airdrop my won token and lick them for specific time
I want to airdrop and presale my won token so in the next step I want to lock them until my IDO data come and unlock in this time 30% of user wallet balances and next month 50 % what is the best way to do this
-
web3dart estimating gas fee exception
I'm trying to estimate the gas fee for the ERC20 token transaction - in this case transferring DAI from one address to another (on Mumbai).
The code for estimating the gas fee:
final contract = DeployedContract(ContractAbi.fromJson(abi, token.id), // 'dai' EthereumAddress.fromHex(token.contractAddress)); // 0xcB1e72786A6eb3b44C2a2429e317c8a2462CFeb1 final transferFunction = contract.function('transferFrom'); final transaction = Transaction.callContract( contract: contract, function: transferFunction, parameters: [ EthereumAddress.fromHex(address), // 0x2970C7181450B6c13071131f0005ccA18436c12B EthereumAddress.fromHex(recipientAddress), // 0xc7c6BAEA62Ff6BBAca799156CC4e9f50BC9e8060 10000000000000, // 0.001 Dai ], ); final fee = await _client.estimateGas( to: transaction.to, value: transaction.value, data: transaction.data, );
However, I'm getting
RPCError: got code 3 with msg "execution reverted: Dai/insufficient-allowance"
. The sender address holds enough tokens (approx. 0.0038 Dai). I have tried first to callapprove
with the same amount but I'm getting a different exceptionRPCError: got code -32000 with msg "already known".
and the gas estimation still fails.Any ideas on how to estimate correctly with
web3dart
? -
Change tax class if field in checkout is not empty in WooCommerce
I am using standard tax rate in WooCommerce but if I want to sell to business customer in other country, then VAT rate must be lower. How can I change tax to "Reduced rate" if field with ID "billing_ic" is filled?
I am tried this, but it does not work:
function wc_different_rate( $tax_class, $product ) { $checkout = WC()->checkout(); $billing_ic = $checkout->get_value( 'billing_ic' ); if ($billing_ic == '') { $tax_class = 'standard-rate'; } else { $tax_class = 'reduced-rate'; } return $tax_class; }
-
WooCommerce set_taxes() not acting correctly
I am trying to make an order programmatically in PHP. However the shipping taxes does not show up correctly.
The documentation https://woocommerce.github.io/code-reference/classes/WC-Order-Item-Shipping.html#method_set_taxes says it expects an array and that is what I give to them...
$shipping_lines = [ "method_id" => $id, "total" => [ "dhlpwc-parcelshop"=> "10.00" ], "totalPrice" => number_format((float)$price,2, '.', '') ]; $item = new WC_Order_Item_Shipping(); $item->set_method_id($shipping_lines['method_id']); // set an existing Shipping method rate ID $item->set_taxes($shipping_lines['total']); $item->set_total($shipping_lines['totalPrice']); // (optional) $order->add_item( $item ); $order->save();
So what is wrong? I also do not get an error in the logs.
Thanks!
-
Set custom fees as shipping fee in woocommerce orders
I need to apply custom dynamic fees to my cart/orders based on dimensions of my products that are inside the cart/order. I use the
add_fee
function that seems to be working fine, it shows up on the orders emails etc but I want this fees to be included as shipping. It should show as shipping fee inside the orders emails, admin backend and woocommerce reports. But it does not. And Yes, I do name the fees as shipping fee and it shows in a separate line in the order overview page, but woocommerce reports still say that shipping = 0. This is problematic because I want to report the shipping costs on my orders. This is the function that I use to add feecalculations to get $shipping_price; WC()->cart->add_fee('Shipping', $shipping_price);
This
Shipping
does show up in order overview page.But, does not show up in here, woocommerce-reports page (shipping Tax amount)
So, I actually want to set a shipping price dynamically on the cart/order and show it as shipping price in the woocommerce backend (Orders Overview, Woocommerce Reports etc).